Skip to content

Commit 5005601

Browse files
committed
Update user manual and add video
1 parent 9a33a7c commit 5005601

File tree

4 files changed

+218
-54
lines changed

4 files changed

+218
-54
lines changed

_build/pages/android.markdown

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,23 @@ Android
33

44
> SmallBASIC for Android guide
55
6+
The Android version of SmallBASIC comes with a built-in Integrated Development Environment
7+
(IDE), you can write programs on your Android-powered tablet or mobile phone and run them instantly.
8+
69
## Getting started
710

8-
The system menu is accessed by the "three vertical dots" button in the bottom right corner of the screen.
11+
In the video below the basic steps of creating a file, opening it in the internal editor and executing
12+
the program are shown.
13+
14+
<div class="video-container">
15+
<iframe width="1160" height="653" src="https://www.youtube.com/embed/2fW7usYY_CA" title="SmallBASIC &quot;Hello World&quot;" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
16+
</div>
17+
18+
Please note, that at the first start of the Android version of SmallBASIC, the editor is turned off. A mouse click on
19+
a program name will start it immediately. If you want to edit the file, please turn on the editor by clicking
20+
on the three dots in the lower right corner and choosing the entry `Editor [OFF]` to enable the editor.
21+
22+
## Step-by-Step Guide
923

1024
![](/images/android_menu1.png "System Menu button")
1125

_build/pages/guide.markdown

+173-52
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ syntax.
1111
Contents
1212
:::
1313

