Empty program: Difference between revisions

Line 676:
</lang>
Because we make it in "level 0" (from console) this is a global module. A global module which loaded from console, or was a module loaded from a file at command line, when opening the environment, erased with an End, or a New, or a Start statement (reset of environment by software), or a Break by keyboard (although a dialog ask for proceed the breaking, the reset of environment) , or in some situation by using End Process from Task Manager.
 
If we wish to run it from command line (by clicking the file in explorer, and let m2000.exe open gsb files), we have to consider the first that this file not contain an execute statement, and that if we didn't use an input statement/function which need console, then console stay hide. To be sure that console open we have to use Show statement. To run A we have to include A at the last line (or append a line and write A). So we write in first line Show (press Esc to return to prompt) and save the file as Save Empty, A so we get this:
 
<lang M2000 Interpreter>
MODULE GLOBAL A {Show
}
A
</lang>
We can open it with Edit "empty.gsb" add some statements between A and block of module, to make some globals, say a DIM a(10) which stay there until the end of current interpreter run (interpreter may run multiple times simultaneously). All globals are globals for current interpreter only.
 
We can run empty.gsb now (supposed we save it as Save Empty, A), from explorer or using a command in M2000 console which opens another interpreter (and can feed it with some numbers or and strings, but this is another story):
<pre>
Use empty
</pre>
So now we see environment again, with open console and at prompt (execution done, and stay open because no End statement executed after the A, or inside module as Set End). Set used to send commands to prompt by code.
 
Finally this is the code in a file (say Empty.gsb) to open, display something, waiting for a key (now a Show automatic happen) and then finish. We have to write it, in M2000 editor, and save it using Save Empty, A or in any editor and save it as empty.gsb in your desired folder.
sav
<lang M2000 Interpreter>
MODULE GLOBAL A {
Print "Hello World"
a$=Key$
Set End
}
A
</lang>
 
We can save it scrabbled text (not readable, but environment can revert the process using a unique key) using Save "empty" @, A
 
(m2000 is open source so key is not a mystery, but you can make your own clone, and use own key)
 
=={{header|M4}}==
Anonymous user