saving

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
dave
Newbie
Posts: 3
Joined: Mon Oct 02, 2006 8:44 pm

saving

Post by dave »

how can i make a program that when a preson enter a name it will look for a file ina cretain location and then read several variables from it and then how can i save that file whenchanges are made to the variables?
i also need it to print a custom message if the file was not found not like "file not found"
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

See OPEN

As for the "file not found" try this link
I have left this dump.
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

Code: Select all

ON ERROR GOTO FileError
CONST FALSE=0
CONST TRUE=NOT FALSE
Input "Type in the name: ",NAM$
OPEN "c:\your\list\of\names.lst" FOR INPUT ACCESS READ AS #1
LineNumber = 1
NameFound = FALSE
WHILE NOT EOF(1)
LINE INPUT #1, TEMP$
IF UCASE$(TEMP$) = UCASE$(NAM$) THEN
PRINT "The name you specified was found on line ";LineNumber
NameFound=TRUE
END IF
LineNumber = LineNumber+1
If NameFound = FALSE Then Print "The name you specified was not found."
END

FileError:
Print "An error occured while opening your file."
END
That quick code will find the names... As for editing them, I will not put code up for that. It seems like this is a homework assignment...


As for the avatar... You could, but it has to be hosted on another site. Pete's site has a file limit size that won't support most animations.
dave
Newbie
Posts: 3
Joined: Mon Oct 02, 2006 8:44 pm

REPLY

Post by dave »

ACTUALLY IT ISNT a home work assignment were still on random slow school
im trying to make a game and when you sign it it looks for the file and if you dont sign in right then it says the custom error message
Post Reply