Qbasicnews.com

Full Version: Music generator saving things etc.. help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hey quick question.

i have made a music generator and the user tells it what notes to play then it stores the notes played in the variable notes$. I want to give the user option to save it to file. can i just go:
****************************
input " want to save"; yorn$
if yorn$ = "yes" then goto save
if yorn$= "no" then goto bye

save:
cls
input "save as?"; filename$
open filename$ ".txt" for output as #1 ' i know this doesnt work
print #1, notes$ ' but this is what i want to
close ' happen
****************************8
i tried that but it wont save. can someone help.
[syntax="QBASIC"]open filename$ + ".txt" for output as #1
[/syntax]
you need the +


also goto's arn't exactly the best.....
ah thank you. where will this save will it save as a text file in the directory?
it should save as a txt file in you qbasic directory unless you change it
ah there they are thanks, one last question, if say the user saved a song as song.txt and then shut the program off. then, came back later wrote another part to the song and then wanted to save it into the save file(append) how do i get the computer to reconize the same filename and ask the user if he/she wants to orverwrite or add. ?



********should i use CASE instead of GOTO??
if you open the file with APPEND mode then it will add to the end of the file. If you open it for OUTPUT then it will overwrite the file's original contents.
Quote:[...]should i use CASE instead of GOTO??

In this case yes.