|
| WM 20: using arrays to build CSV files |
| Iniciado por guest, 08,oct. 2016 14:18 - 5 respuestas |
| |
| | | |
|
| |
| Publicado el 08,octubre 2016 - 14:18 |
Hi All,
I'm trying to use an array to build a csv file and get the error message
"Attempt to access element2. Number of Elements in Array Dimension 1:1"
I am new to arrays. My code is out of the help file:
MyString1 is string MyString1 = "%1,%2,%3,%4,%5,%6,%7,%8" MyArray is array of 1 string MyArray[1] = QRY_EXPORT.AssessmentIDonDevice MyArray[2] = QRY_EXPORT.CountryID MyArray[3] = QRY_EXPORT.RecordName MyArray[4] = QRY_EXPORT.LocationName MyArray[5] = QRY_EXPORT.LocationType MyArray[6] = QRY_EXPORT.Latitude MyArray[7] = QRY_EXPORT.Longitude MyArray[8] = QRY_EXPORT.RecordLocation MyResult is string = StringBuild(MyString1, MyArray) This is abbreviated; there are 197 items in the array.
Thanks for any help.
Pete |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,octubre 2016 - 15:25 |
Hi Pete,
if the order of the items is the same as in the Query, I should use something like from the top of my head, not tested):
MyResult is string lsItems = HListItem(QRY_EXPORT) FOR EACH STRING lsItem OF lsItems SEPARATED BY CRLF MyResult += [", "] + lsItem END |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,octubre 2016 - 15:50 |
Hi.
Try to define your array like arrMyArray is array of 8 by 1 string.
Too you can try to use arrayadd to populate your array with the values.
Rubén |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 28 mensajes |
|
| Publicado el 09,octubre 2016 - 08:32 |
| MyArray is array of 197 strings |
| |
| |
| | | |
|
| | |
| |
| Publicado el 09,octubre 2016 - 18:11 |
Thanks for the ideas Stefan and Ruben...I couldn't get either to work so went back to the long way of making strings.
Cheers
Pete |
| |
| |
| | | |
|
| | |
| |
| Publicado el 10,octubre 2016 - 14:47 |
Hi. For me this code works
MyString1 is string MyString1 = "%1,%2,%3,%4,%5,%6,%7,%8"
MyArray is array [8] string MyArray[1] = "1" MyArray[2] = "1" MyArray[3] = "1" MyArray[4] = "1" MyArray[5] = "1" MyArray[6] = "1" MyArray[7] = "1" MyArray[8] = "1"
sMyResult is string = StringBuild(MyString1, MyArray)
The result is "1,1,1,1,1,1,1,1"
Rubén |
| |
| |
| | | |
|
| | | | |
| | |
|