トピック
Lego-meist Legos-Meister

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.
1そうだね
プレイ済み
返信[1]
親投稿
Lego-meist Legos-Meister
It looks like it works as expected only when DEF is in a different slot. Is that really the how its supposed to work?
0そうだね
プレイ済み
返信[2]
親投稿
Zee Storybookten9
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.
1そうだね
プレイ済み
返信[3]
親投稿
L. Lohadaa
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.
0そうだね
未プレイ
返信[4]
親投稿
V360 TheV360
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!
0そうだね
プレイ済み
返信[5]
親投稿
Lego-meist Legos-Meister
@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!
0そうだね
プレイ済み