keys
(Fresh Scripter)
2003-09-26 01:08 AM
simple programming

My brain is broken.
code:
 
$errorpile[3] ;declaration of array with 4 slots
$test = "This is a test." ;test string
$errorpile[2] = $test ; assign slot 2 to $test
? $errorpile[2] ;print slot 2

I was hoping this would print "This is a test."
Compile error on line:
$errorpile[2] = $test

Please help. Thanks


Les
(KiX Master)
2003-09-26 01:11 AM
Re: simple programming

KiX is an interpeter lasnguage, not a compiled one. Are you sure you have the right board?

ShawnAdministrator
(KiX Supporter)
2003-09-26 01:11 AM
Re: simple programming

Try slapping a DIM in your declaration there:

dim $errorpile[3]

-Shawn


Howard Bullock
(KiX Supporter)
2003-09-26 01:12 AM
Re: simple programming

code:
Dim $errorpile[3] ;declaration of array with 4 slots
$test = "This is a test." ;test string
$errorpile[2] = $test ; assign slot 2 to $test
? $errorpile[2] ;print slot 2

Dang! Way too slow tonight [Frown]

[ 26. September 2003, 01:12: Message edited by: Howard Bullock ]


LonkeroAdministrator
(KiX Master Guru)
2003-09-26 01:12 AM
Re: simple programming

you declare variable either by assigning a value to it or by explicitly making it something with global or dim.
you do none of these.

simple change your "declaration" line to:
dim $errorpile[3]

and it should work just fine


Sealeopard
(KiX Master)
2003-09-26 04:09 PM
Re: simple programming

And the use of variables/arrays is documented in the KiXtart Manual.

keys
(Fresh Scripter)
2003-09-26 11:00 PM
Re: simple programming

Thanks for all the help. I am actually declaring $errorpile in a script that calls other scripts that will dump their errors into this array.
So, from your advice I declared the variable a GLOBAL and all is well.
Interpreted langauge? Does this mean the scripts are run directly by kix32.exe and the errors come out as the script is being interpreted.
Thanks again


Sealeopard
(KiX Master)
2003-09-26 11:02 PM
Re: simple programming

Yes, that is how an Interpreter works, OTOH a compiler compiles a script/program into binary code that can be executed directly.