Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / SUCK-on text game could you lend me a minute to help?

Author
Message
vivi
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 30th Jan 2003 22:26
OK here is my code so far:






OK......there is something wrong. I think i have messed up.
I am making the letter in the array to link up with the random number and print for example 1=a. Im doing it this way and not just as variables a=1 b=2 c=3 because i am going to expand on it to 100's of letters. Of course this isnt working.... thats why im here

Could you correct the code or better yet explain how nad why?
WHY WAIT FOR GAMES.......MAKE THEM COME TO YOU
>>>>www.sharksoft.scripterz.com<<<<<
THANKS IN ADVANCE
Dr DooMer
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 30th Jan 2003 23:51
I don't know if it's the cause of the problem, but shouldn't the "letter(10)" near the bottom read "letter$(10)"? Likewise, the "print letter" should probably read "print letter$(10)"; although, it's not my code, so I could be wrong.

Anyway, the problem most likely comes from the fact that your function doesn't actually return a value. Here's what I think your function should look like:



Now then, by adding the "rand_no" after the endfunction, the function then returns that variable. This also works for the exitfunction command.

A little word on the rnd command now: as you can see, I've put a +1 onto the end of it. Why? It's simple - the rnd(y) command will generate a 'random' real number (not integer) between 0 inclusive and y exclusive. Because you are returning an integer, after conversion, the rnd(7) command will give you a value between 0 and 6. Get me?

If there's anything else that I've written that you don't understand, don't hesitate to prod me for an answer!

Hope this helps!

"I am a living, thinking entity who was created in the sea of information."
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 31st Jan 2003 00:21
You dim letter$(), but you put the letters into an array called mon$() and never read them out again.

You gosub to _start: but never return, I don't know if that makes any difference. Plus, you are gosubbing to the next line, which isn't needed.

You appear to be trying to store the output of the function into the letter() array, but you aren't returning anything from the function. To return something from a function, put the value you want to return after endfunction. E.g. endfunction rnd(7) would return a random number. (what dr doomer said.)

You didn't dim the letter() array to start with.

You'll want to print the value in mon$() which relates to the number returned from the function ran_num(). To do this you put ran_num() as the index number in the mon$() array, e.g. print mon$(ran_num()). Or store the number separately so you can reference it several times, letter#=ran_num() then print str$(letter#).

You need to end the program above the functions and subroutines, otherwise your program might run over into them if you don't end it properly.

My guess at some corrected code:

Login to post a reply

Server time is: 2024-09-19 02:31:48
Your offset time is: 2024-09-19 02:31:48