Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _build/pages/download.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- [Nokia N770/N800](http://downloads.sourceforge.net/smallbasic/sbasic_0.9.7.2_armel.deb){target="_blank"}
- [PalmOS5](http://downloads.sourceforge.net/smallbasic/SmallBASIC-PalmOS5-0.8.2b.zip){target="_blank"}
- [eBookman](http://downloads.sourceforge.net/smallbasic/SmallBASIC_ebm_092j.zip){target="_blank"}
- [Ohter releases on SourceForge](http://sourceforge.net/project/showfiles.php?group_id=22348){target="_blank"}
- [Other releases on SourceForge](http://sourceforge.net/project/showfiles.php?group_id=22348){target="_blank"}

## Changelog

Expand Down
29 changes: 28 additions & 1 deletion _build/pages/guide.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Contents
* [Creating Arrays](#CreatingArrays)
* [Accessing Elements of an Array](#AccessingElementsOfAnArray)
* [Nested Arrays](#NestedArrays)
* [Packed/Unpacked Assignment](#PackedUnpackedAssignment)
* [Array Operations](#ArrayOperations)
* [Matrices](#Matrices)
* [Creating 2D Matrices](#Creating2DMatrices)
Expand Down Expand Up @@ -473,6 +474,22 @@ PRINT A[2][0] ' Output: 4
PRINT A(2)(1) ' Output: 5
```

### Packed/Unpacked Assignment {#PackedUnpackedAssignment}

An array can be unpacked using the unpack assignment:

```
(var1,...,varN) = array[element1,...,elementN]
```

The number of variables must match the number of elements.

```smallbasic
v = [1,2,3]
(x,y,z) = v
PRINT x, y, z
```

### Array Operations {#ArrayOperations}

SmallBASIC supports basic array operations using the standard operators:
Expand Down Expand Up @@ -1362,6 +1379,13 @@ NEXT
' Output 12 6 23 -4
```

The FOR-IN-NEXT loop also loops until the last character of a string is reached.

```smallbasic
s = "Test"
FOR index IN s DO PRINT index
```

The index variable is only a copy of the array element. Changing the content of
the index variable will not change the content of the array element.

Expand Down Expand Up @@ -1478,10 +1502,11 @@ numeric-label.
### Inline Version of IF {#InlineVersionOfIf}

```smallbasic
result = IF (condition, return_value_true, return_value_false)
result = IFF (condition, return_value_true, return_value_false)
```

The command `IFF` will test the condition `condition`. If `condition` resolves to
The functions `IF` and `IFF` will test the condition `condition`. If `condition` resolves to
`true` then `return_value_true` will be returned otherwise `return_value_false`.

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

If `IF` is used with one parameter, the normal IF-statement is used.

See function reference [IFF](https://smallbasic.github.io/reference/638.html) for
more information.

Expand Down
15 changes: 13 additions & 2 deletions _build/reference/680-language-for.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ Defines a FOR/NEXT loop.
- element - A variable to be used as the copy of the current element.
- array - An array or map variable

FOR/NEXT loops may be nested to any level of complexity, but there must be a NEXT for each FOR.

### FOR counter = start TO end [STEP incr] ... NEXT

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.

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.
If increment is negative, execution of the FOR/NEXT loop is terminated whenever counter becomes less than end.

### FOR element IN array ... NEXT

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.
FOR/NEXT loops may be nested to any level of complexity, but there must be a NEXT for each FOR.

### FOR character IN string ... NEXT

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.

### Example 1

Expand Down Expand Up @@ -133,4 +138,10 @@ next
' Output: 1 2 3 4 5
```

### Example 9: FOR-IN with a string

```
s = "Test"
FOR c IN s DO PRINT c
```

17 changes: 17 additions & 0 deletions _build/reference/683-language-if.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ Causes SmallBASIC to make a decision based on the value of an expression.
* expression - An expression; 0 is equivalent to FALSE, while all other values are equivalent to TRUE.
* 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.

### Inline-IF

```smallbasic
result = IF (condition, return_value_true, return_value_false)
```

The function `IF` will test the condition `condition`. If `condition` resolves to
`true` then `return_value_true` will be returned otherwise `return_value_false`.

### Example 1: Block-style IF

```
Expand Down Expand Up @@ -118,3 +127,11 @@ ELSE
PRINT "something else"
ENDIF
```

### Example 5: Inline IF

```
x = 4
ans = IF(x <= 5, 0, 10)
PRINT ans ' Output: 0
```
17 changes: 15 additions & 2 deletions _build/reference/801-string-translate.markdown
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# TRANSLATE

> s = TRANSLATE (source, what [, with])
> s = TRANSLATE (source, what [, with] [, caseInsensitiv])

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.
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.

### Example 1: Replace

Expand All @@ -19,3 +19,16 @@ s1 = "ab_cd_ef"
s2 = translate(s1, "cd")
print s1 + " -> "; s2 ' Output: ab_cd_ef -> ab__ef
```

### Example 3: Case Insensitivity

```
print translate("foo bar", " BAR", "d", true)
print translate("foo bar", " BAR", "d", false)
print translate("foo bar", " BAR", "d")

' Output:
' food
' foo bar
' foo bar
```
6 changes: 3 additions & 3 deletions pages/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h2 id="other-releases">Other releases</h2>
target="_blank">eBookman</a></li>
<li><a
href="http://sourceforge.net/project/showfiles.php?group_id=22348"
target="_blank">Ohter releases on SourceForge</a></li>
target="_blank">Other releases on SourceForge</a></li>
</ul>
<h2 id="changelog">Changelog</h2>
<ul>
Expand All @@ -105,11 +105,11 @@ <h2 id="changelog">Changelog</h2>
</ul>
</div>
<div class="pagefooter">
This page was last edited on Thu, 20 Feb 2025 21:34:29 +0100
This page was last edited on Tue, 2 Sep 2025 21:28:15 +0200
|
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
processed with
<a href="https://pandoc.org/MANUAL.html#pandocs-markdown" target="_blank" rel="nofollow">pandoc 3.1.13</a>
<a href="https://pandoc.org/MANUAL.html#pandocs-markdown" target="_blank" rel="nofollow">pandoc 3.2.1</a>
</div>
</div>
</div>
Expand Down
Loading