Undefined values: Difference between revisions
Content added Content deleted
(Added PicoLisp) |
(→{{header|PicoLisp}}: Added PureBasic) |
||
Line 198: | Line 198: | ||
: MyVar |
: MyVar |
||
-> 7</lang> |
-> 7</lang> |
||
=={{header|PureBasic}}== |
|||
Variables are defined through a formal declaration or simply upon first use. Each variable is initialized to a value. PureBasic does not allow changing of a variable's status at runtime. It can be tested at compile-time and acted upon, however, it cannot be undefined once it is defined. |
|||
<lang PureBasic>If OpenConsole() |
|||
CompilerIf Defined(var, #PB_Variable) |
|||
PrintN("var is defined at first check") |
|||
CompilerElse |
|||
PrintN("var is undefined at first check") |
|||
Define var |
|||
CompilerEndIf |
|||
CompilerIf Defined(var, #PB_Variable) |
|||
PrintN("var is defined at second check") |
|||
CompilerElse |
|||
PrintN("var is undefined at second check") |
|||
Define var |
|||
CompilerEndIf |
|||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") |
|||
Input() |
|||
CloseConsole() |
|||
EndIf</lang> |
|||
Sample output: |
|||
<pre>var is undefined at first check |
|||
var is defined at second check</pre> |
|||
=={{header|Python}}== |
=={{header|Python}}== |