Skip to content

Update reference functions G to J #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Apr 21, 2023
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
922b53b
Update 1457-language-false.markdown
Joe7M Mar 13, 2023
e7f760b
Update 525-console-form.markdown
Joe7M Mar 14, 2023
8219050
Update 525-console-form.markdown
Joe7M Mar 23, 2023
3c9e63a
Update 681-language-gosub.markdown
Joe7M Mar 23, 2023
212972b
Update 682-language-goto.markdown
Joe7M Mar 24, 2023
1d5bea7
Update 780-string-hex.markdown
Joe7M Mar 24, 2023
864856e
Update 773-string-bin.markdown
Joe7M Mar 24, 2023
2ebc98c
Update 789-string-oct.markdown
Joe7M Mar 24, 2023
6be60c0
Update 1525-system-home.markdown
Joe7M Mar 24, 2023
ba6c759
Update 683-language-if.markdown
Joe7M Mar 24, 2023
ab6203c
Update 638-language-iff.markdown
Joe7M Mar 24, 2023
64fdcb6
Update 666-language-imp.markdown
Joe7M Mar 25, 2023
70eec4b
Update 666-language-imp.markdown
Joe7M Mar 25, 2023
ad46687
Merge branch 'smallbasic:master' into master
Joe7M Apr 10, 2023
3fb552d
Update 1441-system-import.markdown
Joe7M Apr 10, 2023
e4d2c61
Update 1446-system-unit.markdown
Joe7M Apr 10, 2023
58d7a1d
Update 1441-system-import.markdown
Joe7M Apr 10, 2023
d40feda
Update 1420-language-to.markdown
Joe7M Apr 13, 2023
9cbaa03
Update 1421-language-step.markdown
Joe7M Apr 13, 2023
cb84335
Update 1424-language-as.markdown
Joe7M Apr 13, 2023
e276854
Update 1429-graphics-showpage.markdown
Joe7M Apr 13, 2023
2781701
Update 667-language-in.markdown
Joe7M Apr 13, 2023
cc8e527
Update 1462-system-include.markdown
Joe7M Apr 14, 2023
e81e6da
Update 539-console-inkey.markdown
Joe7M Apr 14, 2023
0e4046b
Update 590-file-input.markdown
Joe7M Apr 17, 2023
a1444d9
Update 608-file-input.markdown
Joe7M Apr 17, 2023
dd66646
Update 608-file-input.markdown
Joe7M Apr 18, 2023
325b41a
Update 527-console-input.markdown
Joe7M Apr 18, 2023
2f02df6
Update 544-data-insert.markdown
Joe7M Apr 18, 2023
a37154c
Update 781-string-instr.markdown
Joe7M Apr 19, 2023
3d1e669
Update 734-math-int.markdown
Joe7M Apr 19, 2023
f86720f
Update 696-math-intersect.markdown
Joe7M Apr 19, 2023
a6e388b
Update 735-math-inverse.markdown
Joe7M Apr 19, 2023
2f70f3a
Update 555-data-isarray.markdown
Joe7M Apr 19, 2023
1bf6a4a
Update 556-data-isdir.markdown
Joe7M Apr 21, 2023
c2d6a30
Update 557-data-isfile.markdown
Joe7M Apr 21, 2023
18e2ddd
Update 556-data-isdir.markdown
Joe7M Apr 21, 2023
4ed9f92
Update 558-data-islink.markdown
Joe7M Apr 21, 2023
5d51f0a
Update 1430-data-ismap.markdown
Joe7M Apr 21, 2023
ea79bcf
Update 559-data-isnumber.markdown
Joe7M Apr 21, 2023
a05e90c
Update 560-data-isstring.markdown
Joe7M Apr 21, 2023
67a71fa
Update 545-string-join.markdown
Joe7M Apr 21, 2023
25d5e27
Update 577-date-julian.markdown
Joe7M Apr 21, 2023
ddaa788
Update 1446-system-unit.markdown
Joe7M Apr 21, 2023
ac4cdeb
Update 545-string-join.markdown
Joe7M Apr 21, 2023
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
6 changes: 6 additions & 0 deletions _build/reference/1420-language-to.markdown
Original file line number Diff line number Diff line change
@@ -4,6 +4,12 @@

Specifies the loop counter end in a FOR loop

### Example

```
for t = 1 to 10
print t
next
```


16 changes: 16 additions & 0 deletions _build/reference/1421-language-step.markdown
Original file line number Diff line number Diff line change
@@ -4,6 +4,22 @@

Specifies the loop counter increment in a FOR loop

### Example 1: Positive step

```
for t = 1 to 10 step 2
print t
next

' Output: 1 3 5 7 9
```

### Example 2: Negative step

```
for t = 10 to 1 step -2
print t
next

' Output: 10 8 6 4 2
```
25 changes: 24 additions & 1 deletion _build/reference/1424-language-as.markdown
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
# AS

> AS #fileN
> OPEN file AS #fileN

Used in combination with OPEN to open a file using a file number.

See: OPEN

### Example:

```
' create a text file
open "MyDemoFile.txt" for output as #1

for i = 1 to 10
print #1, i
next

close #1

' open text file and print content line by line
open "MyDemoFile.txt" for input as #1

while(!eof(1)) ' eof works only without #
input #1, c
print c
wend

close #1
```


9 changes: 9 additions & 0 deletions _build/reference/1429-graphics-showpage.markdown
Original file line number Diff line number Diff line change
@@ -4,4 +4,13 @@

This command is used to display pending graphics operations allowing for smooth animations.

### Example

```
for x = 10 to 100
cls
rect x, 10, x + 200, 200 filled
showpage
delay(20)
next
```
20 changes: 18 additions & 2 deletions _build/reference/1430-data-ismap.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# ISMAP

> ISMAP (x)
> b = ISMAP (x)

Returns true if x is an MAP variable type. A MAP provides value-key pair access along with array or dotted notation. The MAP can be initialized from a String variable using the ARRAY command.
Returns true if `x` is a MAP variable.

### Example

```
A = {"x":1, "y":2}
print IsMap(A) ' Output 1

A = [1,2,3]
print IsMap(A) ' Output 0 (is an array)

A = 1
print IsMap(A) ' Output 0 (is a number)

A = "abc"
print IsMap(A) ' Output 0 (is a string)
```


14 changes: 12 additions & 2 deletions _build/reference/1441-system-import.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# IMPORT

> IMPORT
> IMPORT UnitName [as MyName]

Import an exported UNIT variable, SUB or FUNC.
Import an exported UNIT or a module with the name UnitName using the namespace MyName.

See UNIT for an example on how to import an unit.

Additionally, modules can be imported using IMPORT. Several modules are part of the release version.
For more information on available modules and how to use them see the articels in the article section.

### Example 1: Import raylib module

```
import raylib as r
```

165 changes: 43 additions & 122 deletions _build/reference/1446-system-unit.markdown
Original file line number Diff line number Diff line change
@@ -2,12 +2,51 @@

> UNIT name

Declares the source module as a unit. Units are a set of procedures, functions and/or variables that can be used by another program or unit.
Declares the source module as a unit. Units are a set of procedures, functions, constants or variables that can be used by another program or unit.

As of SmallBASIC version 0.12.6:
- UNIT supports 'namespace' (Namespaces allow reuse of same names in different contexts. e.g. BitLib.Set(x) and StrLib.Set(x) are both using a function with the same name, "Set", but in different contexts).
- While UNIT can be used as a collection of sub-routines for your own program, UNIT is particularly useful for creating a general-purpose library. General purpose libraries can be useful for many programs or projects, the same way the internal routine “PRINT” is useful for many programs, and not only for specific one.

Use EXPORT to export procedured, functions, constants or variables. Only exported names can be access in the main program.

### Example 1: Simple Unit

First an example of the unit. Please save it with the filename "MyTestUnit.bas"

```
UNIT MyTestUnit

export MyFunc
export MySub
export MyConst = 3.1415
export MyVar = 5

func MyFunc(a,b)
return a + b
end

sub MySub(a,b)
print "a + b = "; a + b
end
```

Second an example on how to use the unit.

```
import MyTestUnit as u

u.MySub(1,2)

print u.MyFunc(2,3)
print u.MyConst

u.MyVar = u.MyVar + 5
print u.MyVar
```


### Example 2: An unit for using string

