Page 1 of 1

Initialize Array with StrParse

PostPosted: Tue Nov 23, 2004 8:27 am
by Guest
If you have an array to initialize, you could write something like this:

Code: Select all
.initialize array [Item]
SetVar "[Item1]" "V1"   ..V1 = value1
SetVar "[Item2]" "V2"
SetVar "[Item3]" "V3"
SetVar "[Item4]" "V4"
SetVar "[Item5]" "V5"
SetVar "[Item6]" "V6"
SetVar "[ItemCount]" "6"

or this:

Code: Select all
.initialize array [Item]
StrParse "V1,V2,V3,V4,V5,V6" "," "[Item]" "[ItemCount]"

Personally, I prefer the one-line 'StrParse' solution which has the added bonus of automatically counting the number of array elements.

Array Initialization

PostPosted: Tue May 03, 2005 6:44 pm
by dbz
Unless the data source is a variable file (data changes frequently),
you know and will have to type in all the data definitons, I prefer to LoadVariables; saves writing and executing the code to load - and debug - and also removes all the initialization code (and Define cnds, if you are the type to use them). from the program. Create a flatfile and LoadVariables 'it' into your program, and the array is there.

yeah i know, i am a little late answering this. dbz