Skip to content

Commit 9d4da3f

Browse files
committed
fbdoc: wiki snapshot 2018-08-23
1 parent 9b04508 commit 9d4da3f

14 files changed

+169
-23
lines changed

doc/manual/cache/CatPgMemory.wakka

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ Procedures that work with static and dynamic memory.
2828
=={{fbdoc item="keyword" value="KeyPgSwap|SWAP"}}==
2929
Exchange the contents of two variables.
3030
=={{fbdoc item="keyword" value="KeyPgSadd|SADD"}}==
31-
Returns the address for the data in a string variable.
31+
Returns the address for the data in a zstring variable.
3232
>>::c::
33+
{{fbdoc item="see"}}
34+
- [[CatPgOpMemory|Memory Operators]]
3335

3436
{{fbdoc item="back" value="DocToc|Table of Contents"}}

doc/manual/cache/GlossaryIndex.wakka

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Brief definitions and explanations for words and phrases used in the ""FreeBASIC
124124
A source code statement (or statements) that allocates space for data or code. For example, ##[[KeyPgSub|Sub]]## defines a procedure by allocating space for the program code it will contain. Some statements can be both a declaration and a definition. For example, ##[[KeyPgDim|Dim]]## both declares and defines a variable.
125125

126126
**dereference**
127-
The act of obtaining a value from memory at a given address. See ##[[KeyPgOpValueOf|Operator * (ValueOf)]]##, ##[[ProPgPointers|Pointers]]##.
127+
The act of accessing (in read and in write) a variable stored at a given address. See ##[[KeyPgOpValueOf|Operator * (ValueOf)]]##, ##[[ProPgPointers|Pointers]]##.
128128

129129
**descriptor**
130130
Refers to the internal data structure used by the compiler and runtime library for managing variable length strings and arrays.

doc/manual/cache/KeyPgBinary.wakka

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Specifies file or device to be opened for binary mode
2424

2525
##//filename//## must be a string expression resulting in a legal file name in the target OS, without wildcards. The file will be sought for in the present directory, unless a path is given.
2626

27-
##//Access_type//## By default ##**Binary**## mode allows to both read and write the file, unless an ##[[KeyPgAccess|Access]]## type is specified, it mus be one of:
27+
##//Access_type//## By default ##**Binary**## mode allows to both read and write the file, unless an ##[[KeyPgAccess|Access]]## type is specified, it must be one of:
2828
- ##**Read**## - the file is opened for input only
2929
- ##**Write**## - the file is opened for output only
3030
- ##**Read Write**## - the file is opened for input and output (the default)

doc/manual/cache/KeyPgByref.wakka

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ end
3535
%%
3636

3737
{{fbdoc item="lang"}}
38-
- In //[[CompilerOptlang|-lang fb]]// dialect, ##**Byval**## is the default parameter passing convention for all built-in types except ##[[KeyPgString|String]]## and user-defined ##[[KeyPgType|Type]]## which are passed ##[[KeyPgByref|Byref]]## by default.
38+
- In //[[CompilerOptlang|-lang fb]]// dialect, ##[[KeyPgByval|Byval]]## is the default parameter passing convention for all built-in types except ##[[KeyPgString|String]]## and user-defined ##[[KeyPgType|Type]]## which are passed ##**Byref**## by default. The ##[[KeyPgZstring|Zstring]]## and ##[[KeyPgWstring|Wstring]]## built-in types are also passed ##**Byref**## by default, but passing ##[[KeyPgByval|Byval]]## is forbidden. Arrays are always passed ##**Byref**## and the use of the specifier ##**Byref**## or ##[[KeyPgByval|Byval]]## is forbidden.
3939
- In //[[CompilerOptlang|-lang qb]]// and //[[CompilerOptlang|-lang fblite]]// dialects, ##**Byref**## is the default parameter passing convention.
4040

4141
{{fbdoc item="diff"}}

doc/manual/cache/KeyPgByrefFunction.wakka

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,22 @@ Function f1( ) ByRef As String
4949
End Function
5050

5151
Function f2( ByRef _s As String ) ByRef As String
52-
'' This variable-length string will be returned by reference, no copy will be created.
52+
'' This variable-length string will transit by reference (input and output), no copy will be created.
5353
Function = _s
5454
End Function
5555

5656
s = "abcd"
5757
Print s
5858

59-
f1( ) &= "efgh"
59+
f1( ) = f1( ) & "efgh"
60+
Print s
61+
62+
'' The enclosing parentheses are required here on the left-hand side.
63+
( f2( s ) ) = f2( s ) & "ijkl"
6064
Print s
6165

