Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

70
LINES

< > BotCompany Repo | #1034045 // Gazelle 22 "Left Arrow Script" Help

Document

1  
Gazelle 22 "Left Arrow Script"
2  
------------------------------
3  
4  
"Left arrow script" is one of Gazelle 22's two scripting languages. It is the powerful one of the two. It can do anything Java can do except for defining classes or lambdas.
5  
6  
-Usually, you write one command per line
7  
-Each command contains at most one action and at most one assignment
8  
-The language is case-sensitive
9  
-You can add comments like in Java with /* */ or //
10  
-You can write multiple commands in one line by separating them with a semicolon
11  
-Arguments to functions are separated by spaces
12  
-You can use integer and string literals like in Java
13  
-You can use true, false and null
14  
15  
It's called "left arrow script" because the left arrow (variable assignment) is its only actual operator (not counting ; and {}).
16  
17  
18  
Operations
19  
----------
20  
21  
You can call any global function defined in Gazelle. Example:
22  
23  
  infoBox "hello"   // show a popup with the text "hello"
24  
  
25  
You can assign the result of a function call to a variable:
26  
27  
  time <- tsNow     // get current time as a Timestamp object
28  
  infoBox time      // show as popup
29  
  
30  
Note that this script requires 2 lines because only one operation is allowed per command.
31  
  
32  
Variables can be overwritten and don't have to be declared.
33  
34  
35  
Creating objects
36  
----------------
37  
38  
You can create an instance of any Java class and call methods on the object:
39  
40  
  list <- new ArrayList
41  
  list add "hello"
42  
  list add "world"
43  
  infoBox list       // shows [hello, world]
44  
  
45  
(Currently you can also say "list <- ArrayList", but this is ambiguous and may be removed in a future version.)
46  
  
47  
You can pass parameters to the constructor:
48  
49  
  pair <- new Pair "hello" "world"
50  
  infoBox pair      // shows <hello, world>
51  
  
52  
53  
Java operators (+, * etc)
54  
-------------------------
55  
  
56  
Java operators can't be used directly but we have functions that do the same thing (if we don't, we'll add them):
57  
58  
  x <- plus 1 2
59  
  infoBox x
60  
61  
62  
Function definitions
63  
--------------------
64  
65  
You can define functions in your script, with arguments. The function can return a value (which is the result of the last command in the function).
66  
67  
  def doubleMe x { mul x 2 }
68  
69  
  x <- doubleMe 5
70  
  infoBox x        // shows 10

Author comment

Began life as a copy of #1033775

download  show line numbers   

Travelled to 6 computer(s): bhatertpkbcr, ekrmjmnbrukm, elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1034045
Snippet name: Gazelle 22 "Left Arrow Script" Help
Eternal ID of this version: #1034045/5
Text MD5: 792fee82302f3d62463a745bae1aa54e
Author: stefan
Category: javax / gazelle v
Type: Document
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-18 17:40:51
Source code size: 2254 bytes / 70 lines
Pitched / IR pitched: No / No
Views / Downloads: 125 / 696
Version history: 4 change(s)
Referenced in: [show references]