Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Mon Nov 20, 2017 12:51 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Mar 03, 2006 10:24 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
Question



Can string arrays be used in Qlarity? Does Qlarity have support for multi-dimensional arrays? Is there a work around?



Answer



The Qlarity language does not have multi-dimensional arrays. We have a couple of ways of working around this.



One method is to use an array of integers indexing a large string to mimic a string array. We have functions built into Qlarity to manipulate and read strings from the 2 arrays such as _GetString, _AppendString, _DeleteString, _FindString, _GetStrCount, _RedimStrArray, _RemoveLastString and _SetString (see F1 help in Qlarity Foundry).



Another method of storing an array of strings (or any array) is to use an array of array handles. With this you put the array in memory and keep track of a reference to this memory location called an array handle. It is easy to cause a memory leak with lost array handles so you must keep track of all allocated array handles and be sure to free them. The functions for this are: AllocateArrayHandle, FreeArrayHandle, and ReadArrayHandle (see F1 help).



You could also create a pool of objects and use an array of object references to access your objects. The objects could have array variables in them. Lets say for example you wanted to create an array of labels. First in layout view you create 50 instances of labels with the names labe_1 to label_50. To put references to these objects into an array you can use code simliar to this:

Code:
'in globals



library basic source labelv2



dim labelrefs[50] as objref labelv2



func Startup ()

    handles MSG_INIT

    dim i as integer



    for i = 1 to 50

        val(labelrefs[i-1], "label_" + str(i))

    next

    return

endfunc


_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group