62-
'' At time of writing, the enclosing parentheses are required here.
63-
( f2( s ) ) &= "ijkl"
66+
'' The enclosing parentheses are not required here on the left-hand side.
67+
f2( s ) => f2( s ) & "mnop"
6468
Print s
6569
%%
6670
{{fbdoc item="filename" value="examples/manual/procs/byref-result3.bas"}}%%(freebasic)

doc/manual/cache/KeyPgByval.wakka

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ End
3939
%%
4040

4141
{{fbdoc item="lang"}}
42-
- In the //[[CompilerOptlang|-lang fb]]// dialect, ##**Byval**## is the default parameter passing convention for all built-in types except ##[[KeyPgString|String]]## and user-defined ##[[KeyPgType|Type]]## which are passed ##[[KeyPgByref|Byref]]## by default.
43-
- In //[[CompilerOptlang|-lang qb]]// and //[[CompilerOptlang|-lang fblite]]// dialects, ##**Byref**## is the default parameter passing convention.
42+
- In the //[[CompilerOptlang|-lang fb]]// dialect, ##**Byval**## is the default parameter passing convention for all built-in types except ##[[KeyPgString|String]]## and user-defined ##[[KeyPgType|Type]]## which are passed ##[[KeyPgByref|Byref]]## by default. The ##[[KeyPgZstring|Zstring]]## and ##[[KeyPgWstring|Wstring]]## built-in types are also passed ##[[KeyPgByref|Byref]]## by default, but passing ##**Byval**## is forbidden. Arrays are always passed ##[[KeyPgByref|Byref]]## and the use of the specifier ##[[KeyPgByref|Byref]]## or ##**Byval**## is forbidden.
43+
- In //[[CompilerOptlang|-lang qb]]// and //[[CompilerOptlang|-lang fblite]]// dialects, ##[[KeyPgByref|Byref]]## is the default parameter passing convention.
4444

4545
{{fbdoc item="diff"}}
4646
- QB only used ##**Byval**## in declarations to non-Basic subroutines

doc/manual/cache/KeyPgDraw.wakka

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Statement for sequenced pixel plotting
1919

2020
Commands to set the color, size and angle will take affect all subsequent ##**Draw**## operations.
2121

22+
##**Draw**## respects the current clipping region as set by the ##[[KeyPgViewgraphics|View (Graphics)]]## statement, but its coordinates are not affected by the custom coordinates system.
23+
2224
{{fbdoc item="ex"}}
2325
{{fbdoc item="filename" value="examples/manual/gfx/draw.bas"}}%%(freebasic)
2426
screen 13

doc/manual/cache/KeyPgFunctionPtr.wakka

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Data type that stores a pointer to a ##[[KeyPgFunction|FUNCTION]]## procedure re
2121
The procedure must match the same ##[[KeyPgFunction|Function]]## declaration as the declared ##[[KeyPgFunction|Function]]## pointer.
2222

2323
To call the subroutine assigned, use the ##//variable//## name as if it were a normal declared ##[[KeyPgFunction|Function]]##.
24+
25+
One of the primary uses for procedure pointers is to create callback procedures. A callback procedure is a procedure created in the user program that is called by another procedure either from the user own code space or from an external library.
2426

2527
{{fbdoc item="ex"}}
2628
{{fbdoc item="filename" value="examples/manual/datatype/funcptr.bas"}}%%(freebasic)
@@ -32,7 +34,64 @@ dim x as Function( x as string ) as string = procptr( ConcatSelf )
3234

3335
print x( "Hello" )
3436
%%
35-
37+
{{fbdoc item="filename" value="examples/manual/datatype/funcptr2.bas"}}%%(freebasic)
38+
Function x2 (Byval i As Integer) As Integer
39+
Return i * 2
40+
End Function
41+
42+
Function x3 (Byval i As Integer) As Integer
43+
Return i * 3
44+
End Function
45+
46+
Function operation (Byval i As Integer, Byval op As Function (Byval As Integer) As Integer) As Integer
47+
Return op(i)
48+
End Function
49+
50+
Print operation(4, @x2)
51+
Print operation(4, @x3)
52+
%%
53+
{{fbdoc item="filename" value="examples/manual/datatype/funcptr3.bas"}}%%(freebasic)
54+
' Example of basic callback Function mechanism to implement a key pressed event:
55+
' (the user callback Function address cannot be modified while the event thread is running)
56+
' - An asynchronous thread tests the keyboard in a loop, and calls a user callback Function each time a key is pressed.
57+
' - The callback Function address is passed to the thread.
58+
' - The callback Function prints the character of the key pressed,
59+
' but if the key pressed is <escape> it orders the thread to finish by using the function return value.
60+
' - As the user callback address is passed to the thread as argument, it cannot be modified while the thread is running.
61+
62+
63+
'' thread Sub definition
64+
Sub threadInkey (Byval p As Any Ptr)
65+
If p > 0 Then '' test condition callback Function defined
66+
Dim As Function (Byref As String) As Integer callback = p '' convert the any ptr to a callback Function pointer
67+
Do
68+
Dim As String s = Inkey
69+
If s <> "" Then '' test condition key pressed
70+
If callback(s) Then '' test condition to finish thread
71+
Exit Do
72+
End If
73+
End If
74+
Sleep 50
75+
Loop
76+
End If
77+
End Sub
78+
79+
'' user callback Function definition
80+
Function printInkey (Byref s As String) As Integer
81+
If Asc(s) = 27 Then '' test condition key pressed = <escape>
82+
Print
83+
Return -1 '' order thread to finish
84+
Else
85+
Print s;
86+
Return 0 '' order thread to continue
87+
End If
88+
End Function
89+
90+
'' user main code
91+
Dim As Any Ptr p = Threadcreate(@threadInkey, @printInkey) '' launch the thread, passing the callback Function address
92+
Threadwait(p) '' wait for the thread finish
93+
%%
94+
3695
{{fbdoc item="diff"}}
3796
- New to ""FreeBASIC""
3897

doc/manual/cache/KeyPgReturn.wakka

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ Control flow statement to return from a procedure or ##[[KeyPgGosub|Gosub]]##.
1111

1212
Because ##[[KeyPgReturn|Return]]## could mean return-from-gosub or return-from-procedure, ##[[KeyPgOptiongosub|Option Gosub]]## and ##[[KeyPgOptionnogosub|Option Nogosub]]## can be used to enable and disable ##[[KeyPgGosub|Gosub]]## support. When ##[[KeyPgGosub|Gosub]]## support is disabled, ##[[KeyPgReturn|Return]]## is then recognized as return-from-procedure. When ##[[KeyPgGosub|Gosub]]## support is enabled, ##[[KeyPgReturn|Return]]## is then recognized as return-from-gosub.
1313

14-
##**Return**## (from procedure) is used inside a procedure to exit the procedure possibly with a return value. A ##[[KeyPgSub|Sub]]## cannot specify a return return value. In a ##[[KeyPgFunction|Function]]##, ##**Return**## must specify its return value. ##**Return** //expression//## is roughly equivalent to the ##Function = //expression// : [[KeyPgExit|Exit]] Function## idiom.
15-
14+
##**Return**## (from procedure) is used inside a procedure to exit the procedure possibly with a return value:
15+
- A ##[[KeyPgSub|Sub]]## cannot specify a return return value. ##**Return**## is roughly equivalent to the ##[[KeyPgExit|Exit]] Sub## idiom.
16+
- In a ##[[KeyPgFunction|Function]]##, ##**Return**## must specify its return value. ##**Return** //expression//## is roughly equivalent to the ##Function = //expression// : [[KeyPgExit|Exit]] Function## idiom.
17+
18+
1619
##**Return**## (from gosub) is used to return control back to the statement immediately following a previous ##[[KeyPgGosub|Gosub]]## call. When used in combination with ##[[KeyPgGosub|Gosub]]##, no return value can be specified. If the optional ##//label//## is specified, execution continues at the specified label. If no ##[[KeyPgGosub|Gosub]]## was made, a runtime error is generated, and execution continues immediately after ##**Return**##.
1720

1821
A ##[[KeyPgGosub|Gosub]]## should always have a matching ##**Return**## statement. However, if ##**Return**## (from gosub) is used where no ##[[KeyPgGosub|Gosub]]## was made, a run-time error is generated.

doc/manual/cache/KeyPgScreengraphics.wakka

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ __##flags## details:__
5959

6060
__Other details__
6161
While in windowed mode, clicking on the window close button will add a keypress of ##([[KeyPgChr|Chr]](255) & "k")## to the ##[[KeyPgInkey|Inkey]]## buffer. Clicking on the Maximize window button will switch to fullscreen mode if possible. A successful ##**Screen**## call sets currently visible and working pages both to page number ##0##, resets the palette to the specified mode one (see [[GfxDefPalettes|Default palettes]]), resets the clipping region to the size of the screen, disables custom coordinates mappings, moves the graphics cursor to the center of the screen, moves the text cursor to the top-left corner of the screen (but never visible on any graphics screen), and sets foreground and background colors to bright white and black respectively.
62+
63+
__Note on using ##Screen 0##__
64+
##Screen 0## closes any graphics window, but also clears the console window if it exists.
65+
##Screen 0, , , SCREEN_EXIT## (with ##SCREEN_EXIT=&h80000000##) also closes any graphics window, but does not clear the console window if it exists (previous text is preserved).
6266

6367
{{fbdoc item="ex"}}
6468
{{fbdoc item="filename" value="examples/manual/gfx/screen.bas"}}%%(freebasic)

0 commit comments

Comments
 (0)