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
MarkSkits
Newbie
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

...
SETPASS:
CLS
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

PASSWORD:
CLS
(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
burger2227
Veteran
Posts: 2317
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.

http://www.qb64.net/wiki/index.php/OPEN

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 : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

byronkit
Newbie
Posts: 6
Joined: Thu May 02, 2019 7:22 am
Location: Norway
Contact:

Reading a line from a file and comparing

Post by byronkit » Sat May 18, 2019 3:48 pm

I am using the "arduino-led-onoff-ble" template to write to HM10 and activate a LED on/off.
Now, Id like to read a status which is pushed by the arduino each time I issue "on"
Is there any example that can help?

Post Reply