Qbasicnews.com

Full Version: saving and loading
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Im trying to make a password type thing and i have it so that if the name isnt set yet then it asks for the admin password and username and if it is set then it goes straight to the login but when the program starts i want it to load the variables to see if they are set and then if they arent i want it to save when your done setting the stuff does anyone understand what im saying?


thanks.
Courtesy of The Glenn.
Piaza,
Please don't take offense to this.
If you are a native English speaking person, it would help us understand if you wrote your request in properly structured English. The way it's phrased is practically impossible to comprehend.
*****
no offence taken.
sorry i just dont know how to word this exactly, and i have been known to ramble on :bounce:

o.k. ill try to rephrase it.

I am making a login program and there are two variables adminuser$ and adminpass$ i have it so that if adminuser$ isnt set then it asks the user for a username and a pass. but that way it always says that adminuser$ is empty becuase it doesnt load anything so i want it to load when i start the program and save when im done do you get what im saying.


thanks. :rotfl:

p.s. what does Courtesy of The Glenn mean
You want to read up on READ and DATA statements. Here's an example:

Code:
' Put this at the top of your program
READ adminpass$

' Put this anywhere
DATA "thepassword"

However, remember this won't secure the password in a BAS unless you compile it.
does tht save it if you run it again?


thanks
Why don't you add the code in the appropriate place and find out? Wink

Of course it does. The password is hard-coded into the file.
Quote:I am making a login program and there are two variables adminuser$ and adminpass$ i have it so that if adminuser$ isnt set then it asks the user for a username and a pass. but that way it always says that adminuser$ is empty becuase it doesnt load anything so i want it to load when i start the program and save when im done do you get what im saying.
Ok, let's break this down into parts.
First, what do you mean by "if adminuser$ isn't set"? How does this variable get set or unset? You can't have it both ways. It is either set or unset when you run the program. Do you want it always to be set, or does it get set by something external to the program, like maybe a COMMAND$ statement?

Why don't you have the Adminuser also supply his own password? That gets rid of all this problem. Your program can always detect the Adminuser's name and allow him admin functions. This would be the better and more standard way to do it, otherwise all a user has to know is the Adminuser's name, and he's in as an admin guy. What do you think.
*****
like this?

Code:
CLS
'KILL "userpass.dat"
ON ERROR GOTO notset
OPEN "userpass.dat" FOR INPUT AS #1
LINE INPUT #1, user$
LINE INPUT #1, pass$
INPUT "User - ", user1$
INPUT "Pass - ", pass1$
IF user1$ <> user$ OR pass1$ <> pass$ THEN PRINT "Wrong" ELSE PRINT "Correct"
CLOSE
    
END
notset:
CLOSE
OPEN "userpass.dat" FOR APPEND AS #1
PRINT "Password and username not set, please set."
INPUT "User - ", user$
PRINT #1, user$
INPUT "Pass - ", pass$
PRINT #1, pass$
CLOSE
RESUME
Are you still on vacation wt? Tongue
Pages: 1 2