Discussions

SmileBASIC Community

bherdmbherdm

11/27/2016 2:13 PM ·Spoilers

Open Closed

Save an array of strings?

I see in the help that it's possible to save a numerical array, is it possible to save an array of strings? Thanks!

Advertisement

Comment

This post has no comments.

  • Yes. Just like variables you just have to add $ after their name. Eg: DIM TEST$[5] TEST$[0]="Hi" TEST$[1]="Sup!" etc.

    Yeahs0
    Played
  • You can't save a string array to a file unfortunately. You could put every entry together into one string with some kind of separator after each one and save it as a TXT though. You would have to load the TXT and split all the parts up to convert them into a string array later.

    Yeahs0
    Played
  • Oh sorry lol. As stated above this is the only way to do this. I've made 2 simple functions that let you save/load arrays into an already defined array. Eg: DIM T$[9] T$[0]="Test" T$[1]="HI" SAVESTR "FILENAME",T$ LOADSTR "FILENAME",DESTINATIONARRAY$

    Yeahs0
    Played
  • If you will be storing sensitive data to a file (high scores, progress) I highly, highly recommend using the DAT file type instead of TXT DAT stores an array of numbers, and cannot be viewed or changed in the text editor DIM D[1] D[0]=MYNUMBER SAVE "DAT:SAVEDATA",D You want to save not very often so the user is not bombarded by dialogs saying "Would you like to save blah blah blah?"

    Yeahs0
    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-9E2M-YEN-6VPP

Report Violation to Miiverse Administrators

You cannot report posts made automatically by a software title.

Edit Post

Select an action: