Category:X-script: Difference between revisions

From Rosetta Code
Content added Content deleted
imported>Friman
(Created page with "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 and write to files and to 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...")
 
imported>Friman
mNo edit summary
Line 1: Line 1:
X-script is a minimalistic programming language which is characterised by user friendlyness and simplicity.
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.
All data are strings. It can also handle binary data, which are then encoded as hexadecimal strings.
It can read and write to files and to serial devices like TCP/IP ports and serial ports.
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 the a chemical calculator:
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 the a chemical calculator:
https://rosettacode.org/wiki/Chemical_calculator - Go to the end and you will find x-script just before Z.
https://rosettacode.org/wiki/Chemical_calculator - Go to the end and you will find x-script just before Z.


Line 8: Line 10:
<wcons Hello World!>
<wcons Hello World!>


I x-script, you can develop an application in two different ways. One is a function, which is similar to functions in other languages, except that all data is strings.
In x-script, you can develop an application in two different ways. One is a function, which is similar to functions in other languages, except that all data is strings.
The other is a state, which is a list of inputs and outputs.
The other is 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 output or actions. The inputs are surrounded by ?"..."? and the coprresponding outputs or actions by !"..."!. If you for example want to read a comma-separated account from a bank, the state could look like this:
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 output 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:
<syntaxhighlight lang="X-script">
<syntaxhighlight lang="X-script">
accountStatement.x
accountStatement.x

Revision as of 19:39, 31 October 2023

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 the a chemical calculator: https://rosettacode.org/wiki/Chemical_calculator - Go to the end and you will find x-script just before Z.

The development of X-script started around 1980 and 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 a function, which is similar to functions in other languages, except that all data is strings. The other is 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 output 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:

accountStatement.x
------------------
(* Titles *)
?"TransactionDate;Reference;Amount
"?
!""!

(* 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 ...> and

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

are ordinary functions. <wcons ...> prints a string to the X-window.

retrieves stringparts identified in the input file.

Pages in category "X-script"

This category contains only the following page.