Discussions

SmileBASIC Community

ClaytonDarkClay88

08/03/2016 8:23 PM ·Spoilers

Open Closed

Saving

How would I be able to save my variables and load them back up? Sort of like a save feature?

Advertisement

Comment

This post has no comments.

  • You can use the SAVE command in conjunction with an array. First, you'd define the array, which must be numerical and will hold the data you want to save. Afterwards, you can use the save command by specifying the file type as DAT and specifying the array. E.g.: DIM SAVARR[3] SAVARR[0]=HP SAVARR[1]=XP SAVARR[2]=IDK SAVE "DAT:FILENAME",SAVARR

    Yeahs0
    Played
  • Similarly, to load the data back, you'd use another numerical array and the LOAD command. You can keep the array empty as it will be expanded automatically. All data will be in the same order as you saved it. I suggest wrapping the load in a CHKFILE conditional. IF CHKFILE("DAT:FILENAME") THEN DIM LOADARR[0] LOAD "DAT:FILENAME",LOADARR,FALSE HP=LOADARR[0] XP=LOADARR[1] IDK=LOADARR[2] ENDIF

    Yeahs0
    Played
  • Oooh. I get it. So when I save, the array (or variables) will be in a different file? And when I load, it loads it?

    Yeahs0
    Played
  • Yep! It's simple, and allows for different files to contain different data!

    Yeahs1
    Played
  • Ok, I'm understanding arrays a bit more now. Thanks! :D You're a great help!

    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-9E2B-886-Y4PP

Report Violation to Miiverse Administrators

You cannot report posts made automatically by a software title.

Edit Post

Select an action: