17.1 Introduction. 4tH 4tH Forth compiler
Reklama
Reklama
Chapter 17
Shell manual
17.1
Introduction
The 4tsh shell is a multitasking environment for 4tH. 4tH features cooperative multitasking, which means programs have to relinquish control to the shell using ’PAUSE’, otherwise the program will keep in control. The best place to add ’PAUSE’ is usually somewhere in a loop. 4tH comes with several example multitasking programs for you to try out. 4tsh can be used as a command line replacement for 4th, since you can enable multitasking in the editor.
4tsh is scriptable. Scripts are stored in blockfiles, because block I/O is completed within a single context. If you prefer to use your own editor, you need to convert your script to a blockfile. 4tH comes with a conversion program, called txt2blk.4th. Every twelve lines are converted to a block, leaving four additional lines for future modifications. Your lines should be limited to 63 characters or less.
When a script it loaded, the first block is executed automatically. By convention, the first block is block 0. When the execution of a block has completed, the script stops. You can call other blocks by using ”LOAD”. When the execution of a called block has completed, the execution of the previous block will resume at the point where execution was transferred to the called block. It is recommended to use the first block as an application load screen
1
, e.g.
( 4tsh application load screen)
1 load ( initialization)
2 load ( checking conditions)
3 load ( error handling)
An application load screen is simply a block that consecutively loads all the blocks that make up your script. You can run an arbitrary number of scripts at startup by issuing them on the command line, e.g.
4tsh boot.scr startup.scr tasks.scr
When all scripts have finished execution, control will automatically be transferred to the monitor.
1
See ”Thinking Forth”, chapter 5.
356
Stiahnuť
Reklama