Skip to content

Commit 448d326

Browse files
committed
DOC: markdown cleanup
1 parent c9f3dba commit 448d326

13 files changed

+57
-46
lines changed

_build/reference/538-console-cat.markdown

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
Returns a console code. 0 = reset, 1 = bold, -1 bold-off, 2 = underline, -2 = underline-off, 3 = reverse, -3 = reverse-off.
66

77

8-
> ? cat(1);"Bold";cat(0)
9-
10-
118
~~~
129
1310
' Note: tested and works with SB 0.12.2 on Linux 64-bit.

_build/reference/539-console-inkey.markdown

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Returns the last key-code in keyboard buffer, or an empty string if there are no keys. Special key-codes like the function-keys are returned as 2-byte string.
66

7-
7+
```
88
k=INKEY
99
IF LEN(k)
1010
IF LEN(k)=2
@@ -15,7 +15,7 @@ IF LEN(k)
1515
ELSE
1616
? "keyboard buffer is empty"
1717
FI
18-
18+
```
1919

2020
~~~
2121
@@ -205,10 +205,16 @@ Def CTRL_SHIFT(c) = CTRL_SHIFT_CHR + Lcase(c) ' Ctrl+Shift+a, etc
205205
~~~
206206

207207
When the first character in the two character code is 27, the second character is a code for the given special key. You would need to inspect the SB source to work out the equivalent SmallBASIC key constants, but I'll have a look at generating a constants.bas file that you can include in your programs.
208+
208209
As reported by Shian (thanks Shian!), there are a few problems with INKEY. I'll fix these in the next update. There is supposed to be a different first character code for SHIFT/ALT etc states.
210+
209211
Also, INKEY needs to read from the system event queue to get the next keystroke. It currently does a pause for key, but I think it should actually block in the call to read the queue, that way when you type a key there would be no delay. Either way this doesn't work well for shooter type games, but there is a better way. Have a look at:
212+
210213
https://github.com/smallbasic/SmallBASIC/blob/master/samples/distro-exam...
214+
211215
This uses the DEFINEKEY command to register keystroke handlers for game keys. When you hit the game key, the registered FUNC will get called more or less immediately, somewhere inside the game main looI think this should work well in the space shooter (which is awesome by the way).
216+
212217
Code for quick lookup of a key code:
218+
213219
http://smallbasic.sourceforge.net/?q=node/1583
214220

_build/reference/546-data-read.markdown

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
55
Assigns values in DATA items to specified variables.
66

7+
var - Any variable.
78

8-
* var - Any variable.
99
Unless a RESTORE command is executed, SmallBASIC moves to the next DATA item with each READ assignment. If SmallBASIC runs out of DATA items to READ, an run-time error occurs.
10-
> FOR c=1 TO 6
11-
READ x
12-
PRINT x
10+
11+
```
12+
FOR c=1 TO 6
13+
READ x
14+
PRINT x
1315
NEXT
1416
...
1517
DATA "a,b,c", 2
1618
DATA 3, 4
1719
DATA "fifth", 6
18-
20+
```
1921

_build/reference/548-data-search.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
Scans an array for the key. If key is not found the SEARCH command returns (in ridx) the value. (LBOUND(A)-1). In default-base arrays that means -1. The cmpfunc (if its specified) it takes 2 vars to compare. It must return 0 if x = y; non-zero if x <> y.
66

7-
8-
> FUNC cmp(x,y)
7+
```
8+
FUNC cmp(x,y)
99
cmp=!(x=y)
1010
END
1111
...
@@ -16,7 +16,7 @@ NEXT
1616
SEARCH A, 4, r USE cmp(x,y)
1717
PRINT r:REM prints 1
1818
PRINT A(r): REM prints 4
19-
19+
```
2020

2121
~~~
2222

_build/reference/549-data-sort.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
Sorts an array. The cmpfunc if specified, takes 2 vars to compare and must return: -1 if x < y, +1 if x > y, 0 if x = y.
66

7-
8-
> FUNC qscmp(x,y)
7+
```
8+
FUNC qscmp(x,y)
99
IF x=y
1010
qscmp=0
1111
ELIF x>y
@@ -20,5 +20,5 @@ FOR i=0 TO 5
2020
A(i)=RND
2121
NEXT
2222
SORT A USE qscmp(x,y)
23-
23+
```
2424

_build/reference/559-data-isnumber.markdown

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
55
Returns true if x is a number (or it can be converted to a number).
66

7-
8-
> ? ISNUMBER(12) :REM true
7+
```
8+
? ISNUMBER(12) :REM true
99
? ISNUMBER("12") :REM true
1010
? ISNUMBER("12E+2") :REM true
1111
? ISNUMBER("abc") :REM false
1212
? ISNUMBER("1+2") :REM false
1313
? ISNUMBER("int(2.4)") :REM false
14+
```
1415

1516

_build/reference/560-data-isstring.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
55
Returns true if x is a string (and cannot be converted to a number).
66

7-
8-
> ? ISSTRING(12) :REM false
7+
```
8+
? ISSTRING(12) :REM false
99
? ISSTRING("12") :REM false
1010
? ISSTRING("12E+2") :REM false
1111
? ISSTRING("abc") :REM true
1212
? ISSTRING("1+2") :REM true
13-
13+
```
1414

_build/reference/569-data-data.markdown

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
55
Stores one or more constants, of any type, for subsequent access via READ command.
66

7-
87
DATA commands are non executable statements that supply a stream of data constants for use by READ commands. All the items supplied by all the DATA commands in a program make up one continuous "string" of information that is accessed in order by your program's READ commands.
9-
> RESTORE MyDataBlock
8+
9+
```
10+
RESTORE MyDataBlock
1011
FOR I=1 TO 3
1112
READ v
1213
PRINT v
@@ -15,5 +16,5 @@ END
1516
...
1617
LABEL MyDataBlock
1718
DATA 1,2,3
18-
19+
```
1920

_build/reference/570-data-dim.markdown

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
55
Reserves storage space for an array.
66

7+
The array will have (upper-lower)+1 elements. If `lower` is not specified, and `OPTION BASE` hasn't used, elements start at 0.
78

8-
The array will have (upper-lower)+1 elements. If @lower@ is not specified, and @OPTION BASE@ hasn't used, elements start at 0.
9+
```
910
REM One dimension array of 7 elements, starting from 0
1011
DIM A(6)
1112
...
@@ -19,7 +20,7 @@ REM Allocating zero-length arrays:
1920
DIM z()
2021
...
2122
IF LEN(Z)=0 THE APPEND Z, "The first element"
22-
23+
```
2324

2425
~~~
2526

_build/reference/571-data-erase.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
55
Deallocates the memory used by the specified arrays or variables. After that these variables turned to simple integers with zero value.
66

7-
8-
> DIM x(100)
7+
```
8+
DIM x(100)
99
...
1010
PRINT FRE(0)
1111
ERASE x
1212
PRINT FRE(0)
1313
PRINT x(1):REM ERROR
14-
14+
```
1515

0 commit comments

Comments
 (0)