Page 1 of 1 1
Topic Options
#35678 - 2003-01-24 04:44 PM Declare Array
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I am trying to setup an array like this:

Lets say that $RecCount has been set alreay as a numeric VAL.

code:
$Array[$RecCount]  

Now I am trying to use the array like this:

code:
$Index = 0
$Line = ReadLine(Something)
while @ error = 0
$Array[$Index] = $Line
$Index = $Index +1
$Line = ReadLine (Something)
Loop

It seems I am doing something wrong with the array index.. can anyone help me with this.

Thanks
_________________________
Austin Henderson

Top
#35679 - 2003-01-24 04:46 PM Re: Declare Array
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Try:
Using the DIM statement: Dim $array[7]

You may have to use execute also.
$rc = execute("$$Array[$Index] = $Line")

[ 24. January 2003, 16:49: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#35680 - 2003-01-24 04:48 PM Re: Declare Array
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Why the $$Array just curious?

Will try now..
_________________________
Austin Henderson

Top
#35681 - 2003-01-24 04:50 PM Re: Declare Array
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I seem to remember a problem with the interpretation of vars in array indexes on the left side of the equal sign. I am doing some testing now too. I don't want to mislead you.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#35682 - 2003-01-24 04:53 PM Re: Declare Array
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You seem to have an errant space in the @ERROR macro in the while loop.

[ 24. January 2003, 16:53: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#35683 - 2003-01-24 04:54 PM Re: Declare Array
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
On the dim can you do it like $Array[$RecCount]

?

Thanks

Specifically here is what I am doing.

code:
  $Index = 0
While (Stuff Happening)
$STMI[$Index] = Val ("$Line")
?"Value: "$Array[$Index]
$STMITot = $STMITot + $STMI[$Index]
$Index = $Index + 1
Loop

Does this look wrong?
_________________________
Austin Henderson

Top
#35684 - 2003-01-24 04:56 PM Re: Declare Array
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Sorry about that I was trying to give a simplified example of what I was doing but screwed it up.. I know that space is not there.

Thanks

I guess maybe I need to know how to properly define an array but I need it to contain a variable amount of records? Is that possible?

Thanks
_________________________
Austin Henderson

Top
#35685 - 2003-01-24 04:56 PM Re: Declare Array
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I have tested this and it works:
code:
break on
$RecCount=5
Dim $Array[$RecCount]

? ubound($Array)


$Index = 0

for $index=1 to 5
$Array[$Index] = $index
next

For each $item in $Array
? $item
next

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#35686 - 2003-01-24 04:58 PM Re: Declare Array
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Thanks Howard I will work on that.. appreciate it.
_________________________
Austin Henderson

Top
#35687 - 2003-01-24 09:06 PM Re: Declare Array
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
This might give you an idea on how to dim and redim array sizes...
Array Declaration Question
_________________________
We all live in a Yellow Subroutine...

Top
#35688 - 2003-01-24 09:31 PM Re: Declare Array
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Waltz.. thank you for the link.

Appreciate it.. will read up.
_________________________
Austin Henderson

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.069 seconds in which 0.034 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