Empty string: Difference between revisions

No edit summary
Line 998:
 
=={{header|M2000 Interpreter}}==
Easy reply for this task
<lang M2000 Interpreter>
A$=""
Print A$<>"", A$="", Len(A$)=0
<lang>
 
Depends of variable visibility, and what we want to do: To make a new local, to shadow a local or a global on.
 
<lang M2000 Interpreter>
Global a$="ok"
Module Checkit {
Print a$="ok"\\
\\ Part 1: Make global variable, alter it, make a shadow local or global one, use temporary variable
a$<=""
Print a$=""\\
\\ we makeGlobal a local one$="ok"
LetModule a$=""Global What {
\\ or Print a$
a$=""}
\\Module orCheckit {
Local a$ \\ use GlobalPrint for global variablesa$="ok"
Print a$="", a$<>=""
Print a$=""
a$<="ok2"
a$<=""
Print a$="", a$<>""
Global a$="ok again"
Module Inner {
Print a$="ok again"
}
Inner
What \\ now What use new global a$
\\ display list of public variables
List
\\ we can define locals using Def, but raise error if local exist
Try {
Def a$="error"
}
Def b$
Print b$=""
For This {
\\ block for temporary definitions
For i=1 to 10 {
Local a$=str$(i)
}
\\ we get 10 more a$
List
Print a$=" 10"
}
Print a$=""
List
\\ using current stack
}
\\ we call always a local module, or a global, but not this module,
\\ no recursion for standard call for modules.
\\ we have to use Call Checkit to call this module recursive
Checkit
What \\ now what use old global a$
Print a$=<>"" ' true
List
\\
\\ Part 2: Pass an empty string to a variable through stack of values
\\
Module Checkit2 {
\\ read make a local by default
Read a$
Print a$="" ' true
For This {
Push "Hello"
Read New a$
Print a$="Hello"
List
}
Print a$=""
}
Checkit2 ""
Print a$<>"" ' true
Module Checkit3 {
\\ using Set we change to global space, for the end of line
Set Read a$
Print a$="" ' true
list
}
Checkit3 ""
Print a$<>"" ' true
Module Checkit4 {
\\ this make a local if no global exist
\\ so if global exist, alter the global one
Let a$=Letter$
Print a$="" ' true
list
}
Checkit4 ""
Print a$="" ' true
}
Checkit
Print a$="" ' true
 
</lang>
 
Anonymous user