|
Post by rto0288 on Sept 15, 2006 20:15:38 GMT
CLS FOR I = 0 to 500 PRINT I; CHR$(I); " "; NEXT I
I read this almost verbatim from a tutorial and it's not working... gives me an illegal function call on the PRINT line.
--ALSO--
I'm having problems with the LOCATE command. I'm trying to use variables for my locate coordinates and it's giving me illegal function call on locate line. I do something like this:
CLS x=1 y=1 DO LOCATE x, y PRINT x; x=x+1 y=y+1 LOOP
>>this won't work for me...
|
|
|
Post by Mikrondel on Sept 16, 2006 1:02:53 GMT
Well first I commend you for explaining the problems well. Now; a bit of testing is in order. The "Immediate" window is where you type a line, and it gets executed as soon as you press enter. This lets you check things without having to modify your program. Say you Ctrl-Breaked out of something, (or an error kicked you out) you can use the immediate window to, for example, check what the variables were. For the first program: run it (get the error), then go into the Immediate window and type PRINT I You should get the number 256 on the screen. Ok, so maybe CHR$(256) doesn't work? Try PRINT CHR$(256) And there's your error. OK, so you can only use CHR$ for numbers between 0 and 255. This is because all printable characters are 1 byte; 1 byte can store integers from 0 to 255. ASCII is the system which connects each of those numbers to a symbol. CHR$() is a function that returns an ASCII character, and is only defined for numbers from 0 to 255 - otherwise you get an illegal function call. Anyway, change your FOR-loop to suit this limit. As a side note, a few characters of ASCII value between about 7 and 13 interfere with what's being displayed - e.g. CHR$(12) clears the screen, I think. Now, onto the second program. Similar issue. X and Y get out of the range that LOCATE supports. (Normally the screen is 80x25 or 80x50) Because your DO-LOOP goes on indefinitely, x and y will keep getting larger until an error occurs. As another side note, since in your second program x and y are always the same, you can get rid of anything involving y altogether, and just LOCATE x, x with exactly the same result (but a simpler and more efficient program). I'm working (very slowly, unfortunately. Extremely busy with school right now) on a tutorial that you may like to look at: aleks.budzynowski.info/wiki/quickbasic/tutorial/index
|
|