Spécial ! |
Version mobile de l'aldweb Site m.aldweb.com Ni Français, ni Anglais ?Essayez donc l'un de ces drapeaux :
|
|
Météo / Spam / www |
Météo Lyon
aldweb contre le SPAM
|
|
|
|
|
|
|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 1589 |
I need to know about arrays :( |
le 20/10/2007 @ 22:43 par Nate Weil
|
Please someone just tell me how to initialize an array, like for instance test(1000) and to keep things simple, how to print from one of those, like print test(2534) Thanks! I need this for civ, or it won't even get started :D |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1 -------- le 20/10/2007 @ 23:39 par Tuka
visiteur |
Hello Nate,
From User Manual There are 2 arrays defined in iziBasic: A() and A$(). At runtime, both can address all Numbers and text Strings stacks (see Appendix #8). A-Z variables are also addressed with A(1)-A(26) DIM A(n) At design time, DIM A(n) reserves some space in the Numbers stack in addition to the A-Z variables Notes: - n>26 and n<=FRE(4) (see the MINOSVERSION compiling directive and appendix #8). You will have to leave some space in the upper stack for all other numerical assignments.
TEST() is not usable. My palm is Sony CLIE TJ25. An error was given in DIM A(1026). An error was given in DIM A(240). An array variable is too big.
My sample code. 'Arrays.iBAS {CreatorID "HELO"} {Version "1.0"} {PARSER ON} {CONSOLEFONT OFF} BEGIN DIM A(50) B=100:C=200:Y=300:Z=400 FOR I=27 TO 50 A=RND(100):A(I)=A NEXT FOR I=1 TO 50 A=A(I):A$=STR$(A,0)+" ":PRINT A$; A=I MOD 10:IF A=0 PRINT NEXT WAIT END |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 2 -------- le 21/10/2007 @ 00:17 par Nate Weil
visiteur |
So an array can't hold more than 50 variables? I had read the info on variables in the manual, but it didn't seem to make much sense except that you could refer to the 26 letters as A(1), A(2), etc. and that's not what I need. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 3 -------- le 21/10/2007 @ 01:06 par Tuka
visiteur |
Hello Nate,
The size of the array variable is different by a device. DIM A(230) succeeded with my device. The number stack is not reserved enough.
I use MegaString to solve this problem. It can store numbers from 0 to 255 if I use 1 character. It can store numbers from 0 to 65535 if I use 2 characters. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 4 -------- le 21/10/2007 @ 01:23 par Tuka
visiteur |
Hello,
I made a mistake. The size of the number stack changes by {MINOSVERSION t}.
'FRE.iBAS {CreatorID "HELO"} {Version "1.0"} {MINOSVERSION "5.0"} {PARSER ON} {CONSOLEFONT OFF} BEGIN A=FRE(4) PRINT A USING 0 WAIT END |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 5 -------- le 21/10/2007 @ 01:52 par Nate Weil
visiteur |
what does FRE(4) do? Thats the only bit I don't understand
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 6 -------- le 21/10/2007 @ 02:06 par JoeV
visiteur |
Hello Tuka,
That is a clever way to get around the memory limitation.
Nate,
Tuka is right. It depends on your OS version number. In PalmOS 5.0 you have an array size of almost 12,000. Its more like 11,980 because of some overhead needed by IziBasic. Of course, your palm must be able to run OS 5.0. Read the MINOSVERSION directive in the manual.
So if you can run OS 5.0, your code would look like this:
{MINOSVERSION "5.0"} dim a(11980) BEGIN 'program here END
Then to print variable z your program code would contain:
print z ...or... a=a(26) : print a
And to print any array variable above z you could write:
a=a(1234) : print a ...or... a=a(11980) : print a ...etc...etc
Print a(1234) is not allowed but you can perform mathematical ops like:
a(1004)=a(1000)*a(1001)/a(1003)
As Tuka said, you cannot do this:
dim test(11980)
All your array variables must be called a(n), where n is a valid number depending on your OS version, such as a(11980).
Hope this clears things up.
JoeV
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 7 -------- le 21/10/2007 @ 02:12 par Tuka
visiteur |
Hello Nate,
FRE(4) is last free address of Number Stack. It is not the greatest size of the array variable. But I think that it is an approximate aim. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 8 -------- le 21/10/2007 @ 02:21 par Tuka
visiteur |
Hello JoeV,
Thank you for detailed explanation. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 9 -------- le 21/10/2007 @ 02:56 par Nate Weil
visiteur |
ok... so is everything alright with this listing then?
dim a(10000),b(10000) begin a=a(59284) print a b=b(25934) print b end |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 10 -------- le 21/10/2007 @ 03:12 par Tuka
visiteur |
Hello Nate,
b() is not usable. We always use A(). A(59284) is too big.
dim a(10000) begin a=a(5000) print a using 0 b=a(2000) print b using 0 end |
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|
|
|
|
|