WangEmu Script Input

A "script" is simply an ASCII text file. The WangEmu script mechanism allows entering text to the emulated computer state by redirecting the text file to the specified keyboard device, as if the user had prodigious typing ability. This can be useful for loading programs off of the native file system, or for running some test sequence.

The top level "File" menu normally looks like this:


While the script is running, any input from the keyboard is ignored until all of the script input has been consumed. While the script is being processed, the user can't request another script since the "Script..." menu item will be grayed out:


The script can be a straight ASCII file and each character is processed as a separate keystroke. After the end of each line a carriage return is sent. After the entire contents of the file have been sent, the emulator once again looks to the PC keyboard to supply input.

While most of the time characters will be entered verbatim, there are a few different "escape" sequences to allow non-literal processing. The escapes always begin with a backslash. If the sequence you want to enter happens to exactly match an escape sequence but you want to send the characters individually and not the escape, just double the backslash.

The types of escapes are:

Escaped Hex Character

To enter a hex character literally, the sequence must be


If the backslash isn't followed by two hex digits, then the sequence, including the backslash, is interpreted as a series of literal bytes.

Example sequences

(ASCII bell)
\0D or \<CR>
(carriage return)
\0A or \<LF>
(line feed)
\7F or \<DEL>
(delete character)

Escaped Keyword

Wang BASIC stores keywords as a single byte, all of which are between hex 80 and hex FF. Keywords can be entered at the keyboard one character at a time, or with the appropriate keyboard, keywords can be entered directly via keycaps assigned the appropriate keyword token value.

The WangEmu script allows entering these keywords directly too. There probably isn't any great need to do it, but it was easy to implement, and so here it is. Actually, there is one good use. Any line can't be more than about 250 characters long. If a long statement is entered via key-at-a-time ASCII, much less can be fit on one line than if keywords are used whenever possible.

Here is the list of keywords that can be entered via the script mechanism. Some of the keywords are specific to BASIC-2.





Special Function Keys

Probably more a useful feature than keyword entry is special function key entry via a script. Special function keys 0 through 31 can be entered by following this example to enter special function key 13:


Include Files

In a severe case of overkill, script files can include other script files. I can't imagine any great use for this, but I had written the script code for another purpose and adopted it to WangEmu so this feature comes along for free. The best explanation is this example, which will include the contents of the file foo.txt before continuing with the current script:

\<include foo.txt>

Scripts can be nested up to three deep.