Discussions

SmileBASIC Community

Lego-meistLegos-Meister

01/21/2016 12:40 PM ·Spoilers

Open Closed

DEF Not performing as expected

Whats wrong with DEF? The help says that the variables are "handled as local" so as not to interfere with other variables of the same name. But that is not the case. I can still change and read the variables from outside DEF-END range! Is this a glitch or am I misinterpreting this? I also have to set each variable to 0 at the beginning of each DEF.

Advertisement

Comment

This post has no comments.

  • It looks like it works as expected only when DEF is in a different slot. Is that really the how its supposed to work?

    Yeahs0
    Played
  • Zee

    01/21/2016 9:22 PM ·Spoilers

    It's because you didn't define B again. Example: ACLS VAR B B=90:TEST B=50:TEST DEF TEST VAR B B=B+1 ?B END That should work.

    Yeahs1
    Played
  • L.

    01/22/2016 5:07 AM ·Spoilers

    What Zee said. To avoid this altogether, just don't use same-name variables when working with DEF. Nothing should stop you from using B1 or B2 or TEST2.

    Yeahs0
  • Also, if you want to put parameters into your commands, you can do this: DEF TEST B B=B+1 PRINT "B=";B END Then you can type TEST 10 and it will say B=11!

    Yeahs0
    Played
  • @Zee: Thank you, that's exactly what I wanted! @L: One of the reasons I wanted them to be local variables was so I could create commands that could be used in other peoples programs without knowing what variable names they've already used. I just makes sure that it will work properly under all circumstances. Thanks for everyone's replies!

    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-BXM-ZM98-6VG-JJH7

Report Violation to Miiverse Administrators

You cannot report posts made automatically by a software title.

Edit Post

Select an action: