Page 1 of 1 1
Topic Options
#148889 - 2005-09-30 03:42 AM Data structures
theycallmebruce Offline
Lurker

Registered: 2005-09-29
Posts: 2
In the script I am currently writing, a linked list would be extremely useful. At the moment, I either need to process data twice to calculate the required array size, or continually redim arrays.

Are there any plans for kixtart to provide data structures such as linked lists, and possibly associative arrays?

Top
#148890 - 2005-09-30 09:45 AM Re: Data structures
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
In most (all?) cases you may use an INI file for associative arrays. I've used them for this in the past, sanitizing keys and data when needed. If your data and keys are simple enough you can use the file directly without any extra coding.

Linked lists are also fairly easy implement with an array:
Code:
Dim $avData[3,x]
; $avData[0,x] = Data
; $avData[1,x] = Reverse pointer
; $avData[2,x] = Forward pointer



I'm not saying that linked lists and associative arrays are not a good suggestion - they are an excellent suggestion - but while we wait for them to appear you can use these work-arounds.

Top
#148891 - 2005-09-30 09:53 PM Re: Data structures
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
If you want associate arrays (Hashes in Perl) you can easily use COM to access VBS dictionary objects.

Code:

Object that stores data key, item pairs.

Remarks
A Dictionary object is the equivalent of a PERL associative array. Items can be any form of data, and are stored in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually a integer or a string, but can be anything except an array.

The following code illustrates how to create a Dictionary object:

[VBScript]
Dim d ' Create a variable.
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens" ' Add some keys and items.
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
...
Methods
Add Method (Dictionary) | Exists Method | Items Method | Keys Method | Remove Method | RemoveAll Method

Properties
Count Property | Item Property | Key Property

See Also
FileSystemObject Object | TextStream Object



Just convert the VBS syntax to KiXtart.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 515 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.055 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org