Create and record a script in GX-TXT. Fill out metadata and define parameters, including choice-type alternatives.
- For a reusable record choose File → New User script; for an open session record choose New Session script.
- In Metadata compile a stable ID and a Name; check Scope and Language and, if useful, version, description and API required. To change language, change the Language field with
PythonorOctave. - Open Source and write the code. For example, for an autonomous Octave test:
disp("Hello from Script Library"); - If you need parameters, open Parameters and enter a definition per line in the
nome | tipo | obbligatorio | valore predefinito | descrizioneformat. For example,threshold | double | 0 | 1.5 | Example threshold;0indicates that it is not mandatory. The values must respect the stated type. - Choose File → Save or Ctrl+S. The message below confirms the reference and revision saved in the Registry.
Metadata fields
| Field | Use and conditions |
|---|---|
| Scope | User keeps the record in the user library; Session keeps it in the Open Session. The New choice initially sets the value; in a new draft can be changed. On a record already recorded is in read alone. |
| Language | Enter Python or Octave in the new draft; on a record already recorded the language is only read. The initial source follows the chosen language. |
| ID | Stable and unique identifier within, part of the reference. After registration, it is read-only. |
| Name | Legible name shown in the list. Fill it before you save. |
| Version | Version of the record, initially 1.0.0; insert a valid version, for example 1.2.3. It is distinct from the increased revision of saving. |
| Description | Free description of the purpose of the script. |
| Required APIs | Public APIs required by the code; for example NUMERIC_API_v1. Revision of the execution controls the availability of the declared APIs. |
| Reset | The button next to each field restores the default control value, empty in the tried metadata fields; it is disabled if the field is not editable. After Reset, enter the required values before saving. |

Parameter definition format
Each line in Parameters uses nome | tipo | obbligatorio | predefinito | descrizione. Name and type are required. The other fields may be empty. The required field accepts 0 or 1 and defaults to 0. The available types are string, integer, double, number, boolean, choice, color, path, file and command. See the Runner parameter types table for their meanings. Saving checks the definition format and duplicate names. Check the default in the Runner as well. For example, you can save wrong as the default for a double, but Validate review flags it as an invalid number. Correct the value in the Runner, or update the registered definition and save again. Blank lines are ignored.
Define the available values for a choice parameter
The five columns of the Parameters editor do not include the list of alternatives. In this version, a choice parameter created there without alternatives can be saved but the Runner does not offer choices and validation fails. A solution is to declare the parameter in the Python source, leaving the line free with the same name in Parameters:
from gxtxt import gxtxt_parameter_declare
gxtxt_parameter_declare('mode', 'choice', values=['red', 'blue'], default='red')Save the script to read the declaration from the source without running it. In the Runner, the mode menu offers red and blue. Leave that name out of the manual metadata to avoid a conflict.