#. UNIT supports 'namespace' (Namespaces allow reuse of same names in different contexts. e.g. BitLib.Set(x) and StrLib.Set(x) are both using a function with the same name, "Set", but in different contexts).
#. UNIT name on Linux system is no longer case sensitive (which makes life easier for Linux users).

The UNIT file is strlib.bas:

@@ -83,122 +122,4 @@ Print Strlib.Rset("-->> ", 25)
Pause
~~~

#. While UNIT can be used as a collection of sub-routines for your own
program, UNIT is particularly useful for creating a general-purpose
library.
General purpose library can be useful for many programs or projects,
the same way the internal routine "PRINT" is useful for many programs,
and not only for specific one.

#. It is very important to keep the syntax of EXPORTed routines fixed.
For example:
Imagine that the internal routine "PRINT" will use a new syntax in
future version of SmallBASIC, something like:

~~~
PRINT [fileN,] x, y, color, "string" ' the "new" syntax
~~~

In this case many older programs will not work with the new version
of SmallBASIC.

The same way, when you create a UNIT to be used as a general-purpose
library, you must keep the syntax of EXPORTed routines fixed, so old
programs will continue to work well with newer versions of your UNIT.

3. If you modify an existing UNIT, you should assign to it a new version number.
The easy way to maintain a <a href=https://en.wikipedia.org/wiki/Software_versioning> Software versioning</a> is like this:

"Unit Name", Version major.minor.revision, Release_Date

For example:

~~~
REM Unit "StrLib" Version 1.15.11, 20/3/2016
~~~

major number:> is increased when there are significant jumps in functionality such as changing the framework which could cause incompatibility with interfacing programs.
minor number:> is incremented when only minor features or significant fixes have been added.

revision number:> is incremented when minor bugs are fixed.

By assigning a version number, other users will know what to expect from the
modified version. You should also add a short description of the changes
that you have made.

4. If your UNIT is quite advanced, and you expect it to work differently in
future versions, you can use the following method which allows Old & New
programs to work with your unit correctly:

Instead of using a fixed syntax for sub routines, such as:


~~~
ZipText(string, method, fileName)
~~~


Use a single object parameter which has a default value of 0:


~~~
ZipText(x)
~~~


Now, in version 1.0.0 for example, x might have this syntax as an array:


~~~
x is [string, method, fileName] ' Version 1.0.0
~~~

And in some future version, x might have another syntax, such as:


~~~
x is [string, method, fileName, format] ' Version 1.1.0
~~~

Or...

~~~
x is [string, fileName] ' Version 1.14.5
~~~

Etc.

The

~~~
ZipText(x)
~~~

routine will verify the number of arguments
and/or their type (array, string, etc) and execute the correct code for this
version's-syntax.

This method is especially useful for maintaining a big project for a long
time, which is going to offer more and more features in the future. It will
allow old programs to work as usual, and new programs to benefit from the
new features.

#. UNIT should Export only> routines or constants (variables)
which related to the specific use of that unit.
For example, UNIT which offers string manipulation routines should only>
Export string manipulation routines or string constants.

If UNITs contain routines for many different uses, it is likely that two
UNITs will have to IMPORT each other - and this is basically illogical.

#. * UNIT must be documented well, so other users can use it.
* UNIT should be efficient, because it should serves many other programs.
* Routines syntax should be consistent and standard, to be easy to use.
* UNIT is saved as Byte-Code (SBU), which is fast and does not include
spaces, comments, etc. So feel free to add enough comments and spaces...

There are more about UNITs (shared libraries), but the most important:
When you write a UNIT to be used by others, try to be merciful... i.e.
write clear and documented code, and make it easy for others to use your
UNIT.

6 changes: 2 additions & 4 deletions _build/reference/1457-language-false.markdown
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ a = true
b = false

print a ' output: 1
print b ' output: 2
print b ' output: 0
```

Example 2: Use in a while loop
@@ -21,8 +21,7 @@ IsRunning = true

while(IsRunning)
i++
print i

print i
if(i == 5) then IsRunning = false
wend

@@ -33,7 +32,6 @@ Example 3: Use in a if statement

```
ButtonPressed = false ' replace false with true

if(ButtonPressed) then print "Button was pressed"
```

Loading
Oops, something went wrong.