Discussions

SmileBASIC Community

☆CodeZeяo☆Code-Zero-666

09/15/2016 6:48 PM ·Spoilers

Open Closed

How would I save Names?

:)

Advertisement

Comment

This post has no comments.

  • More specific please. Save strings? save them as data or what?

    Yeahs0
    Played
  • like.. a player name :)

    Yeahs0
    Played
  • You mean actually save, as in turn off the program and it saves it. That I'm not sure.

    Yeahs0
    Played
  • no. like in game, you make a player name then it saves the name and the game continues.

    Yeahs0
    Played
  • 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"

    Yeahs2
    Played
  • 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$

    Yeahs1
    Played
  • 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.

    Yeahs1
    Played
  • Thanks Oscar! and yes I need to save it. :)

    Yeahs0
    Played
  • Could you tell me how to save names?

    Yeahs0
    Played
  • 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.

    Yeahs0
    Played
  • 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.

    Yeahs0
    Played
  • 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

    Yeahs0
    Played
  • 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?

    Yeahs0
    Played
  • 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

    Yeahs1
    Played

Add a Comment

You must sign in to post a comment.

Sign in using a Nintendo Network ID to connect to users around the world by writing posts and comments and by giving Yeahs to other people's posts. You can create a Nintendo Network ID using your Wii U console or your system in the Nintendo 3DS family.

Use of Miiverse Details about Miiverse

Report Violation to Miiverse Administrators

You are about to report a post with content which violates the Miiverse Code of Conduct. This report will be sent to Nintendo's Miiverse administrators and not to the creator of the post.

Violation Type:

Post ID: 3DB-NBL7-EJ9-9E2F-MJK-A2DT

Report Violation to Miiverse Administrators

You cannot report posts made automatically by a software title.

Edit Post

Select an action: