Reading a line from a file and comparing.

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Posts: 2
Joined: Sun Jun 04, 2017 5:21 pm

Reading a line from a file and comparing.

Post by MarkSkits » Sat Jun 17, 2017 3:44 pm

I'm working on an operating environment in QuickBasic 4.5.

I need help loading saving and loading from a line of code in a file like example.sys for a password system.

Here's what I have the code as so far:

Code: Select all

INPUT "Enter Password you want to set: ",setpass$
INPUT "Confirm: ",confirmpass$
IF confirmpass$ = setpass$ THEN password$ = setpass$ ELSE PRINT "Passwords not identical!":SLEEP 2:GOTO SETPASS
(Code that saves line of code to file)
After reboot:

Code: Select all

(Code that sets the value of password$ from a specific line of code.)
INPUT "Enter Password: ",passinput$
IF passinput$ = password$ THEN GOTO DESKTOP ELSE PRINT "Wrong Password!":SLEEP 3:GOTO PASSWORD
Basically, how would I store a value onto a file and be able to access it later?

User avatar
Posts: 2168
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: Reading a line from a file and comparing.

Post by burger2227 » Sun Jun 18, 2017 9:22 pm

You have to OPEN a file and WRITE or PRINT the word to the file.

To read the file you need to OPEN the filename and INPUT the word(s) from the file.

PS: QB64 does not need DOS and it works better and faster on PC's from XP up.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : http://www.QB64.NET
Get my Q-Basics demonstrator: ...

Post Reply