|
Post by piegopher on Mar 4, 2002 17:25:45 GMT
Is there a way to make a goto command that goes to a label defined by a variable or something? Something like
x = int(rnd * 5) + 1 goto x
I know that that doesn't work, but it should. It makes sense in MY mind, therefore I am smarter than the computer. Mahaha! ...I'll go now
|
|
|
Post by brisray on Mar 4, 2002 19:22:05 GMT
This looks like it should work - I write lots of stuff that looks like it should work!
The GOTO, GOSUB statements expect a literal not a variable. Try using IF or SELECT CASE statements to control what happens.
x = INT(RND * 5) + 1
SELECT CASE x CASE 1 GOSUB MySub CASE 2 GOSUB NextSub END SELECT
This will work, but if x is a large range of numbers the SELECT CASE or IF statements are going to get a bit long.
Ray
|
|
|
Post by fly@aol.com on Mar 6, 2002 1:11:30 GMT
no. goto expects a previously specified location. now if you were using gwbasic you could do this, but qbasic disallows it.
if you are really hot to trot on this, try writing general code and use data statements to determine its content. for example:
input "enter data batch to process "; q if q=1 then restore one if q=2 then restore two if q=3 then restore three read a, b, c print a, b, c end one: 1, 2, 3 two: 4, 5, 6 three: 7, 8, 9
if you enter "1", it will print 1, 2, 3. if you enter "2", it will print 4, 5, 6. etc. this is about as close as you'll get.
|
|
|
Post by piegopher on Mar 6, 2002 20:19:47 GMT
Behhh... so what you're saying is that there is no easy way? bah! Oh well... I suppose I'll just have to work on my attention span. ...On second thought, that dog has a poofy tail! Heeheeheehee....
|
|