Skip to content

Commit 4219b15

Browse files
authored
Merge pull request #24 from Joe7M/master
Update of function reference starting with T
2 parents dddb9e9 + fac6aea commit 4219b15

30 files changed

Lines changed: 443 additions & 255 deletions

_build/pages/articles.markdown

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
- [Android](/pages/android.html)
1818
- [SDL](/pages/sdl.html)
1919
- [FLTK](/pages/fltk.html)
20-
- [Visual Studio Code, Atom and Geany](/pages/language_support.html)
20+
- [Setup external editors](/pages/language_support.html)
2121
- [Distribute your program](/pages/distributiontool.html)
2222

23-
2423
## Plugins
2524

2625
- [Raylib: 2D and 3D game development](/pages/plugins_raylib.html)

_build/pages/community.markdown

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## Forum
44

55
- [SyntaxBomb / SmallBASIC](https://www.syntaxbomb.com/smallbasic)
6-
- [Basic4All](http://basic4all.epizy.com/index.php)
76

87
## Issues
98
- [GitHub](https://github.com/smallbasic/SmallBASIC/issues){target=new}

_build/pages/links.markdown

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
## External articles
99

1010
- [Wikipedia entry](http://en.wikipedia.org/wiki/SmallBASIC){target=_blank}
11-
- [PalmPilot Software Development - Alternatives to C](http://goanna.cs.rmit.edu.au/~winikoff/palm/dev.html){target=_blank}
1211
- [David A. Wheeler's Suggestions for PalmOS PDA Users](http://www.dwheeler.com/palm-suggest.html){target=_blank}
13-
- [PalmOS-hosted programming languages](http://www.ibm.com/developerworks/linux/library/l-palmos2.html?dwzone=linux#h7879){target=_blank}
14-
- [PC Advisor](http://www.pcadvisor.co.uk/how-to/software/3307979/how-program-software/){target=_blank}
1512
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/smallbasic/){target=_blank}
1613

1714
## External documentation
@@ -20,9 +17,7 @@
2017

2118
## What about the other "SmallBASIC?"
2219

23-
We noticed there's another version of [SmallBASIC](http://smallbasic.com/faq.aspx){target=_blank}. Other than the naming coincidence, our version of SmallBASIC doesn't have anything to do with this other version.
24-
25-
- [Small Basic to SmallBASIC translator - experimental](http://sb-translator.appspot.com/){target=_blank}
20+
We noticed there's another version of [SmallBASIC](https://smallbasic-publicwebsite.azurewebsites.net){target=_blank}. Other than the naming coincidence, our version of SmallBASIC doesn't have anything to do with this other version.
2621

2722
## ECMA-55
2823

_build/reference/1420-language-to.markdown

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

3-
> FOR t = 1 TO 10
3+
> FOR t = var1 TO var2
44
5-
Specifies the loop counter end in a FOR loop
5+
Specifies the loop counter end in a FOR loop. For more information see FOR.
66

77
### Example
88

_build/reference/1425-language-try.markdown

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

33
> TRY
44
5+
The TRY statement introduces a TRY/CATCH block. A try/catch block consist of the following structure:
6+
57
__TRY__
68

7-
The TRY statement introduces a TRY/CATCH block.
9+
The TRY statement starts a block of commands which might create a run-time error.
810

911
__CATCH [var | expr]__
1012

11-
The CATCH statement is used to CATCH an run-time error. This is typically used with errors raised when calling a file system command that cannot be completed, for example attempting to open a non-existent file.
12-
13-
The CATCH statement has two modes. You can supply a variable argument to store the error string. Alternatively you can supply an expression. When the raised error matches the (String) expression, the error will be caught.
13+
The CATCH statement is used to catch a run-time error of one of the commands in the try-block. This is typically used with errors raised when calling a file system command that cannot be completed, for example attempting to open a non-existent file.
1414

15-
When using the expression mode, you can supply a succession of CATCH statements to handle various error messages separately.
15+
The CATCH statement has two modes. You can supply a variable argument to store the error string. Alternatively you can supply an expression. When the raised error matches the (String) expression, the error will be caught. When using the expression mode, you can supply a succession of CATCH statements to handle various error messages separately.
1616

1717
__END TRY__
1818

@@ -26,18 +26,45 @@ try
2626
' DON'T use existing file for demo.
2727
open "try demo.tmp" for input as #1
2828
catch err
29-
print err; " "
29+
print err
3030
' Some error handling could be implemented here
3131
' i.e: if(err = "...") then ...
3232
end try
3333
3434
print "This point is reach, even if opening the file was not possible"
3535
```
3636

37-
### Example 2: Advanced error handling for opening files
37+
### Example 2: Open COM-Port
38+
39+
```
40+
try
41+
open "com2000:" AS #1
42+
catch err
43+
print "open failed: ";err
44+
end try
45+
```
46+
### Example 3: Using error expressions
47+
48+
```
49+
try
50+
' DON'T use existing file for demo.
51+
open "demo.tmp" for input as #1 ' Replace "demo.tmp" by "?.tmp"
52+
catch "FS(2): NO SUCH FILE OR DIRECTORY"
53+
print "File not found"
54+
' Some error handling could be implemented here
55+
goto aftertrycatch
56+
catch "FS(22): INVALID ARGUMENT"
57+
print "Filename not allowed"
58+
' Some error handling could be implemented here
59+
end try
60+
61+
label aftertrycatch
62+
print "end of program"
63+
```
3864

39-
~~~
65+
### Example 4: Advanced error handling for opening files
4066

67+
```
4168
' See also: Home -- Articles -- TRY / CATCH
4269
Const FILE_NAME = "try demo.tmp" ' -- DON'T use existing file for demo.
4370
' OPEN file or device safely:
@@ -99,14 +126,6 @@ If fn Then
99126
? lines;
100127
Close #fn
101128
Fi
102-
~~~
129+
```
103130

104-
### Example 3: Open COM-Port
105131

106-
```
107-
try
108-
open "com2000:" AS #1
109-
catch err
110-
? "in catch: open failed";err
111-
end try
112-
```

_build/reference/1426-language-catch.markdown

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

33
> CATCH [var | expr]
44
5-
The CATCH statement is used to CATCH a run-time error. This is typically used with errors raised when calling a file system command that cannot be completed, for example attempting to open a non-existent file.
5+
The CATCH statement is used to catch a run-time error. This is typically used with errors raised when calling a file system command that cannot be completed, for example attempting to open a non-existent file.
66

7-
The CATCH statement has two modes. You can supply a variable argument to store the error string. Alternatively you can supply an expression. When the raised error matches the (String) expression, the error will be caught. When using the expression mode, you can supply a succession of CATCH statements to handle various error messages separately.
7+
The CATCH statement has two modes. You can supply a variable argument to store the error string. Alternatively you can supply an expression. When the raised error matches the (String) expression, the error will be caught. When using the expression mode, you can supply a succession of CATCH statements to handle various error messages separately.
88

9-
For more information and examples please see TRY.
9+
For more information see TRY.
1010

11+
### Example
12+
13+
```
14+
try
15+
' DON'T use existing file for demo.
16+
open "try demo.tmp" for input as #1
17+
catch err
18+
print err
19+
' Some error handling could be implemented here
20+
' i.e: if(err = "...") then ...
21+
end try
22+
23+
print "This point is reach, even if opening the file was not possible"
24+
```

_build/reference/1427-language-endtry.markdown

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

33
> END TRY
44
5-
The END TRY statement marks the end of a TRY/CATCH block. For more information and examples please see TRY.
5+
The END TRY statement marks the end of a TRY/CATCH block. For more information see TRY.
66

7+
### Example
78

9+
```
10+
try
11+
' DON'T use existing file for demo.
12+
open "try demo.tmp" for input as #1
13+
catch err
14+
print err
15+
' Some error handling could be implemented here
16+
' i.e: if(err = "...") then ...
17+
end try
18+
19+
print "This point is reach, even if opening the file was not possible"
20+
```

_build/reference/1437-language-throw.markdown

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,22 @@
22

33
> THROW [info [, ...]]
44
5-
The THROW command (previously known as RTE) is used to initiate a catch-able error. If there is no surrounding TRY/CATCH block, THROW can be used to abort the program.
5+
The THROW command is used to initiate a catch-able error. If there is no surrounding TRY/CATCH block, THROW can be used to abort the program. Optional a string `info` can be used to create an error message.
66

7-
*Summary*
8-
TRY/CATCH is used to trap errors allowing a program to recover without having to be restarted.
7+
### Example 1: Abort a program
98

109
```
11-
TRY
10+
throw("Error")
1211
```
1312

14-
The TRY statement introduces a TRY/CATCH BLOCK.
13+
### Example 2: Initial a catch-able error
1514

1615
```
17-
CATCH [var | expr]
18-
```
19-
20-
The CATCH statement is used to CATCH an run-time error. This is typically used with errors raised when calling a file system command that cannot be completed, for example attempting to open a non-existent file.
21-
22-
The CATCH statement has two modes. You can supply a variable argument to store the error string. Alternatively you can supply an expression. When the raised error matches the (String) expression, the error will be caught.
23-
24-
When using the expression mode, you can supply a succession of CATCH statements to handle various error messages separately.
25-
END TRY
26-
27-
The END TRY statement marks the end of a TRY/CATCH block.
28-
29-
```
30-
THROW
31-
```
32-
33-
The THROW command (previously known as RTE) is used to initiate a catch-able error. If there is no surrounding TRY/CATCH block, THROW can be used to abort the program.
34-
35-
Example
36-
37-
~~~
38-
3916
try
40-
open "com2000:" AS #1
17+
a = 1
18+
if(a == 1) then throw("a == 1")
19+
if(a == 2) then throw("a == 2")
4120
catch err
42-
? "in catch: open failed";err
21+
print "Error: "; err
4322
end try
44-
45-
~~~
46-
23+
```
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# EXEC
22

3-
> EXEC file
3+
> EXEC (file)
44
5-
Transfers control to another operating system program. Control returns to the .bas immediately and the system command is executed parallel and independent to SmallBASIC. File name is case sensitive in Linux.
5+
Transfers control to the program `file`. Control returns to the calling bas-file immediately and the program is executed parallel and independent to SmallBASIC. File name is case sensitive in Linux. Enclose the string `file` with quotation marks to start a program with parameters.
66

77
See `run` for starting an external program and wait until program finished execution.
88

9+
### Example 1
10+
911
```
1012
' Select your editor for testing
1113
exec "kate" ' Editor KDE
@@ -15,3 +17,9 @@ exec "kate" ' Editor KDE
1517
print "This line will be printed immediately without delay"
1618
```
1719

20+
### Example 2: Execute with parameters
21+
22+
```
23+
' Call shutdown in Linux
24+
exec(enclose("shutdown -h now"))
25+
```

_build/reference/1448-date-ticks.markdown

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# TICKS
22

3-
> TICKS
3+
> n = TICKS
44
55
Returns the number of milliseconds that have elapsed since start of the operating system.
66

7+
### Example 1:
8+
79
```
810
t = ticks()
911
print t
1012
```
1113

14+
### Example 2: Game with constant frame rate
15+
1216
```
1317
' ticks() can be used to let your game
1418
' run with a constant frame rate

0 commit comments

Comments
 (0)