Qbasicnews.com

Full Version: help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ok heres my code
Code:
START$="WHAT IS YOUR NAME"
LOCATE 5,3:PRINT START$
LOCATE 6,3:INPUT NAMEIN$

DO
OPEN "NAMES.DAT" FOR INPUT AS#1
INPUT #1,NAMEF$
IF NAMEF$=NAMEIN$ THEN GOTO 20
IF NAMEF$="END" THEN GOTO 25
LOOP

20
CLOSE
LOCATE 20,5:PRINT  " YOUR NAME IS IN MY LIBRARY CREATING PROFILE"
GOTO 40
25
COLOR 4
LOCATE 10,5:PRINT "YOUR NAME IS NOT IN MY LIBRARY"
40

SLEEP 3000

when the name that is stored in names.dat = namein$ it goes to 20 like it should but when it reaches namef$="end" it kinda freezes and doesnt goto 25 why can somebody please help
Are you sure, that there's an "END" in the file?

Or maybe, the line in your program isn't IF NAMEF$ = "END" THEN...
but ...." END"?

If no IF-expression is true, fb won't quit running the Loop.


For controling, what FB does, you could...

...Change the last line to
LOOP UNTIL EOF(1)
END

=> Quits, when the end of file (EOF) is reached

... add something like
PRINT NAMEF$
in the loop. And then Check, what was read.
Maybe, there's a Space at the end of one line.
For highlighting then, add
WRITE NAMEF$
the printed string will be in "double quotes ", so that you can find spaces easyly.

Hope, this helped you!
You should also be aware that string tests are case senstive also you should should remove any errant spaces in the way.
You may want to use
Code:
IF TRIM$(UCASE$(NAMEF$))="END" then..
thanx dusky_joe the eof(1) worked i was thinking of using that but i couldnt remember how to put it into context ie. chr$ or asc or what not but n e way that was the trick thank you
One thing: NEVER USE GOTO! You will hate yourself if you use GOTO for much of anything beyond a few lines. Uses SUBs and FUNCTIONs instead, they will make your life WAAAAY easier. Not only that, but much more easy to read, too!
man GOTO has gotten kind of a bad rep since most of the time when it's used , it's used in extreamly unstructed code but goto used correctly can speed up your program alot all goto is , is a jump