From Rosetta Code

X-script is a minimalistic programming language which is characterised by user friendlyness and simplicity. All data are strings. It can also handle binary data, which are then encoded as hexadecimal strings. It can read from and write to files and serial devices like TCP/IP ports and serial ports. It has a window that has similarities with consoles, where you can start programs, call functions and call states or just write code (like in Python).

Here is an example of an x-script that implements a chemical calculator: - Go to the end and you will find x-script just after Z.

The development of X-script started around 1980 and the language has been improved ever since. Originally, the goal was to enable the creation of rapid prototypes of programs, to test ideas before the real programming started.

The "Hello world" program looks like this: <wcons Hello World!>

In x-script, you can develop an application in two different ways. One is as a function, which is similar to functions in other languages, except that all data are strings.

The other is as a state, which is a list of inputs and outputs. A state is mostly the quickest way to solve a programming problem. It is also easy to read, since it is a list of inputs and the corresponding outputs or actions. The inputs are surrounded by ?"..."? and the corresponding outputs or actions by !"..."!. If you for example want to read a comma-separated account from a bank, the state could look like this:

(* Titles *)

(* Example: 2023-09-04;Accessa Finance Inc 305653152413;-3850.00 *)
?"<format dddd-dd-dd>;<to ;>;<decimal>
!"<wcons On date <p 1> you <if <p 3>'<0,payed to,earned from> <p 2>: <p 3> dollars."!


Function calls have this format: <name arg1,arg2,...>.

The example above calls the library functions <format ...>, <to ...>, <decimal>, <wcons ...>, <p ...>, <eof> and <r>.

<format ...>, <to ...>, <decimal> and <eof> are "pattern functions" which are used to match input strings.

<wcons ...>, <p ...> and <r> are ordinary functions. <wcons ...> prints a string to the X-window.

<p ...> retrieves stringparts identified in the input file. <r> returns from the state,

Pages in category "X-script"

This category contains only the following page.