TEXTIO:

An Example

-- Notes Page --


This example displays the current state of a finite state machine model execution.

First, the USE clause makes the contents of the TEXTIO package available. The enumerated type STATE is also declared. The procedure display_state requires only one input value, the current state of the FSM.

Several local variables are declared. The buffer k of type LINE will be used for WRITE storage. The FILE flush is of type text and will output to a file named /dev/tty. This logical name is the standard output or screen in UNIX. Therefore, the procedure will write to the screen. The variable state_string holds the text value of the state.

The CASE statement converts the state of the FSM into a text value. The WRITE statement then writes the value of state_string to the buffer k. The WRITE statement further specifies that the string should be left justified and be 7 spaces wide.

Finally, the WRITELINE sends the buffer k to the file flush. The text is then written to the screen.

Note that this procedure would not work very well for writing to a file. Since the file is re-initialized every time the procedure is used, the text would always be written to the beginning of the file. Using TEXTIO to write to a file requires that the file be passed to the procedure as a parameter, or the modeler could use a process that implements the same functionality.

Based on [Navabi93]