Calc-U 1600Pocket computer emulator Play in browser

Calc-U-1600 Help 6 Presets

Chapter 6 · Presets

Presets

A preset is a text file that sets up a machine: the model, what is plugged in, then programs and scripted input. Load one to get a machine into a known state in one go: a game ready to play, a program typed in and started, a test that checks what the display shows. The examples the product bundles are presets, and so are the startup presets.

The product's own sections, keys and examples are in its part of this chapter: Presets of this product. Every key and step is listed in the reference.

Loading a preset

A load always builds a new machine: the machine that ran before is gone, with its memory. The new machine is built from a cold boot with the model and exactly what the preset names; a place the preset does not name stays empty. Then the preset's sections are carried out from top to bottom.

While a preset runs:

When the preset is done, the machine runs on at regular speed and is yours.

When a preset is refused

The whole file is read and checked before anything is built. If anything is wrong (an unknown key, a value a key does not take, a key a model does not have, a peripheral that does not fit its place, a file it names that cannot be read), nothing is built and the running machine stays as it is. A notice gives the first error with its line number.

A file without format-version, or with another version than 2, is refused; a file from a newer release is refused as such. A preset written by an earlier release is converted by hand, as the last section of the product's media files page describes (Reference of this product).

If a step fails while the preset runs, or does not finish within the preset's timeout:, the preset stops there: the steps after it are not carried out, the machine stays as it is, and a notice gives the line and the reason.

To follow a preset step by step, set the run log's level to Info (the chapter on the debugger says where): the log then shows the machine the preset built, each step as it is done and the preset's end. At Off the log keeps only what a step writes on purpose, such as elapsed-time: report, and why a preset stopped.

A first preset

format-version: 2
model: <model>
preset-name: My setup
description: One line for menus and tooltips
keys:
  - key: <key> <key>
  - wait: 2s
  - expect: <text>

The file extension does not choose the model; model: does.

Steps

A step is one line - verb: value in a keys: section; a step without a value is written - verb:. The most used ones:

Step What it does
key: <key> … presses and releases each key in turn; key IDs are separated by spaces
wait: 2s lets that much time pass (2s, 1.5s, 500ms; the unit is required)
regular-speed: / full-speed: the steps after it run at regular or at full speed
expect: <text> fails the preset unless the display shows the text
not-expect: <text> fails the preset if the display shows the text
screenshot: <file name> saves a picture of the display
trace: <file name> / trace: off starts or ends a trace (Debugger)
elapsed-time: start / report measures emulated time and writes it to the log as m:ss.mmm
cut-paper: copies the paper of the printer that is plugged in to the clipboard, then cuts it, as Cut on the paper panel; in the browser it only cuts
copy-paper: copies the paper of the printer that is plugged in to the clipboard, as Copy on the paper panel; in the browser it does nothing

Steps for media (inserting a medium, Name & Save) and the product's own steps are listed in the reference and the product's part.

Waiting

A preset waits on its own: each item starts only when the one before has finished. A key press has finished when the machine is idle again: a key that starts a program finishes when the program stops or waits for you (an INPUT, a key). You rarely need wait:.

You want Write
a program to run to its end before the next step nothing: the next step waits
to watch part of the preset happen regular-speed: before it, full-speed: after it
a pause so a display can be seen, or a running program to go on for a while wait: 2s
to press a key while a program still runs (to stop it, say) skip-wait: after the step that started it
the last program to run to its end before the preset ends let-it-finish: as the last step

Checking the display

expect: and not-expect: turn a preset into a test. They check after the item before has finished: after the key that runs a program, when the program has ended. If the check fails, the preset stops and the notice holds the text and what the display showed. How the display is compared (a line of text, a number) is the product's: see its part.

Startup presets

A startup preset is the preset a model is built from when the product starts with that model, or when you switch to that model. Set one per model in Settings ▸ Startup presets: "None", the startup presets the product bundles for that model, or any preset file of your own with "Choose…". It is kept in the settings file under [preset] (Settings).

"Choose…" opens the file dialog of the platform: on the desktop and on the iPhone and iPad, a preset file; in the browser, the preset together with the files it names, as in Load Preset…. The preset is checked before it is set, as a start would read it: one that names a file that is not there, or is for another model, is not set, and a notice says why.

In the browser, a startup preset chosen this way is kept in the browser's storage, and so is every file opened in the browser (with Load Preset…, Import Media…, a drop). A preset whose files were opened before can therefore be chosen alone. A preset loaded with Load Preset… is not kept itself; only the files that came with it are.

Examples

The product's examples are bundled with it and listed under File ▸ Examples ▸, in groups. They are presets like any other: open one to see how it is written, copy it, and change it. The product's part lists them.

Help built from Calc-U-1600-help.zip 0.9.1, the help of the Calc-U-1600 0.9.1 release.