Skip to content

Commit 8ee6582

Browse files
committed
Add missing features
1 parent 8458a60 commit 8ee6582

File tree

7 files changed

+737
-651
lines changed

7 files changed

+737
-651
lines changed

_build/pages/download.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
- [Nokia N770/N800](http://downloads.sourceforge.net/smallbasic/sbasic_0.9.7.2_armel.deb){target="_blank"}
3636
- [PalmOS5](http://downloads.sourceforge.net/smallbasic/SmallBASIC-PalmOS5-0.8.2b.zip){target="_blank"}
3737
- [eBookman](http://downloads.sourceforge.net/smallbasic/SmallBASIC_ebm_092j.zip){target="_blank"}
38-
- [Ohter releases on SourceForge](http://sourceforge.net/project/showfiles.php?group_id=22348){target="_blank"}
38+
- [Other releases on SourceForge](http://sourceforge.net/project/showfiles.php?group_id=22348){target="_blank"}
3939

4040
## Changelog
4141

_build/pages/guide.markdown

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Contents
3232
* [Creating Arrays](#CreatingArrays)
3333
* [Accessing Elements of an Array](#AccessingElementsOfAnArray)
3434
* [Nested Arrays](#NestedArrays)
35+
* [Packed/Unpacked Assignment](#PackedUnpackedAssignment)
3536
* [Array Operations](#ArrayOperations)
3637
* [Matrices](#Matrices)
3738
* [Creating 2D Matrices](#Creating2DMatrices)
@@ -473,6 +474,22 @@ PRINT A[2][0] ' Output: 4
473474
PRINT A(2)(1) ' Output: 5
474475
```
475476

477+
### Packed/Unpacked Assignment {#PackedUnpackedAssignment}
478+
479+
An array can be unpacked using the unpack assignment:
480+
481+
```
482+
(var1,...,varN) = array[element1,...,elementN]
483+
```
484+
485+
The number of variables must match the number of elements.
486+
487+
```smallbasic
488+
v = [1,2,3]
489+
(x,y,z) = v
490+
PRINT x, y, z
491+
```
492+
476493
### Array Operations {#ArrayOperations}
477494

478495
SmallBASIC supports basic array operations using the standard operators:
@@ -1362,6 +1379,13 @@ NEXT
13621379
' Output 12 6 23 -4
13631380
```
13641381

1382+
The FOR-IN-NEXT loop also loops until the last character of a string is reached.
1383+
1384+
```smallbasic
1385+
s = "Test"
1386+
FOR index IN s DO PRINT index
1387+
```
1388+
13651389
The index variable is only a copy of the array element. Changing the content of
13661390
the index variable will not change the content of the array element.
13671391

@@ -1478,10 +1502,11 @@ numeric-label.
14781502
### Inline Version of IF {#InlineVersionOfIf}
14791503

14801504
```smallbasic
1505+
result = IF (condition, return_value_true, return_value_false)
14811506
result = IFF (condition, return_value_true, return_value_false)
14821507
```
14831508

1484-
The command `IFF` will test the condition `condition`. If `condition` resolves to
1509+
The functions `IF` and `IFF` will test the condition `condition`. If `condition` resolves to
14851510
`true` then `return_value_true` will be returned otherwise `return_value_false`.
14861511

14871512
```smallbasic
@@ -1490,6 +1515,8 @@ ans = IFF(x <= 5, 0, 10)
14901515
PRINT ans ' Output: 0
14911516
```
14921517

1518+
If `IF` is used with one parameter, the normal IF-statement is used.
1519+
14931520
See function reference [IFF](https://smallbasic.github.io/reference/638.html) for
14941521
more information.
14951522

_build/reference/680-language-for.markdown

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ Defines a FOR/NEXT loop.
1313
- element - A variable to be used as the copy of the current element.
1414
- array - An array or map variable
1515

16+
FOR/NEXT loops may be nested to any level of complexity, but there must be a NEXT for each FOR.
17+
1618
### FOR counter = start TO end [STEP incr] ... NEXT
1719

1820
SmallBASIC begins processing of the FOR/NEXT block by setting counter equal to start. Then, if 'incr' is positive and counter is not greater than end, the commands between the FOR and the NEXT are executed. When the NEXT is encountered, counter is increased by 'incr', and the process is repeated. Execution passes to the command following the NEXT if counter is greater than end.
1921

20-
If increment is negative, execution of the FOR/NEXT loop is terminated whenever counter becomes less than end. FOR/NEXT loops may be nested to any level of complexity, but there must be a NEXT for each FOR.
22+
If increment is negative, execution of the FOR/NEXT loop is terminated whenever counter becomes less than end.
2123

2224
### FOR element IN array ... NEXT
2325

2426
The commands-block will be repeated for LEN(array) times. Each time the 'element' will holds the value of the current element of the array.
25-
FOR/NEXT loops may be nested to any level of complexity, but there must be a NEXT for each FOR.
27+
28+
### FOR character IN string ... NEXT
29+
30+
The commands-block will be repeated for LEN(string) times. Each time the 'character' will holds the value of the current character of the string.
2631

2732
### Example 1
2833

@@ -133,4 +138,10 @@ next
133138
' Output: 1 2 3 4 5
134139
```
135140

141+
### Example 9: FOR-IN with a string
142+
143+
```
144+
s = "Test"
145+
FOR c IN s DO PRINT c
146+
```
136147

_build/reference/683-language-if.markdown

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ Causes SmallBASIC to make a decision based on the value of an expression.
5353
* expression - An expression; 0 is equivalent to FALSE, while all other values are equivalent to TRUE.
5454
* command - Any legal command or a numeric label. If a number is specified, it is equivalent to a GOTO command with the specified numeric-label.
5555

56+
### Inline-IF
57+
58+
```smallbasic
59+
result = IF (condition, return_value_true, return_value_false)
60+
```
61+
62+
The function `IF` will test the condition `condition`. If `condition` resolves to
63+
`true` then `return_value_true` will be returned otherwise `return_value_false`.
64+
5665
### Example 1: Block-style IF
5766

5867
```
@@ -118,3 +127,11 @@ ELSE
118127
PRINT "something else"
119128
ENDIF
120129
```
130+
131+
### Example 5: Inline IF
132+
133+
```
134+
x = 4
135+
ans = IF(x <= 5, 0, 10)
136+
PRINT ans ' Output: 0
137+
```

_build/reference/801-string-translate.markdown

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

3-
> s = TRANSLATE (source, what [, with])
3+
> s = TRANSLATE (source, what [, with] [, caseInsensitiv])
44
5-
Translates all occurrences of the string `what` found in string `source` with the string `with` and returns the new string. If `with` is not given, all occurrences of `what` will be removed.
5+
Translates all occurrences of the string `what` found in string `source` with the string `with` and returns the new string. If `with` is not given, all occurrences of `what` will be removed. `caseInsensitiv` can be `true` for case insensitiv or `false` for case sensitiy. If `caseInsensitiv` is not given, `TRANSLATE` is case sensitiv.
66

77
### Example 1: Replace
88

@@ -19,3 +19,16 @@ s1 = "ab_cd_ef"
1919
s2 = translate(s1, "cd")
2020
print s1 + " -> "; s2 ' Output: ab_cd_ef -> ab__ef
2121
```
22+
23+
### Example 3: Case Insensitivity
24+
25+
```
26+
print translate("foo bar", " BAR", "d", true)
27+
print translate("foo bar", " BAR", "d", false)
28+
print translate("foo bar", " BAR", "d")
29+
30+
' Output:
31+
' food
32+
' foo bar
33+
' foo bar
34+
```

pages/download.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ <h2 id="other-releases">Other releases</h2>
9696
target="_blank">eBookman</a></li>
9797
<li><a
9898
href="http://sourceforge.net/project/showfiles.php?group_id=22348"
99-
target="_blank">Ohter releases on SourceForge</a></li>
99+
target="_blank">Other releases on SourceForge</a></li>
100100
</ul>
101101
<h2 id="changelog">Changelog</h2>
102102
<ul>
@@ -105,11 +105,11 @@ <h2 id="changelog">Changelog</h2>
105105
</ul>
106106
</div>
107107
<div class="pagefooter">
108-
This page was last edited on Thu, 20 Feb 2025 21:34:29 +0100
108+
This page was last edited on Tue, 2 Sep 2025 21:28:15 +0200
109109
|
110110
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
111111
processed with
112-
<a href="https://pandoc.org/MANUAL.html#pandocs-markdown" target="_blank" rel="nofollow">pandoc 3.1.13</a>
112+
<a href="https://pandoc.org/MANUAL.html#pandocs-markdown" target="_blank" rel="nofollow">pandoc 3.2.1</a>
113113
</div>
114114
</div>
115115
</div>

0 commit comments

Comments
 (0)