There is your subscript out of range error. Petit Computer takes your tab(33) as Variable Array "tab" element number 33! See how a simple posting of source code clears the issue immediately? Better make that a usual practice!
When you use PRINT (or ?) you can use either , or ; to separate normal text from variables.
, will print the variable after a "tab" while ; will print it right after the text.
: is used to separate different functions on the same line, like PRINT "HI": PRINT "HI AGAIN".
@Morphtroid
That's great explanation for using commas and semicolon with PRINT. Would you repost it in tutorial thread? It'd be good to keep all the explanations together.
Also, i got this error:
Subscript out of range (11)
My code is:
F(Q)=0
Whats wrong with that?
You need to ask better questions than that because there is nothing wrong with that statement. The error lies somewhere else. It is important that you write the shortest code that still demonstrate the problem. You need to figure out what the problem is and write a sample program that duplicates the same problem. If you have Duplicate Definition Error, you should write this program:
DIM A$[10]
and run it twice. Why did it fail the second time? DIM defines the variable. You cannot redefine variables here. There are different situations that can take advantage of previously defined variables, so this isn't an error. You need to figure out a way around it.
Don't take it the wrong way, but I think you should familiarize yourself with Petit Computer and type in other people's program and see how they work. Otherwise, we'd be porting your program for you, and who knows how long that will take? We're here to help, not do your homework for you. You need to have some initiative yourself.
Try to learn something new everyday, and write a small program to demonstrate your learning. Share if you do. We can use more tutorial pages!
Im sorry, its just frustrating when it doesnt work.
One more question, then im done..
Here is my full coding for a dice simulator.
LOCATE 10,1:? "Dice"
PRINT:PRINT:PRINT
DIM F(12)
PRINT "THIS PROGRAM SIMULATES THE ROLLING OF A"
PRINT "PAIR OF DICE."
PRINT "YOU ENTER THE NUMBER OF TIMES YOU WANT THE COMPUTER TO"
PRINT "'ROLL' THE DICE. WATCH OUT, VERY LARGE NUMBERS TAKE"
PRINT "A LONG TIME. IN PARTICULAR, NUMBERS OVER 5000."
FOR Q=1 TO 12
F(Q)=0
NEXT Q
PRINT:PRINT "HOW MANY ROLLS";
INPUT X
FOR S=1 TO X
A=INT(6*RND(1)+1)
B=INT(6*RND(1)+1)
R=A+B
F(R)=F(R)+1
NEXT S
PRINT
PRINT "TOTAL SPOTS","NUMBER OF TIMES"
FOR V=2 TO 12
PRINT V,F(V)
NEXT V
PRINT
PRINT:PRINT "TRY AGAIN";
INPUT Z$
IF Z$="YES" THEN 80
END
But it doesnt work:/
I tried dim F(Q), but it says duplicate definition.
Can someone help me i'm trying to use sphitsp like this IF SPHITSP (1,0) THEN GOSUB @STORE and it won't work (it is in a loop) all that happens is that the store opens as long as the store sprite is on screen.
Forums
Topic: Petit Computer
Posts 551 to 570 of 9,620
Please login or sign up to reply to this topic