Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random characters
#1
lol, i could think of a good name for this thread...

anyway, here's my question- i made a program to get characters from the user, and randomly displays them on the screen 2147483648 times- i was origionally trying to do a sort of 'matrix intro' thing, with the green numbers and characters scrolling.

It was working just great until i added a way to exit the while loop ( IF (INKEY$ = "q") THEN GOTO ec ), when i added that, it still runs in the Qbasic editor, but when i make it a standalone .exe file, after about 5 seconds of running, the characters stop printing on the screen as fast as they had been. If i hit any key other than q, it speeds up again for the same interval of time. So my guess is that the inkey check is holding up the program?

Another thing of note is this line:

WHILE (endless& <= 2147483648#)

i didn't put the # there- when i ran the program inside the editor, when i was done running it, the # was there- what's with that?



Here's the code in it's entirety, thanks for the help


CLS
SCREEN 0
COLOR 10, 0


PRINT "______________________________________"
PRINT "|------------------------------------|"
PRINT "|The Cascading Characters of Doom!!!!|"
PRINT "|------------------------------------|"
PRINT
INPUT "How many characters in the set"; char%

DIM choice$(char%)

FOR ctr = 1 TO char%

CLS
PRINT "______________________________________"
PRINT "|------------------------------------|"
PRINT "|The Cascading Characters of Doom!!!!|"
PRINT "|------------------------------------|"
PRINT "Enter character number "; ctr;
INPUT " ", choice$(ctr)

NEXT ctr


RANDOMIZE TIMER

endless& = 0
count& = 0

WHILE (endless& <= 2147483648#)

count& = count& + 1

IF (count& <= 80) THEN
ran% = INT(RND * (char% - 1 + 1)) + 1
PRINT choice$(ran%);
END IF

IF (count& > 80) THEN
PRINT
count& = 0
END IF
endless& = endless& + 1


IF (INKEY$ = "q") THEN GOTO ec

WEND


ec:
CLS
END
Reply
#2
Quote:lol, i could think of a good name for this thread...

I'll put "Matrix intro"

Quote: anyway, here's my question- i made a program to get characters from the user, and randomly displays them on the screen 2147483648 times- i was origionally trying to do a sort of 'matrix intro' thing, with the green numbers and characters scrolling.

It was working just great until i added a way to exit the while loop ( IF (INKEY$ = "q") THEN GOTO ec ), when i added that, it still runs in the Qbasic editor, but when i make it a standalone .exe file, after about 5 seconds of running, the characters stop printing on the screen as fast as they had been. If i hit any key other than q, it speeds up again for the same interval of time. So my guess is that the inkey check is holding up the program?

I try it, but it just run fine.

Quote: Another thing of note is this line:

WHILE (endless& <= 2147483648#)

i didn't put the # there- when i ran the program inside the editor, when i was done running it, the # was there- what's with that?

Note that 2147483648 = 2^32, so it isn't a long. The range of long is -2^32...2^32-1. Qb know that and append the #.
Reply
#3
did you run it in a window, or full screen?? it works correctly in the window, but it full screen, it has issues..
Reply
#4
I run in fullscreen under win98, compiled with qb45.
Reply
#5
Quote: ran% = INT(RND * (char% - 1 + 1)) + 1
PRINT choice$(ran%);
Umm... Firstly -1+1 = 0 so
Code:
ran% = INT(RND * (char% - 1 + 1)) + 1
is the same as
Code:
ran% = INT(RND * char%) + 1
and if you want random characters you could use the code
Code:
PRINT CHR$(INT(RND*222)+33)
It prints all the characters in the range 33-254 Smile
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply
#6
Why didn't you look at the answers to your post here: http://www.network54.com/Hide/Forum/mess...1060115167

Mac
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)