Here is my code:
TO CREATE_ARRAY
MAKE "CHESS_POS ARRAY [8 8]
FOR "I 0 7 [FOR "J 0 7 [PRINT :I PRINT :J ASET :CHESS_POS [:I :J] [44
((:I - 3.5) * :SQ.SZ) ((:J - 3.5) * :SQ.SZ)]
END
When I try running this I get the following message:
0
0
The procedure ASET needs a number as its input.
In function CREATE_ARRAY
\
Statement [FOR "I 0 7 [FOR "J 0 7 [PRINT :I PRINT :J ASET :CHESS_POS [" :\
I " :J] [44 ((:I - 3.5) * :SQ.SZ) ((:J - 3.5) * :SQ.SZ)]]]]
The reason I put the print statements in the procedure was to show that :I
and :J were really numbers.
Why am I getting an error message?
Any help is greatly appreciated. In advance, THANK YOU.
Could I have written the code as :
TO CREATE_ARRAY
MAKE "CHESS_POS ARRAY [8 8]
FOR "I 0 7
[FOR "J 0 7
[ASET :CHESS_POS [:I :J] [44 ((:I - 3.5) * :SQ.SZ) ((:J - 3.5) *
:SQ.SZ)]
END
?
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com
---------------------------------------------------------------
Please post messages to the Logo forum to log...@gsn.org. Mail
questions about the list administration to log...@gsn.org. To
unsubscribe send unsubscribe logo-l to majo...@gsn.org.
But in UCB/MSWLogo the code would look something like this, which has slightly different syntax.
But in general, you are missing two right brackets (a good reason to indent your code with each
pair of brackets visibly matched).
I would hope any Logo allows you to indent the code as you suggested but UCB/MSWLogo requires some
continuation symbols (~). Also multidimensional arrays are created with MDARRAY in UCB/MSWLogo.
Also, I believe you have some issues with constructing your lists of information that you want
"resolved". [:I :J] builds a list with the WORDS :I and :J not the value of I and J. Use the
function LIST to resolve these into their values. Same problem applies to the data you are
trying to place into the the array (which I assume was a list also).
Note also that UCB/MSWLogo allow you to set the base index to be what you want (usually 0 or 1).
I have told it to allow a base index of 0 since a base index 1 is the default and not appropriate here.
Note also that UCB/MSWLogo requires a delta for the FOR loop counter.
That should give you enough information to translate my changes back into your logo.
TO CREATE_ARRAY
make "SQ.SZ 100
MAKE "CHESS_POS (MDARRAY [8 8] 0)
FOR [I 0 7 1]~
[
FOR [J 0 7 1]~
[
mdsetitem (list :I :J) :CHESS_POS (list 44 ((:I - 3.5) * :SQ.SZ) ((:J - 3.5) * :SQ.SZ))
(PRINT :I :J "Contains mditem (list :i :j) :CHESS_POS)
]
]
END
CREATE_ARRAY
0 0 Contains 44 -350 -350
0 1 Contains 44 -350 -250
0 2 Contains 44 -350 -150
0 3 Contains 44 -350 -50
0 4 Contains 44 -350 50
0 5 Contains 44 -350 150
0 6 Contains 44 -350 250
0 7 Contains 44 -350 350
1 0 Contains 44 -250 -350
1 1 Contains 44 -250 -250
1 2 Contains 44 -250 -150
1 3 Contains 44 -250 -50
1 4 Contains 44 -250 50
1 5 Contains 44 -250 150
1 6 Contains 44 -250 250
1 7 Contains 44 -250 350
2 0 Contains 44 -150 -350
2 1 Contains 44 -150 -250
2 2 Contains 44 -150 -150
2 3 Contains 44 -150 -50
2 4 Contains 44 -150 50
2 5 Contains 44 -150 150
2 6 Contains 44 -150 250
2 7 Contains 44 -150 350
3 0 Contains 44 -50 -350
3 1 Contains 44 -50 -250
3 2 Contains 44 -50 -150
3 3 Contains 44 -50 -50
3 4 Contains 44 -50 50
3 5 Contains 44 -50 150
3 6 Contains 44 -50 250
3 7 Contains 44 -50 350
4 0 Contains 44 50 -350
4 1 Contains 44 50 -250
4 2 Contains 44 50 -150
4 3 Contains 44 50 -50
4 4 Contains 44 50 50
4 5 Contains 44 50 150
4 6 Contains 44 50 250
4 7 Contains 44 50 350
5 0 Contains 44 150 -350
5 1 Contains 44 150 -250
5 2 Contains 44 150 -150
5 3 Contains 44 150 -50
5 4 Contains 44 150 50
5 5 Contains 44 150 150
5 6 Contains 44 150 250
5 7 Contains 44 150 350
6 0 Contains 44 250 -350
6 1 Contains 44 250 -250
6 2 Contains 44 250 -150
6 3 Contains 44 250 -50
6 4 Contains 44 250 50
6 5 Contains 44 250 150
6 6 Contains 44 250 250
6 7 Contains 44 250 350
7 0 Contains 44 350 -350
7 1 Contains 44 350 -250
7 2 Contains 44 350 -150
7 3 Contains 44 350 -50
7 4 Contains 44 350 50
7 5 Contains 44 350 150
7 6 Contains 44 350 250
7 7 Contains 44 350 350
--
===============================================================
George Mills
email: mi...@softronix.com
http://www.softronix.com
The www page contains some very powerful educational software.
Our single most important investment is our kids.