Skip to content

Commit 515b555

Browse files
authored
Merge pull request #27 from Joe7M/master
Update of function reference
2 parents 2cecc10 + 2fd78d1 commit 515b555

79 files changed

Lines changed: 1000 additions & 881 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

_build/reference.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,13 @@
510510
"signature": "WRITE #fileN; var1 [, ...]",
511511
"type": "command"
512512
},
513+
{
514+
"help": "Read variables from a binary file.",
515+
"keyword": "READ",
516+
"nodeID": "601",
517+
"signature": "READ #fileN; var1 [, ...]",
518+
"type": "command"
519+
},
513520
{
514521
"help": "Reads and returns a byte from file or device (Binary mode) .",
515522
"keyword": "BGETC",

_build/reference/1422-language-using.markdown

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
> PRINT USING
44
5-
See PRINT, SPRINT
5+
PRINT USING uses the FORMAT function to display numbers and strings.
6+
7+
See PRINT for more information. USG and USING are equivalent.
8+
9+
### Example
10+
11+
```
12+
a = 1000
13+
b = 2000
14+
PRINT USING "#,###.##"; a
15+
PRINT USING "#,###.## "; a; b ' <- Format is applied to all variables
16+
PRINT USING "a = #####.00 b = #####"; a; b ' <- One formated string with placeholders for two variables
17+
18+
' Output: 1,000.
19+
' Output: 1,000. 2,000.
20+
' Output: a = 1000.00 b = 2000
21+
```
622

723

_build/reference/1423-language-usg.markdown

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22

33
> PRINT USG
44
5-
Synonym for USING
5+
PRINT USG uses the FORMAT function to display numbers and strings.
6+
7+
See PRINT for more information. USG and USING are equivalent.
8+
9+
### Example
10+
11+
```
12+
a = 1000
13+
b = 2000
14+
PRINT USG "#,###.##"; a
15+
PRINT USG "#,###.## "; a; b ' <- Format is applied to all variables
16+
PRINT USG "a = #####.00 b = #####"; a; b ' <- One formated string with placeholders for two variables
17+
18+
' Output: 1,000.
19+
' Output: 1,000. 2,000.
20+
' Output: a = 1000.00 b = 2000
21+
```
622

723

824

_build/reference/1428-language-bg.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ Play sound in the background. BG prevents the program from blocking while the so
66

77
See SOUND.
88

9+
### Example
10+
911
```
1012
SOUND 1000, 1000 BG
13+
pause
1114
```
1215

1316

Lines changed: 17 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,33 @@
11
# ARRAY
22

3-
> ARRAY [var | expr]
3+
> A = ARRAY [s | expr]
44
5-
Creates a ARRAY or MAP variable from the given string or expression.
5+
Creates a ARRAY or MAP variable from the given string `s` or expression `expr`. The ARRAY command supports JSON (Javascript object notation) syntax. The MAP provides value-key pair access along with array or dotted notation.
66

7-
The ARRAY command supports JSON (Javascript object notation) syntax. The MAP provides value-key pair access along with array or dotted notation.
8-
The MAP can be converted back into a JSON string using the STR command. You can test whether a variable is a MAP using the ISMAP command.
7+
See STR for converting a MAP variable into a JSON string.
8+
9+
### Example 1: JSON string to MAP
910

1011
```
1112
a = array("{Name: Alice, Age: 20}")
1213
print a
1314
print a.Name + " is " + a.Age + " years old"
15+
16+
' Output:
17+
' {"Age":20,"Name":"Alice"}
18+
' Alice is 20 years old
1419
```
1520

16-
Instead of using ARRAY, the following shorter syntax will give the same result:
21+
### Example 2: JSON with nested MAP
1722

1823
```
19-
a = {Name: Alice, Age: 20}
20-
print a
21-
print a.Name + " is " + a.Age + " years old"
24+
a = Array("{x:1, y:3, down:{x:4, y:7}}")
25+
print a ' Output: {"down":{"y":7,"x":4},"x":1,"y":3}
2226
```
2327

24-
The following example shows a possible JSON representation describing a person:
28+
### Example 3: Array string to array
2529

26-
~~~
27-
{
28-
"firstName": "John",
29-
"lastName": "Smith",
30-
"isAlive": true,
31-
"age": 25,
32-
"address": {
33-
"streetAddress": "21 2nd Street",
34-
"city": "New York",
35-
"state": "NY",
36-
"postalCode": "10021-3100"
37-
},
38-
"phoneNumbers": [
39-
{
40-
"type": "home",
41-
"number": "212 555-1234"
42-
},
43-
{
44-
"type": "office",
45-
"number": "646 555-4567"
46-
},
47-
{
48-
"type": "mobile",
49-
"number": "123 456-7890"
50-
}
51-
],
52-
"children": [],
53-
"spouse": null
54-
}
55-
~~~
56-
57-
Example 1:
58-
59-
~~~
60-
Def uline(text) = Cat(2) + text + Cat(-2) ' Underline text
61-
Cls
62-
? uline("1-Dimension Map Array:")
63-
?
64-
a = Array("{x:100, y:300, title:top-left}")
65-
? "a is: "; a
66-
? "a is map? "; Ismap(a)
67-
?
68-
? "a.x is: "; a.x
69-
? "a.y is: "; a.y
70-
? "a.title is: "; a.title
71-
?
72-
a.x = "N/A"
73-
? "a.x is now: "; a.x
74-
?
75-
?:?:? " Press any key..."
76-
Pause
77-
Cls
78-
? uline("1-Dimension Map Array, with 1-D Nested Map Array:")
79-
?
80-
Dim a(1 To 10, 1 To 2)
81-
a(5, 1) = Array("{x:1, y:3, down:{x:4, y:7}}")
82-
? "a(5, 1) is: "; a(5, 1)
83-
? "a(5, 1) is map? "; Ismap(a(5, 1))
84-
? "a is map? "; Ismap(a)
85-
?
86-
? "a(5, 1).x is: "; a(5, 1).x
87-
? "a(5, 1).y is: "; a(5, 1).y
88-
? "a(5, 1).down.x is: "; a(5, 1).down.x
89-
? "a(5, 1).down.y is: "; a(5, 1).down.y
90-
?
91-
a(5, 1).down.x = "N/A"
92-
? "a(5, 1).down.x is now: "; a(5, 1).down.x
93-
?
94-
?:?:? " Press any key..."
95-
Pause
96-
Cls
97-
? uline("1-Dimension Map Array, with Two 1-D Nested Map Arrays:")
98-
?
99-
a = Array("{x:1, y:3, down:[{x:4, y:7}, {x:6, y:9}]}")
100-
? "a is: "; a
101-
? "a is map? "; Ismap(a)
102-
?
103-
? "a.x is: "; a.x
104-
? "a.y is: "; a.y
105-
? "a.down(0).x is: "; a.down(0).x
106-
? "a.down(0).y is: "; a.down(0).y
107-
? "a.down(1).x is: "; a.down(1).x
108-
? "a.down(1).y is: "; a.down(1).y
109-
?
110-
a.down(1).x = "N/A"
111-
? "a.down(1).x is now: "; a.down(1).x
112-
?
113-
?:?:? " Press any key..."
114-
Pause
115-
Cls
116-
? uline("Create 1-Dimension Map Array without using ARRAY Keyword:")
117-
?
118-
b.x = 40
119-
b.y = 50
120-
b.title = "Top-Left"
121-
? "b.x is: "; b.x
122-
? "b.y is: "; b.y
123-
? "b.title is: "; b.title
124-
?
125-
? "b is: "; b
126-
? "b is map? "; Ismap(b)
127-
?
128-
?:?:? " Press any key..."
129-
Pause
130-
~~~
30+
```
31+
a = Array("[1,2,3]")
32+
print a ' Output: [1,2,3]
33+
```

_build/reference/1439-system-chain.markdown

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
> CHAIN source
44
5-
Compile and run the given source. Source can be a file name, a line of code or an array of code. Use ENV to share variables with the parent process.
5+
Compile and run the given source. `source` can be a file name, a line of code or an array of code. Use ENV to share variables with the parent process.
66

7-
Example 1: Using constants; Note: `\"` is used to create a quote inside the string
7+
### Example 1: Using constants
8+
9+
Note: `\"` is used to create a quote inside the string
810

911
```
1012
Chain "? \"100 + 50 is: \"; 100 + 50"
1113
1214
' Output: 100 + 50 is: 150
1315
```
1416

15-
Example 2: Using variables
17+
### Example 2: Using variables
1618

1719
```
1820
Env "SB1=6"
@@ -22,7 +24,7 @@ Chain "? Env(\"SB1\") ^ Env(\"SB2\")"
2224
' Output: 36
2325
```
2426

25-
Example 3: Using an array
27+
### Example 3: Using an array
2628

2729
```
2830
Env "SB1=3"
@@ -38,7 +40,7 @@ Chain a
3840
' Output: 3 6 9 12 15
3941
```
4042

41-
Example 4: Using a file and returning a value
43+
### Example 4: Using a file and returning a value
4244

4345
```
4446
' First we have to create a bas-file to show how chain works with files
@@ -67,7 +69,7 @@ print "Return value SB1 is: "; Env("SB1");
6769
' Return value SB1 is: 6
6870
```
6971

70-
Example 5:
72+
### Example 5:
7173

7274
```
7375
' Create demo bas file (could be any SmallBASIC file):
@@ -101,7 +103,7 @@ Color 7: ? "I'm The Parent Program..."
101103
Color 15: ? "Child program returned value: "; Env("SB1")
102104
```
103105

104-
Example 6: Creating an eval function
106+
### Example 6: Creating an eval function
105107

106108
```
107109
' Dedicated to MGA.

_build/reference/1446-system-unit.markdown

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ Declares the source module as a unit. Units are a set of procedures, functions,
77
- UNIT supports 'namespace' (Namespaces allow reuse of same names in different contexts. e.g. BitLib.Set(x) and StrLib.Set(x) are both using a function with the same name, "Set", but in different contexts).
88
- While UNIT can be used as a collection of sub-routines for your own program, UNIT is particularly useful for creating a general-purpose library. General purpose libraries can be useful for many programs or projects, the same way the internal routine “PRINT” is useful for many programs, and not only for specific one.
99

10-
Use EXPORT to export procedured, functions, constants or variables. Only exported names can be access in the main program.
10+
Use EXPORT to export procedures, functions, constants or variables. Only exported names can be accessed in the main program.
1111

1212
### Example 1: Simple Unit
1313

14-
First an example of the unit. Please save it with the filename "MyTestUnit.bas"
14+
First, an example of the unit. Please save it with the filename "MyTestUnit.bas"
1515

1616
```
1717
UNIT MyTestUnit
@@ -30,7 +30,7 @@ sub MySub(a,b)
3030
end
3131
```
3232

33-
Second an example on how to use the unit.
33+
Second, an example on how to use the unit.
3434

3535
```
3636
import MyTestUnit as u
@@ -45,13 +45,12 @@ print u.MyVar
4545
```
4646

4747

48-
### Example 2: An unit for using string
48+
### Example 2: An unit for using strings
4949

5050

51-
The UNIT file is strlib.bas:
52-
53-
~~~
51+
The UNIT file. Please save as strlib.bas.
5452

53+
```
5554
' File: strlib.bas
5655
' ------------
5756
' In this demo we are using UNIT to add more useful String commands to
@@ -100,12 +99,11 @@ Func Rset(s, b)
10099
Rset = Space(b - l) + s
101100
Fi
102101
End
103-
104-
~~~
102+
```
105103

106104
Demo file, demo.bas, which is using strlib.bas above:
107105

108-
~~~
106+
```
109107
' Here we declare that this file is using another UNIT file.
110108
' Note: The actual file name must be in lower case for Linux OS.
111109
Import strlib ' (without .bas extension)
@@ -120,6 +118,6 @@ Print Strlib.Lset(Strlib.Rset("This way...", 18), 25)
120118
Locate 6, 30
121119
Print Strlib.Rset("-->> ", 25)
122120
Pause
123-
~~~
121+
```
124122

125123

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# XMAX
22

3-
> XMAX
4-
5-
Holds the screen width in pixels
3+
> n = XMAX
64
5+
Returns the screen width in pixels.
76

7+
See YMAX for screen height.
88

9+
### Example
910

11+
```
12+
print "This window has " + XMAX + "x" + YMAX + " pixels"
13+
' Output: This window has 640x480 pixels
14+
```

_build/reference/1527-graphics-ymax.markdown

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# YMAX
22

3-
> YMAX
3+
> n = YMAX
44
5-
Holds the screen height in pixels.
5+
Returns the screen height in pixels.
6+
7+
See XMAX for screen width.
8+
9+
### Example
10+
11+
```
12+
print "This window has " + XMAX + "x" + YMAX + " pixels"
13+
' Output: This window has 640x480 pixels
14+
```
615

716

817

_build/reference/521-console-at.markdown

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
> AT x, y
44
5-
Moves the console cursor to the specified position. x,y are in pixels.
5+
Moves the text cursor to the specified position `[x, y]`. `x` and `y` are in pixels.
6+
7+
See LOCATE to move the text cursor in units of characters cells.
8+
9+
### Example
610

711
```
812
at 100,100

0 commit comments

Comments
 (0)