Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help
#1
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
o live is to die, to die is to expel, to expel is to exist is to live without knowing to be
Reply
#2
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!
ometimes, i think it is not logical to say
x = x + 1


This post is fully recycleable
Reply
#3
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..
his sig left intentionally blank
Reply
#4
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
o live is to die, to die is to expel, to expel is to exist is to live without knowing to be
Reply
#5
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!
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply
#6
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)