14+
* [Getting Started](#GettingStarted)
15+
* [SmallBASIC Versions](#SmallbasicVersions)
16+
* [Windows](#Windows)
17+
* [Linux](#Linux)
18+
* [Android](#Android)
19+
* [Build from Source](#BuildFromSource)
20+
* [Using the IDE](#UsingtheIntegratedDevelopmentEnvironment)
1421
* [Source Code Format](#SourceCodeFormat)
1522
* [Comments](#Comments)
1623
* [Numbers and Srings](#NumberAndStrings)
@@ -37,6 +44,7 @@ Contents
3744
* [Accessing Elements of a Map Variable](#AccessingElementsOfAMapVariable)
3845
* [Add Key-Value Pairs](#AddKeyValuePairs)
3946
* [Key-Value Pairs with References](#KeyValuePairsWithReferences)
47+
* [Maps as Pseudo Objects for OOP](#MapsAsPseudoObjectForOOP)
4048
* [Operators](#Operators)
4149
* [Pseudo-operators](#pseudo)
4250
* [Subroutines and Functions](#SubroutinesAndFunctions)
@@ -50,11 +58,16 @@ Contents
5058
* [Nested Routines](#NestedRoutines)
5159
* [Declarations in PalmOS](#DeclarationsInPalmOS)
5260
* [Expressions](#Expressions)
61+
* [IF-THEN-ELSIF-ELSE](#IfThenElseifEndif)
62+
* [Single-line IF-THEN-ELSE](#SingleLineIfThenElse)
63+
* [Inline Version of IF](#InlineVersionOfIf)
64+
* [SELECT CASE](#SelectCase)
5365
* [Loops](#Loops)
5466
* [FOR-TO-NEXT Loop](#ForToNextLoop)
5567
* [FOR-IN-NEXT Loop](#ForInNextLoop)
5668
* [WHILE-WEND Loop](#WhileWendLoop)
5769
* [REPEAT-UNTIL Loop](#RepeatUntilLoop)
70+
* [The DO Keyword](#TheDoKeyword)
5871
* [Units](#Units)
5972
* [Declaration](#UnitsDeclaration)
6073
* [Import](#UnitsImport)
@@ -63,12 +76,65 @@ Contents
6376
* [OPTION MATCH](#Statement3)
6477
* [OPTION PREDEF](#Statement4)
6578
* [Meta Commands](#Meta)
66-
* [The USE keyword](#use)
67-
* [The DO keyword](#do)
68-
* [Loops and variables](#Loops)
79+
* [The USE Keyword](#TheUseKeyword)
80+
* [Exception Handling](#ExceptionHandling)
6981

7082
:::
7183

84+
## Getting Started {#GettingStarted}
85+
86+
SmallBASIC is available for various operating systems, including
87+
Windows, Linux, and Android. It can be built from source to run
88+
on many other POSIX-compliant systems, such as Raspberry Pi OS. With
89+
its built-in Integrated Development Environment (IDE), you can write
90+
programs on your Android-powered tablet or mobile phone and run them
91+
instantly.
92+
93+
### SmallBASIC Versions {#SmallbasicVersions}
94+
95+
SmallBASIC comes in three different flavors for the desktop. The SDL version offers a simple but
96+
efficient IDE and is perfect for working with graphics. The FLTK version has a great IDE. The
97+
console version doesn’t offer an IDE and is text-only but works perfect with plugins like raylib
98+
or nuklear. The Android version is similar to the SDL version and comes with an integrated IDE,
99+
too.
100+
101+
### Windows {#Windows}
102+
103+
Download the [latest release of SmallBASIC](https://smallbasic.github.io/pages/download.html).
104+
The different versions of SmallBASIC are included in the zip-file. Extract the zip-file to a
105+
location of your choice. Open the SmallBASIC folder and start one of the following programs:
106+
107+
- sbasicg.exe: SDL
108+
- sbasici.exe: FLTK
109+
- sbasic.exe: Console
110+
111+
### Linux {#Linux}
112+
113+
Download the [latest release of SmallBASIC](https://smallbasic.github.io/pages/download.html).
114+
The different versions of SmallBASIC are provided as separate AppImages. Download an AppImage
115+
and copy it to a directory of your choice. Execute the AppImage. Depending of the Linux version
116+
you have to make the AppImage executable: `chmod u+x AppImageFile`, where `AppImageFile` is the
117+
filename of the AppImage.
118+
119+
### Android {#Android}
120+
121+
Download and install SmallBASIC for Android using
122+
[Google Play](https://play.google.com/store/apps/details?id=net.sourceforge.smallbasic).
123+
124+
### Build from Source {#BuildFromSource}
125+
126+
Using Linux it is quite easy to build SmallBASIC from source. This has the advantage, that you
127+
don't need to use AppImages and you can use SmallBASIC on other devices like Raspberry Pi.
128+
Please follow the instructions on [Github](https://github.com/smallbasic/SmallBASIC).
129+
130+
### Using the Integrated Development Environment {#UsingtheIntegratedDevelopmentEnvironment}
131+
132+
Please read the separate articles for the different versions of SmallBASIC:
133+
134+
- [SDL](https://smallbasic.github.io/pages/sdl.html)
135+
- [Android](https://smallbasic.github.io/pages/android.html)
136+
- [FLTK](https://smallbasic.github.io/pages/fltk.html)
137+
72138
## Source Code Format {#SourceCodeFormat}
73139

74140
SmallBASIC files are plain text files in ASCII or UTF-8. A program consists of
@@ -776,6 +842,8 @@ sub PrintBold(s)
776842
end
777843
```
778844

845+
### Maps as Pseudo Objects for OOP {#MapsAsPseudoObjectForOOP}
846+
779847
Maps in combination with references can be used to create a pseudo object
780848
similar to object-oriented programming.
781849

@@ -899,13 +967,13 @@ scope.
899967

900968
Subroutine and function names can use any alphanumeric characters, extended
901969
characters (ASCII codes 128 - 255 for non-English languages), and the symbol `_`.
902-
The first character of the name cannot be a digit nor a `_`.
970+
The first character of the name cannot be a digit.
903971

904972
Subroutine and function names are case-insensitive.
905973

906974
```
907-
abc(), a_c(), ab2c() -> valid names
908-
1cd(), a$b(), _abc() -> invalid names
975+
abc(), a_c(), ab2c(), _abc() -> valid names
976+
1cd(), a$b() -> invalid names
909977
```
910978

911979
Subroutines and functions can not have the same name as build-in commands.
@@ -1254,6 +1322,20 @@ UNTIL index > 10
12541322

12551323
Use `EXIT` or in case of nested loops `EXIT LOOP` to exit the loop.
12561324

1325+
### The DO Keyword {#TheDoKeyword}
1326+
1327+
This keyword is used to declare single-line commands. It can be used with
1328+
`WHILE` and `FOR`-family loops.
1329+
1330+
```smallbasic
1331+
FOR i = 1 to 10 DO PRINT i
1332+
FOR f IN files("*.txt") DO PRINT f
1333+
```
1334+
1335+
```smallbasic
1336+
WHILE i < 4 DO i++
1337+
```
1338+
12571339
## Conditions {#Conditions}
12581340

12591341
Conditions can be used to branch the program flow depending on the value of
@@ -1288,9 +1370,10 @@ on its line. If anything other than a comment follows `THEN` on the same line,
12881370
SmallBASIC interprets it as a single-line IF-THEN-ELSE construct. IF blocks may
12891371
be nested.
12901372

1291-
Instead of `ELSEIF` and `ENDIF`, `ELIF` and `FI` can be used.
1373+
Instead of `ELSEIF` and `ENDIF`, `ELIF` and `FI` can be used. Instead of `THEN`,
1374+
`DO` can be used, but this is not suggested.
12921375

1293-
### Single-line IF-THEN-ELSE
1376+
### Single-line IF-THEN-ELSE {#SingleLineIfThenElse}
12941377

12951378
```smallbasic
12961379
IF expression THEN command1 ELSE command2
@@ -1303,7 +1386,47 @@ Multiple commands can be separated by a colon `:`. If instead of a command a
13031386
number is specified, it is equivalent to a GOTO command with the specified
13041387
numeric-label.
13051388

1389+
### Inline Version of IF {#InlineVersionOfIf}
1390+
1391+
```smallbasic
1392+
result = IFF (condition, return_value_true, return_value_false)
1393+
```
1394+
1395+
The command `IFF` will test the condition `condition`. If `condition` resolves to
1396+
`true` then `return_value_true` will be returned otherwise `return_value_false`.
1397+
1398+
```smallbasic
1399+
x = 4
1400+
ans = IFF(x <= 5, 0, 10)
1401+
PRINT ans ' Output: 0
1402+
```
1403+
1404+
See function reference [IFF](https://smallbasic.github.io/reference/638.html) for
1405+
more information.
1406+
1407+
### SELECT CASE {#SelectCase}
1408+
1409+
```smallbasic
1410+
SELECT CASE expr
1411+
CASE result1
1412+
' do thinks
1413+
CASE result2
1414+
' do thinks
1415+
CASE ELSE
1416+
' do thinks
1417+
END SELECT
1418+
```
1419+
1420+
`SELECT CASE` offers a more concise syntax to writing successive IF tests. `SELECT CASE`
1421+
performs multiple tests on the expression `expr`. If the value of `expr` is equal to
1422+
`result1`, the case statement `result1` will be entered and the commands executed. An
1423+
unlimited amount of case statements can be used. Once a case statement is fulfilled
1424+
the select-case structure will be exited and all following case statements will not be
1425+
tested anymore. If non of the case statements were entered the optional 'CASE ELSE'
1426+
statements will be entered.
13061427

1428+
See function reference [SELECT CASE](https://smallbasic.github.io/reference/655.html) for
1429+
detailed information.
13071430

13081431
## Units {#Units}
13091432

@@ -1425,66 +1548,64 @@ SmallBASIC uses the following meta commands:
14251548
#unit-path: C:\sbasic\units;C:\temp
14261549
```
14271550

1551+
### The USE Keyword {#TheUseKeyword}
14281552

1553+
The `USE` keyword is used on specific commands for passing a user-defined expression.
14291554

1430-
### The USE keyword {#use}
1431-
1432-
This keyword is used on specific commands to passing a user-defined expression.
1433-
1434-
```
1555+
```smallbasic
14351556
SPLIT s," ",v USE TRIM(x)
14361557
```
14371558

1438-
In that example, every element of V() will be 'trimmed'.
1439-
Use the x variable to specify the parameter of the expression. If the expression needs more parameter, you can use also the names y and z
1559+
In this example, every element of `v` will be trimmed. Use the `x` variable to
1560+
specify the parameter of the expression. If the expression needs more parameter,
1561+
you can use also the names `y` and `z`.
14401562

1441-
### The DO keyword {#do}
1563+
## Exception Handling {#ExceptionHandling}
14421564

1443-
This keyword is used to declare single-line commands. It can be used with WHILE and FOR-family commands.
1565+
Exception handling is supported for file handling, and accessing serial ports and
1566+
network sockets. Exception handling is typically used with errors raised when
1567+
calling a file system command that cannot be completed, for example attempting to
1568+
open a non-existent file.
14441569

1570+
```smallbasic
1571+
TRY
1572+
' do something
1573+
CATCH err
1574+
print err
1575+
' do something
1576+
END TRY
14451577
```
1446-
FOR f IN files("*.txt") DO PRINT f
1447-
...
1448-
WHILE i < 4 DO i ++
1449-
```
1450-
1451-
Also, it can be used by IF command (instead of THEN), but is not suggested.
14521578

1453-
1454-
1455-
### Loops and variables {#Loops}
1456-
1457-
When we write loops it is much better to initialize the counters on the top of the loop instead of the top of the program or nowhere.
1458-
1459-
```
1460-
i = 0
1461-
REPEAT
1462-
...
1463-
i = i + 1
1464-
UNTIL i > 10
1579+
```smallbasic
1580+
TRY
1581+
' do something
1582+
CATCH "Error 1"
1583+
' do something
1584+
CATCH "Error 2"
1585+
' do something
1586+
END TRY
14651587
```
14661588

1467-
p.. Initializing variables at the top of the loop can make code more readable.
1589+
The `TRY` statement introduces a try/catch block. A try/catch block consist of the
1590+
following structure:
14681591

1469-
## Loops and expressions
1592+
`TRY`
14701593

1471-
```
1472-
FOR-like (loops) commands evaluate both the "destination" and the exit-expression every time.
1473-
FOR i=0 TO LEN(FILES("*.txt"))-1
1474-
PRINT i
1475-
NEXT
1476-
```
1594+
The `TRY` statement starts a block of commands which might create a run-time error.
14771595

1478-
In that example the 'destination' is the LEN(FILES("*.txt"))-1 For each value of i the destination will be evaluated. That is WRONG but it is supported by BASIC and many other languages.
1479-
So, it is much better to be rewritten as
1596+
`CATCH [var | expr]`
14801597

1481-
```
1482-
idest=LEN(FILES("*.txt"))-1
1483-
FOR i=0 TO idest
1484-
PRINT i
1485-
NEXT
1486-
```
1598+
The `CATCH` statement is used to catch a run-time error of one of the commands in
1599+
the try-block.
1600+
1601+
The `CATCH` statement has two modes. You can supply a variable argument to store the
1602+
error string. Alternatively you can supply a string expression. When the raised error
1603+
matches the string expression, the error will be caught. When using the expression
1604+
mode, you can supply a succession of CATCH statements to handle various error messages
1605+
separately.
14871606

1488-
Of course, it is much faster too.
1607+
`END TRY`
14891608

1609+
The `END TRY` statement marks the end of a try/catch block.
14901610

1611+
For examples see the language reference [TRY](https://smallbasic.github.io/reference/1425.html).

_build/pages/sdl.markdown

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
# sbasicg (SDL)
1+
# SmallBASIC SDL Version
2+
3+
The SDL version of SmallBASIC offers a simple but efficient IDE and is perfect for working with graphics. To start the SDL version please execute:
4+
5+
- Windows: `sbasicg.exe`
6+
- Linux: `SmallBASIC-SDL_xx.xx-x86_64.AppImage` or `sbasicg` if built from source
7+
8+
In the video below the basic steps of creating a file, opening it in the internal editor and executing
9+
the program are shown.
10+
11+
<div class="video-container">
12+
<iframe width="1160" height="653" src="https://www.youtube.com/embed/2fW7usYY_CA" title="SmallBASIC &quot;Hello World&quot;" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
13+
</div>
14+
15+
Please note, that at the first start of the SDL version of SmallBASIC, the editor is turned off. A mouse click on
16+
a file name will start the program immediately. If you want to edit the file, please turn on the editor by clicking
17+
on the three dots in the lower right corner and choosing the entry `Editor [OFF]` to enable the editor.
218

319
## Live mode
420

css/style.css

+13
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,19 @@ a.screenshot {
758758
display: inline-block;
759759
}
760760

761+
.video-container {
762+
position: relative;
763+
padding-bottom: 56.25%; /* 16:9 */
764+
height: 0;
765+
}
766+
.video-container iframe {
767+
position: absolute;
768+
top: 0;
769+
left: 0;
770+
width: 100%;
771+
height: 100%;
772+
}
773+
761774
/* CSS for syntax highlighting */
762775
pre > code.sourceCode { white-space: pre; position: relative; border:0px;}
763776
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }

0 commit comments

Comments
 (0)