Source language: Translate to:

Initialize Array with StrParse

NeoBook tips, tricks, code samples and more...

Moderator: Neosoft Support

Initialize Array with StrParse

Postby Guest » Tue Nov 23, 2004 8:27 am

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

Postby dbz » Tue May 03, 2005 6:44 pm

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
User avatar
Posts: 42
Joined: Mon Apr 04, 2005 4:12 am
Location: Varel, Germany

Return to NeoBook Knowledgebase

Who is online

Users browsing this forum: No registered users and 0 guests