Zbex: Introduction

From CCARH Wiki
Jump to: navigation, search

Each of the 30 Dmuse windows can be made to behave like a computer terminal. The command to make this happen is Shft+KeyPad *. This command actually toggles the connect mode flag; i.e., press it again and the window stops acting like a terminal. Initially, you may have to activate the Zbex interpreter by pressing F9 and then a to activate advanced features.

The main thing that is different with connect mode turned on is the behvaior of the Enter key. With connect mode on, the Enter key will send the contents of the line the cursor is on to the computer as an input. How the computer responds to that input depends on the current state of the window. When the window is waiting for you to give it the name of a program to run, it will present the prompt, "Ready for program." If you simply press the Enter key, that is, enter a blank line, the window will respond with the lines:

    Not found 
    Ready for program 

This happens because Dmuse does not recognize a blank line as the name of a program. If you enter a line that Dmuse does recognize as a program, it will transfer control to that program; i.e., that program will begin to run.

There are several programs that Dmuse will recognize, but we should start with the main one, namely, the Zbex compiler and interpreter. This program will compile an Zbex program that you specify and then run that program. The Zbex compiler/interpreter is called by entering "zz". If you type "zz then Enter", you will see the following lines appear in your window.

    zz 
    Current Library is <current directory> 
    Program file?  

The prompt for a program file is the way the Zbex compiler asks you for the Zbex program you want to run. You have three options: (1) you may enter the name of a file, or (2) you may enter a line with the form "*<window number>", e.g., *6, or (3) you may enter a blank line. If you enter the name of a file, the Zbex compiler assumes that the file contains an Zbex program, and it will attempt to compile that program into an executable module that can be handed off to the interpreter. If you enter "*<window number>", the Zbex compiler assumes that the specified window contains the Zbex program you want to run. If you enter a blank line, the Zbex compiler expects you to enter the program, line by line in the current window.

Let's follow the third option for a moment. Suppose you enter a blank line at the "Program file?" prompt. Then you will see the following lines in your window:

    zz 
    Current Library is <current directory>
    Program file?  
                                              (blank line entered here) 
    Input program from terminal.  
    

You are now expected to enter a program. Let's suppose you enter the following two-line program:

     putc Hello World 
     run 

You should then see the following lines in your window:

    zz 
    Current Library is <current directory> 
    Program file?  
     
    Input program from terminal.  
    putc Hello World 
    run 
    ** S=2, P=8, L=231, M=410 ** 
    Hello World 
    Ready for program 

The line with the numbers tells you that the program successfully compiled; the next line "Hello World" is the output from the program; and the "Ready for program" prompt tells you that the window is again waiting for you to give it the name of a program to run.



Previous chapter
None
Zbex
Manual
Next Chapter
Zbex: Programs in files and in other Dmuse windows