Discussions

SmileBASIC Community

KalvinNoctise

06/27/2016 3:39 PM ·Spoilers

Open Closed

arrays

how do arrays work?

Advertisement

Comment

This post has no comments.

  • -create an array: DIM arrayname[size] -example: DIM EXAMPLE[7] -access an array element: arrayname[index] -example: EXAMPLE[3]=12 PRINT EXAMPLE[3] (arrays start counting at 0, and the maximum value is 1 less than the size)

    Yeahs0
    Played
  • 12Me21 told how to make arrays, so I'll explain them. Arrays are special variables that can hold more than one value. There are 3 types of arrays that can each hold things in up to four dimensions. (you'll mostly use the first 2) The integer array holds numbers but can't store decimals, the real array holds numbers that can have decimals, and the string array that can hold text.

    Yeahs0
    Played
  • can you use string with arrays?

    Yeahs0
    Played
  • yes, just add a $ to the end of the array name

    Yeahs0
    Played
  • We can treat a string variable itself as an array as follows. S$="ONE" ... S$[0]=="O", S$[1]=="N", S$[2]=="E" Multiple dimension arrays are also available as follows. DIM S$[3]:S$[0]="ZERO":S$[1]="ONE":S$[2]="TWO" ... S$[1][0]=="O", S$[1][1]=="N", S$[2][1]=="W" ... Could you confirm them yourself?

    Yeahs0
  • how do you use 2d arrays?

    Yeahs0
    Played
  • DIM ARRAY[size1,size2] ARRAY[index1,index2]=value

    Yeahs0
    Played
  • so these work like rows and columns?

    Yeahs1
    Played
  • Pretty much. They're useful for storing maps.

    Yeahs0
    Played
  • ok then, thanks guys!

    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-BXN-3HKR-LPG-8YJ9

Report Violation to Miiverse Administrators

You cannot report posts made automatically by a software title.

Edit Post

Select an action: