トピック
☆CodeZeяo☆ Code-Zero-666

How would I save Names?

:)
2そうだね
プレイ済み
返信[1]
親投稿
Aaron Krondelo
More specific please. Save strings? save them as data or what?
0そうだね
プレイ済み
返信[2]
親投稿
☆CodeZeяo☆ Code-Zero-666
like.. a player name :)
0そうだね
プレイ済み
返信[3]
親投稿
Aaron Krondelo
You mean actually save, as in turn off the program and it saves it. That I'm not sure.
0そうだね
プレイ済み
返信[4]
親投稿
☆CodeZeяo☆ Code-Zero-666
no. like in game, you make a player name then it saves the name and the game continues.
0そうだね
プレイ済み
返信[5]
親投稿
Oscar PwnageBlock
Well, if you want to 'save' a string within a program, all you have to do is declare and assign a string variable. Then, as long as you don't modify the variable, you can reference it throughout your program's runtime. You can declare a string by appending a dollar sign to a variable's identifier, like this: NAME$ = "TEXT GOES HERE"
2そうだね
プレイ済み
返信[6]
親投稿
Oscar PwnageBlock
If you want to let the player input the string's content, you can use the INPUT command. It follows this syntax... INPUT <Guiding text>,<Variable to assign to> So you could do something like... INPUT "Enter your name: ",NAME$
1そうだね
プレイ済み
返信[7]
親投稿
Oscar PwnageBlock
Now, if you want to save a string for future use (to load it back up again after the program stops), you need to use the SAVE command. It requires more explanation, so please reply if you want to know about this one.
1そうだね
プレイ済み
返信[8]
親投稿
☆CodeZeяo☆ Code-Zero-666
Thanks Oscar! and yes I need to save it. :)
0そうだね
プレイ済み
返信[9]
親投稿
☆CodeZeяo☆ Code-Zero-666
Could you tell me how to save names?
0そうだね
プレイ済み
返信[10]
親投稿
Oscar PwnageBlock
Sorry for the late reply. If you want to save a string, you simply need a string and the SAVE command. You can save a text file with this syntax... SAVE "TXT:<Filename>",<String$> For example... NAME$="EXAMPLE" SAVE "TXT:SAVEDATA",NAME$ Do note that a dialog will appear to the user in order to save, meaning that the user may cancel saving.
0そうだね
プレイ済み
返信[11]
親投稿
Oscar PwnageBlock
Loading it is very simple as well. Similarly, you'd need a string variable and the LOAD command. You can use LOAD with either of these syntax... <String$>=LOAD("TXT:<Filename>",FALSE) LOAD "TXT:<Filename>",FALSE OUT <String$> It is suggested that you call CHKFILE before you try to load something. This is so that you prevent loading a file that doesn't exist, since it would throw an error.
0そうだね
プレイ済み
返信[12]
親投稿
Oscar PwnageBlock
You use CHKFILE to check if the file exists. It follows this syntax... <Boolean>=CHKFILE("<Filetype:><Filename>") The function will return either true or false, so it's suggested you place it in a conditional, like this... IF CHKFILE("TXT:SAVEDATA") THEN NAME$=LOAD("TXT:SAVEDATA",FALSE) ENDIF
0そうだね
プレイ済み
返信[13]
親投稿
☆CodeZeяo☆ Code-Zero-666
Thank you so much Oscar! you're awesome. I don't know if you know about this, but how would I make text letter by letter pop up in a line?
0そうだね
プレイ済み
返信[14]
親投稿
Oscar PwnageBlock
It's an easy custom function. You just need to remember that a string is really just an array of individual characters, so you can iterate over it. I'll give you an example with text (TX$), a wait amount (WT), and even a sound (BP) as a parameter. DEF TYPE TX$,WT,BP FOR I=0 TO LEN(TX$)-1 ?TX$[I]; BEEP BP WAIT WT NEXT END You can then call it like this... TYPE "SMILEBASIC",10,9
1そうだね
プレイ済み