1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 13:50:36 +00:00

Updated offline wiki.

This commit is contained in:
FellippeHeitor 2016-03-18 08:36:04 -03:00
parent afc995ddc1
commit 00b9b6a37f
344 changed files with 6678 additions and 1820 deletions

View file

@ -2,14 +2,18 @@ The '''$CONSOLE''' [[Metacommand]] creates a console window that can be used thr
{{PageSyntax}}
::: $CONSOLE
::: '''$CONSOLE''' {ON|OFF|ONLY}
* [[_CONSOLE]] OFF or ON may be used to hide or show the console window. ON can only be used after OFF.
* [[_CONSOLE]] '''ON''' or '''OFF''' may be used to show or hide the console window. OFF can only be used after ON.
* The '''ONLY''' option can be used when only a console window is desired without a program window.
* [[_DEST]] [[_CONSOLE]] may be used to send screen output to the console window.
* [[_SCREENHIDE]] and [[_SCREENSHOW]] can be used to hide or show the main program window.
* [[_DELAY]] or [[SLEEP]] can be used to allow the console window to be set in front of the main program window.
* '''QB64 [[Metacommand]]s require that commenting or [[REM]] NOT be used anywhere on the Metacommand code line!'''
* Change the title of the [[$CONSOLE]] windows created using: [[SHELL]] "title consoletitle"
* '''Note:''' Text can be copied partially or totally from console screens in Windows by highlighting and using the title bar menu.
:: To copy console text output, right click the title bar and select ''Edit'' for ''Mark'' to highlight and repeat to ''Copy''
''Example 1:'' Hiding and displaying a console window. Use [[_DELAY]] to place console in front of main program window.
@ -26,8 +30,8 @@ The '''$CONSOLE''' [[Metacommand]] creates a console window that can be used thr
{{CodeEnd}}
''Example 2:'' How to use a Console window to copy screen output using the ''Edit'' menu by right clicking the console window title bar.
{{CodeStart}}
''Example 2:'' How to use a Console window to copy screen output using the ''Edit'' menu by right clicking the console title bar.
{{CodeStart}} '' ''
{{Cl|$CONSOLE}}
{{Cl|_DEST}} {{Cl|_CONSOLE}}
@ -43,7 +47,7 @@ hx$ = {{Cl|HEX$}}(c&&)
hx$ = {{Cl|HEX$}}(9223372036854775807)
{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
hx$ = {{Cl|HEX$}}(-9223372036854775808)
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits" '' ''
{{CodeEnd}}
{{OutputStart}}Max hex _BYTE = FF with 2 digits = 255
Max hex INTEGER = FFFF with 4 digits = 65535

35
internal/help/$ELSE.txt Normal file
View file

@ -0,0 +1,35 @@
'''$ELSE''' is precompiler command, which determines which sections of code inside its blocks are included into our code for compiling.
{{PageSyntax}}
:: $IF variable = expression THEN...
::.
:: $ELSE
::.
:: $END IF
* $ELSE must follow a valid $IF statement
* There can only be one $ELSE in an $IF-$ELSEIF-$ELSE-$END IF block, and it must be the last block selection before the $END IF. $ELSEIF ''can not'' follow $ELSE.
''Example 1:''
{{CodeStart}} '' ''
{{Cl|$IF}} WIN THEN
{{Cl|CONST}} Slash = "\"
{{Cl|$ELSE}}
{{Cl|CONST}} Slash = "/"
{{Cl|$END IF}}
{{Cl|PRINT}} "The proper slash for your operating system is "; Slash
{{CodeEnd}}
For the above, the CONST slash is defined by the automatic internal flag (WIN), which tells us what operating system we're using. On a windows PC, the Slash will be the backslash; for any other OS it will be the forward slash.
''See also:''
* [[$LET]]
* [[$IF]]
* [[$ELSEIF]]
* [[$END IF]]
{{PageNavigation}}

43
internal/help/$ELSEIF.txt Normal file
View file

@ -0,0 +1,43 @@
'''$ELSEIF''' is precompiler command, which determines which sections of code inside its blocks are included into our code for compiling.
{{PageSyntax}}
:: $IF variable = expression THEN...
::.
::.$ELSEIF variable = expression THEN...
::.
:: $ELSE
::.
:: $END IF
* $ELSEIF must follow a valid $IF or $ELSEIF statement.
* If $ELSE is used, it must be used as the last conditional check before $END IF. $ELSEIF ''can non'' come after $ELSE.
''Example 1:''
{{CodeStart}} '' ''
{{Cl|$IF}} WIN AND 32Bit THEN
{{Cl|CONST}} Slash = "\"
{{Cl|CONST}} OS = "Windows 32Bit"
{{Cl|$ELSEIF}} WIN AND 64Bit THEN
{{Cl|CONST}} Slash = "\"
{{Cl|CONST}} OS = "Windows 64Bit"
{{Cl|$ELSEIF}} 32Bit THEN
{{Cl|CONST}} Slash = "\"
{{Cl|CONST}} OS = "Non-Windows 32Bit"
{{Cl|$ELSE}}
{{Cl|CONST}} Slash = "/"
{{Cl|CONST}} OS = "Non-Windows 64Bit"
{{Cl|$END IF}}
{{Cl|PRINT}} "The proper slash for your operating system is "; Slash; " and you're running on a "; OS; " operating system."
{{CodeEnd}}
''See also:''
* [[$LET]]
* [[$IF]]
* [[$ELSE]]
* [[$END IF]]
{{PageNavigation}}

22
internal/help/$END_IF.txt Normal file
View file

@ -0,0 +1,22 @@
'''$END IF''' is precompiler command, which determines which sections of code inside its blocks are included into our code for compiling.
{{PageSyntax}}
:: $IF variable = expression THEN...
::.
::.$ELSEIF variable = expression THEN...
::.
:: $ELSE
::.
:: $END IF
* $END IF denotes the end of a valid precompiler $IF block.
''See also:''
* [[$LET]]
* [[$IF]]
* [[$ELSE]]
* [[$ELSEIF]]
{{PageNavigation}}

63
internal/help/$IF.txt Normal file
View file

@ -0,0 +1,63 @@
'''$IF''' is precompiler command, which determines which sections of code inside its blocks are included into our code for compliing.
{{PageSyntax}}
:: $IF variable = expression THEN...
::.
::.
::.
:: $END IF
* $IF is the start of a precompiler code block which includes or excludes sections of code from being compiled.
* Currently there is no single line $IF statement. $IF must be in a valid $IF THEN... $END IF block to work properly.
* Like all other metacommands, you can not use more than one metacommand per line. Use of : to separate multi-line statements onto one line will not work with $IF (or any other metacommand).
* Variable names can contain numbers, letters, and periods -- in any order!
* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters, and periods, in any order.
* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude for us. These are: '''WIN''' or '''WINDOWS''' if the user is running QB64 in a windows environment. '''LINUX''' if the user is running QB64 in a Linux environment. '''MAC''' or '''MACOSX''' if the user is running QB64 in a Mac environment. '''32BIT''' if the user is running a 32-bit version of QB64. '''64BIT''' if the user is running a 64-bit version of QB64.
''Example 1:''
{{CodeStart}} '' ''
{{Cl|$LET}} ScreenMode = 32
{{Cl|$IF}} ScreenMode = 0 THEN
{{Cl|CONST}} Red = 4
{{Cl|$ELSEIF}} ScreenMode = 32 THEN
{{Cl|CONST}} Red = _RGB32(255,0,0)
{{Cl|$END IF}}
{{Cl|COLOR}} Red
{{Cl|PRINT}} "Hello World"
{{CodeEnd}}
Explanation:
If you look at the code above, you'll see that we have the same CONST defined twice inside the program. Normally, we get an error if we try to define a CONST more than once, but the $IF condition here is CHOOSING which CONST we want inside our program.
AS long as Screenmode is 0, the program will exclude the code where CONST Red is defined as color 4. If Screenmode is 32, CONST Red will be defined as _RGB32(255, 0, 0).
The $LET and $IF statements let us control the code that actually gets compiled, while excluding the other blocks completely.
''Example 2:''
{{CodeStart}} '' ''
{{Cl|$IF}} WIN THEN
{{Cl|CONST}} Slash = "\"
{{Cl|$ELSE}}
{{Cl|CONST}} Slash = "/"
{{Cl|$END IF}}
{{Cl|PRINT}} "The proper slash for your operating system is "; Slash
{{CodeEnd}}
For the above, the CONST slash is defined by the automatic internal flags which tell us what operating system we're using. On a windows PC, the Slash will be the backslash; for any other OS it will be the forward slash.
''See also:''
* [[$LET]]
* [[$ELSE]]
* [[$ELSEIF]]
* [[$END IF]]
{{PageNavigation}}

40
internal/help/$LET.txt Normal file
View file

@ -0,0 +1,40 @@
'''$LET''' is precompiler command, which is now usable by modern day [[cavemen]] to help include and exclude which sections of code compiles in their program based on OS/bit-size or other predefined conditions.
{{PageSyntax}}
:: $LET variable = expression
* $LET a = 12 sets a precompiler variable "a" to the value of 12. This variable is ONLY valid for the precompiler itself and does NOTHING to affect the values of any variable/constant which might also be called "a" in the program.
* Variable names can contain numbers, letters, and periods -- in any order! $LET 3.2 = TRUE is a perfectly valid variable and expression.
* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters, and periods, in any order. $LET 3.2 = "TRUE" is also perfectly, but $LET 3.2 = ""TRUE"" will error. (See the double quotes?)
''Example 1:''
{{CodeStart}} '' ''
{{Cl|$LET}} ScreenMode = 32
{{Cl|$IF}} ScreenMode = 0 THEN
{{Cl|CONST}} Red = 4
{{Cl|$ELSEIF}} ScreenMode = 32 THEN
{{Cl|CONST}} Red = _RGB32(255,0,0)
{{Cl|$END IF}}
{{Cl|COLOR}} Red
{{Cl|PRINT}} "Hello World"
{{CodeEnd}}
Explaination:
If you look at the code above, you'll see that we have the same CONST defined inside the program. Normally, we get an error if we try to define a CONST more than once, but the $IF condition here is CHOOSING which CONST we want inside our program.
AS long as Screenmode is 0, the program will exclude the code where CONST Red is defined as color 4. If Screenmode is 32, CONST Red will be defined as _RGB32(255, 0, 0).
The $LET and $IF statements let us control the code that actually gets compiled, while excluding the other blocks completely.
''See also:''
* [[Cavemen]]
* [[$IF]]
* [[$ELSE]]
* [[$ELSEIF]]
* [[$END IF]]
{{PageNavigation}}

21
internal/help/$RESIZE.txt Normal file
View file

@ -0,0 +1,21 @@
The '''$RESIZE''' metacommand determines if a program window can be resized by the user in '''QB64 GL''' only.
{{PageSyntax}}
::: '''$RESIZE:'''{ON|OFF|STRETCH|SMOOTH}
* $RESIZE:ON is used to allow the program window to be resized by a program user. Otherwise it cannot be changed.
* $RESIZE:OFF (default) is used when the program's window size cannot be changed by the user.
* $RESIZE:STRETCH the screen will be stretched to fit the new window size with a 1 to 1 ratio of width and height.
* $RESIZE:SMOOTH the screen will be stretched also, but with linear filtering applied to the pixels.
* '''QB64 GL''' programs only. Not available in QB64 SDL versions .954 and older.
''See also:''
* [[_RESIZE]], [[_RESIZE (function)]]
* [[_RESIZEWIDTH]], [[_RESIZEHEIGHT]] {{text|(functions return the requested dimensions)}}
{{PageNavigation}}

View file

@ -0,0 +1,28 @@
{{DISPLAYTITLE:$VIRTUALKEYBOARD}}
The '''$VIRTUALKEYBOARD''' QB64 GL Metacommand turns the virtual keyboard ON or OFF in Android device programs.
{{PageSyntax}}
::: '''$VIRTUALKEYBOARD:'''{ON|OFF}
{{PageDescription}}
* If you haven't got an Android device and just want to try out the virtual keyboard add the following meta-command: $VIRTUALKEYBOARD:ON
{{PageErrors}}
''Example:''
{{CodeStart}}
{{Cl|$VIRTUALKEYBOARD}}:ON
{{Cl|DO}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) '' ''
{{CodeEnd}}
{{PageSeeAlso}}
{{PageNavigation}}

View file

@ -2,7 +2,7 @@ The '''&B''' prefix denotes that an integer value is expressed in a binary b
{{PageSyntax}}
:::: a& = &B1110110000111111
:::: a& = '''&B1110110000111111'''
* The base 2 numbering system uses binary digit values of 1 or 0, or bits on or bits off in computer register switches or memory.

View file

@ -18,6 +18,7 @@ The '''&H''' prefix denotes that an integer value is expressed in a Hexadeci
* [[LONG]] 32 bit [[_RGB]] values can be made using hexadecimal values from '''&HFF{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}''' with full [[_ALPHA]] only.
* [[LONG]] 32 bit [[_RGBA]] values can be made using hexadecimal values from '''&H00{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}''' with any [[_ALPHA]].
* Hexadecimal '''0x''' is often used to prefix [[HEX$]] port addresses in documentation. Replace 0x with [[&H]] in QB64 or QBasic.
* To convert hex strings returned from [[HEX$]] with [[VAL]] you need to prefix the string with &H (for example; if the string is "FF" you should do VAL("&HFF") or VAL("&H" + hexvalue$).
''Example 1:'' The maximum octal values of decimal value -1 in each numerical type are:

View file

@ -1,14 +1,21 @@
The '''ALIAS''' clause in the {{KW|DECLARE (non-BASIC statement)|DECLARE}} statement tells the program that you will use a different name than that in the library. This only applies when declaring non-BASIC procedures.
The '''ALIAS''' clause in a [[DECLARE LIBRARY]] statement block tells the program the name of the procedure used in the external library.
{{PageSyntax}}
::: SUB ''pseudoname'' '''ALIAS ''actualname''''' [(''parameters'')]
::: SUB ''pseudoname'' '''ALIAS''' ''actualname'' [(''parameters'')]
{{Parameters}}
* The ''actual name'' is the same procedure name as it is inside of the library.
* The name does not have to be inside of quotes when using [[DECLARE LIBRARY]].
* [[Keywords currently not supported by QB64|QB64 supports ALIAS in DECLARE LIBRARY procedures only!]]
* The ''pseudo name'' is the name of the [[SUB]] or [[FUNCTION]] the QB64 program will use.
* The ''actual name'' is the same procedure name as it is inside of the DLL library.
* QB64 must use all parameters of imported procedures including optional ones.
''Description:''
* The ALIAS name clause is optional as the original library procedure name can be used.
* The procedure name does not have to be inside of quotes when using [[DECLARE LIBRARY]].
* QB64 does not support creating optional parameters at this time.
* In Qbasic ALIAS was originally only used in a [[DECLARE (non-BASIC statement)]] library declarations.
''Example:'' Instead of creating a SUB with the Library statement inside of it, just rename it:
@ -21,12 +28,10 @@ The '''ALIAS''' clause in the {{KW|DECLARE (non-BASIC statement)|DECLARE}} state
{{PageSeeAlso}}
* [[SUB]], [[FUNCTION]]
* [[DECLARE LIBRARY]], [[BYVAL]]
* [[DECLARE DYNAMIC LIBRARY]]
* [[DECLARE (non-BASIC statement)]]
{{PageNavigation}}

View file

@ -3,7 +3,7 @@ The [[AND (boolean)|AND]] conditonal operator is used to include another evaluat
{{PageSyntax}}
::: IF '''{{Parameter|condition}} AND {{Parameter|condition2}}'''
::: IF {{Parameter|condition}} '''AND''' {{Parameter|condition2}}
{{PageDescription}}
@ -11,7 +11,9 @@ The [[AND (boolean)|AND]] conditonal operator is used to include another evaluat
* {{Parameter|condition}} and {{Parameter|condition2}} can also contain their own AND evaluations.
* Both the IF evaluation and the AND evaluation must be True for the statement to be True.
* Statements can use parenthesis to clarify an evaluation.
* Can be confused with the [[AND]] numerical operator.
* [[AND]] and '''OR''' cannot be used to combine command line operations.
* '''A double AND syntax error may be ignored and create a QB64 compiler error!'''
* Not to be confused with the [[AND]] and [[OR]] numerical operations.
{{Template:RelationalTable}}
@ -52,7 +54,6 @@ True
''Explanation:'' The evaluations in the paranteses are evaluated first then the evaluation ''of'' the paranteses takes place, since all evaluations return True the IF...THEN evaluation returns True. If any of the evaluations returned False then the IF...THEN evaluation would also return False.
{{PageSeeAlso}}
* [[OR (boolean)]], [[XOR (boolean)]]
* [[IF...THEN]]

View file

@ -2,15 +2,22 @@ The '''ASC''' function returns the {{KW|ASCII}} code number of a certain {{KW|ST
{{PageSyntax}}
:: code% = '''ASC(''text$'''''[, ''position'']''')'''
:: code% = '''ASC('''''text$''[, ''position%'']''')'''
* String ''text'' [[STRING|string]] character parameter must have a length of at least 1 byte or an error occurs.
* '''In QB64''' a new ''position'' parameter is allowed. The ASCII code of the character in a string position specified will be returned by the function (if omitted ASC will return the code of the first character).
* If the string used with ASC has more than one character, the first byte character code is returned.
* [[ASCII]] code [[INTEGER]] values returned will range from 0 to 255 only.
* If the function is used to read an empty string value an [[ERROR Codes|error]] will occur! [[INKEY$]] returns an empty string when a key is not pressed.
* ASC returns 0 when reading 2 byte codes returned by [[INKEY$]] when the arrow, F function, Home\Page keys are used. Use QB64's position parameter to read the second byte.
* '''In QB64''' an optional byte ''position'' [[INTEGER]] parameter greater than 0 can specify the ASCII code of any character in a string to be returned.
* If the optional position parameter is omitted, ASC will return the [[ASCII]] code of the '''first''' [[STRING]] character only.
* [[ASCII]] code [[INTEGER]] or [[_UNSIGNED]] [[_BYTE]] values returned will range from 0 to 255 only.
* ASC returns 0 when reading [[ASCII]] 2 byte codes returned by [[INKEY$]] when the arrow, F function, Home\Page keys are used.
:: Use QB64's position parameter to read the second byte if necessary. {{Text|IF ASC(key$) <nowiki>=</nowiki> 0 THEN byte2 <nowiki>=</nowiki> ASC(key$, 2)|green}}
* In '''QB64''' ASC string byte position reads are about '''5 times faster''' than [[MID$]] when parsing strings. See [[MID$]] ''Example 2''.
{{PageErrors}}
* If the function is used to read an '''empty string value''' an illegal function call [[ERROR Codes|error]] will occur! [[INKEY$]] returns an empty string when a key is not pressed.
* '''QB64''' ''position'' parameters must range from 1 to the [[LEN|length]] of the string being read or an illegal function call [[ERROR Codes|error]] will occur.
{{WhiteStart}}' '''ASCII Keyboard Codes'''
'
@ -152,7 +159,7 @@ DO
''See also:''
* [[ASC (statement)]] {{text|(QB64 only)}}
* [[_KEYHIT]], [[_KEYDOWN]]
* [[CHR$]], [[INKEY$]]
* [[MID$]], [[CHR$]], [[INKEY$]]
* [[VAL]], [[STRING$]]
* [[ASCII]], [[_MAPUNICODE]]
* [[Scancodes]]

View file

@ -5,9 +5,14 @@ The {{KW|ATN}} or arctangent function returns the angle in radians of a numerica
:: radian_angle = '''ATN(''tangent!'')'''
{{Parameters}}
* The return is that tangent value's ''angle'' in radians.
* ''tangent'' [[SINGLE]] or [[DOUBLE]] values are use by the function. EX:'''{{text|Pi <nowiki>=</nowiki> 4 * ATN(1)|green}}'''
{{PageDescription}}
* The [[SINGLE]] or [[DOUBLE]] ''tangent'' value would be equal to the tangent value of an angle. EX: [[TAN]](ATN(1)) = 1
* The return is that tangent value's ''angle'' in radians. To convert from radians to degrees, multiply radians * (180 / π).
* To convert from radians to degrees, multiply radians * (180 / π).
* The ''tangent'' value would be equal to the tangent value of an angle. EX: '''{{text|[[TAN]](ATN(1)) <nowiki>=</nowiki> 1|green}}'''
* The function return value is between -π / 2 and π / 2.
@ -28,8 +33,51 @@ PRINT Pi, Pi# '' ''
{{CodeEnd}}
''Example 3:'' Finds the angle from the center point to the mouse pointer.
{{CodeStart}} '' ''
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
x1! = 320
y1! = 240
DO
{{Cl|PRESET}} (x1!, y1!), {{Cl|_RGB}}(255, 255, 255)
dummy% = {{Cl|_MOUSEINPUT}}
x2! = {{Cl|_MOUSEX}}
y2! = {{Cl|_MOUSEY}}
{{Cl|LINE}} (x1, y1)-(x2, y2), {{Cl|_RGB}}(255, 0, 0)
{{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} getangle(x1!, y1!, x2!, y2!)
{{Cl|_DISPLAY}}
{{Cl|_LIMIT}} 200
{{Cl|CLS}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> ""
{{Cl|END}}
{{Cl|FUNCTION}} getangle# (x1#, y1#, x2#, y2#) 'returns 0-359.99...
{{Cl|IF...THEN|IF}} y2# = y1# {{Cl|THEN}}
{{Cl|IF...THEN|IF}} x1# = x2# {{Cl|THEN}} {{Cl|EXIT FUNCTION}}
{{Cl|IF...THEN|IF}} x2# > x1# {{Cl|THEN}} getangle# = 90 {{Cl|ELSE}} getangle# = 270
{{Cl|EXIT FUNCTION}}
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} x2# = x1# {{Cl|THEN}}
{{Cl|IF...THEN|IF}} y2# > y1# {{Cl|THEN}} getangle# = 180
{{Cl|EXIT FUNCTION}}
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} y2# < y1# {{Cl|THEN}}
{{Cl|IF...THEN|IF}} x2# > x1# {{Cl|THEN}}
getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131
{{Cl|ELSE}}
getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131 + 360
{{Cl|END IF}}
{{Cl|ELSE}}
getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131 + 180
{{Cl|END IF}}
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}{{small|Function by Galleon}}
{{PageSeeAlso}}
* [[TAN]] {{text|(tangent)}}
* [[_PI]] {{text|(QB64 function)}}
* [[TAN]] {{text|(tangent function)}}
* [[SIN]], [[COS]]
* [[Mathematical Operations]]
* [[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]]

View file

@ -6,10 +6,11 @@
{{PageDescription}}
* BINARY creates the file if the filename$ does not exist.
* [[OPEN]] FOR BINARY creates the file if the filename$ does not exist.
* {{Parameter|filename$}} is the name of the file to open, but could also configure a port.
* {{Parameter|#filenumber%}} is the number that will represent the file when performing file operations.
* BINARY files use [[GET]] and [[PUT]] to read or write the file at any byte position.
* BINARY files use [[GET|GET #]] and [[PUT|PUT #]] to read or write the file at any byte position.
* '''QB64-GL''' allows [[LINE INPUT]] to be used for faster access to text file data.
* The number of bytes read or written depends on the byte [[LEN|length]] of the variable type used.
* When [[PUT]] is used with a variable, numerical values are converted to [[ASCII]] string types [[MKI$]], [[MKL$]], [[MKS$]], [[MKD$]] or [[_MK$]].
* One byte [[ASCII]] {{KW|STRING}} data character values can be read as number values using {{KW|ASC}}(values from 0 to 255).
@ -74,11 +75,11 @@ DO: {{Cl|_LIMIT}} 100
{{PageSeeAlso}}
* {{KW|CLOSE}}
* {{KW|GET}}, {{KW|PUT}}
* {{KW|SEEK}} (function), {{KW|SEEK (statement)}}
* {{KW|RANDOM}}, {{KW|INPUT (file mode)}}, {{KW|APPEND}}, {{KW|OUTPUT}}
* {{KW|Bitmaps}}, {{KW|Binary}}(numbers)
* [[OPEN]], [[CLOSE]]
* [[GET]], [[PUT]], [[LINE INPUT]]
* [[SEEK]] (function), [[SEEK (statement)]]
* [[INPUT (file mode)]], [[RANDOM]], [[APPEND]], [[OUTPUT]]
* [[Bitmaps]], [[Binary]] (numbers)
{{PageNavigation}}

View file

@ -2,21 +2,24 @@
{{PageSyntax}}
::: '''BLOAD {{Parameter|Filename$}}, {{KW|VARPTR}}({{Parameter|ImageArray%(index)}})'''
::: '''BLOAD''' {{Parameter|Filename$}}''', [[VARPTR]]('''{{Parameter|ImageArray%(index)}}''')'''
{{Parameters}}
* {{Parameter|Filename$}} is the name of the file that the image should be [[BSAVE]]d to.
* {{Parameter|ImageArray%(index)}} is the Integer [[arrays|array]] start index that holds the image you want to save.
{{PageDescription}}
* {{Parameter|Filename$}} is the name of the file that the image should be saved to.
* {{Parameter|ImageArray%(index)}} is the Integer array that holds the image you want to save.
* There MUST be an Integer array of adequate size (up to 26K) to hold the graphic data!
* A {{KW|DEF SEG}} pointing to the array is required. {{KW|DEF SEG}} = {{KW|VARSEG}}(ImageArray%(index))
* A [[DEF SEG]] pointing to the array is required. [[DEF SEG]] = [[VARSEG]](ImageArray%(index))
* {{Parameter|index}} is the starting image element of the Array. Can also include RGB color settings at the start index.
* Fullscreen images in {{KW|SCREEN}} 12 require 3 file {{KW|BLOAD}}s. A 26K array can hold 1/3 of screen.
* Fullscreen images in [[SCREEN]] 12 require 3 file BLOADs. A 26K array can hold 1/3 of screen.
* Custom RGB color settings can be embedded(indexed) at the start of the image array.
* {{KW|BLOAD}} Can be used to load any arrays that was saved with {{KW|BSAVE}}, not just graphics.
* Array sizes are limited to 32767 Integer elements due to use of {{KW|VARPTR}} in QB and '''QB64'''!.
* '''QB64''' can load larger arrays directly to and from binary files using {{KW|PUT}} # and {{KW|GET}} #.
* BLOAD can be used to load any array that was saved with [[BSAVE]], not just graphics.
* Array sizes are limited to 32767 Integer elements due to use of [[VARPTR]] in QB and '''QB64'''!.
* '''QB64''' can load larger arrays directly to and from binary files using [[PUT]] # and [[GET]] # without BLOAD.
''Example 1:'' Loading data to an array from a BSAVED file.

View file

@ -1,21 +1,25 @@
{{KW|BSAVE}} saves the contents of an image array to a {{KW|BINARY}} file.
[[BSAVE]] saves the contents of an image array to a {{KW|BINARY}} file.
{{PageSyntax}}
::: '''BSAVE}} {{Parameter|savefile$}}, [[VARPTR]]({{Parameter|Array(index)}}), {{Parameter|Filesize&}}'''
::: '''BSAVE''' {{Parameter|savefile$}}''', [[VARPTR]]'''({{Parameter|Array(index)}})''',''' {{Parameter|Filesize&}}
{{Parameters}}
* ''savefile$'' is the STRING file name of the file designated to be created.
* ''Array(index)'' is the image [[arrays|array]] that already holds the [[GET (graphics statement)|GET]] image data.
* ''Filesize'' must be a bit over twice the size of the elements used in an {{KW|INTEGER}} [[Arrays|array]].
{{PageDescription}}
* To place image data into the array, use {{KW|GET (graphics statement)|GET}} to store a box area image of the screen.
* {{KW|SCREEN}} 12 can only GET 1/3 of the screen image at one time using a 26K array.
* Image arrays are {{KW|DIM}}ensioned as {{KW|INTEGER}}. Use {{KW|DEFINT}} when working with large graphic arrays.
* To place image data into the array, use [[GET (graphics statement)|GET]] to store a box area image of the screen.
* [[SCREEN]] 12 can only GET 1/3 of the screen image at one time using a 26K array.
* Image arrays are [[DIM]]ensioned as [[INTEGER]]. Use [[DEFINT]] when working with large graphic arrays.
* Any arrays can be saved, but Image arrays are most common.
* {{KW|DEF SEG}} = {{KW|VARSEG}} must be used to designate the array segment position in memory.
* {{KW|VARPTR}} returns the Array index offset of the memory segment. Array sizes are limited to 32767 Integer elements due to the use of {{KW|VARPTR}} in QB and '''QB64'''!.
* '''QB64''' can load larger arrays directly to and from binary files using {{KW|PUT}} # and {{KW|GET}} #.
* Filesize must be twice the size of the elements used in an {{KW|INTEGER}} [[Arrays|array]].
* {{KW|BSAVE}} files can later be opened with {{KW|BLOAD}}.
* [[DEF SEG]] = [[VARSEG]] must be used to designate the array segment position in memory.
* [[VARPTR]] returns the Array index offset of the memory segment. Array sizes are limited to 32767 Integer elements due to the use of [[VARPTR]] in QB and '''QB64'''!.
* '''QB64''' can load larger arrays directly to and from binary files using [[PUT]] # and [[GET]] # without BSAVE.
* [[BSAVE]] files can later be opened with {{KW|BLOAD}}.
''Example 1:'' Saving array data to a file quickly.
@ -47,9 +51,9 @@
{{PageSeeAlso}}
* [[GET (graphics statement)]], [[PUT (graphics statement)]]
* [[BLOAD]], [[OPEN]], [[BINARY]]
* [[GET]], [[PUT]] {{text|(file statements)}}
* [[GET (graphics statement)]], [[PUT (graphics statement)]]
* [[VARSEG]], [[VARPTR]]
* [[DEF SEG]], [[TYPE]]
* [[Text Using Graphics]]

View file

@ -1,28 +1,44 @@
The '''BYVAL''' statement is used to pass a parameter's value with {{KW|SUB}} programs made in other programming languages.
The '''BYVAL''' statement is used to pass a numerical parameter's value with procedures made in other programming languages.
{{PageSyntax}}
:: Procedure_Name ('''BYVAL''' ''variable1'', '''BYVAL''' ''variable2'')
:: SUB Procedure_Name ('''BYVAL''' ''variable1'', '''BYVAL''' ''variable2'')
{{PageDescription}}
* QB64 supports keyword only with [[DECLARE LIBRARY]] [[SUB]] and [[FUNCTION]] procedure declarations.
* Passing by value assures that the original variable value is not changed by another procedure.
* '''QB64''' can use BYVAL in [[DECLARE LIBRARY]] procedures that add SDL libraries or DLL functions.
* Use [[parenthesis]] around [[SUB]] or [[FUNCTION]] parameters passed BY VALUE in Qbasic or QB64. Ex: ''CALL Procedure ((x&), (y&))''
* Qbasic versions below 7 do not use {{KW|BYVAL}} unless the {{KW|SUB}} program referred to is from a different programming language.
* PDS versions can use {{KW|BYVAL}} as it is intended in any {{KW|SUB}} or {{KW|FUNCTION}} parameters.
*'''BYVAL''' can also be used with [[ABSOLUTE]] in Qbasic but not in QB64 currently.
* '''NOTE: Many Qbasic keyword variable names CAN be used with a [[STRING]] suffix($) ONLY! You CANNOT use them without the suffix, use a numerical suffix or use [[DIM]], [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements!'''
* '''QB64''' can only use BYVAL in [[DECLARE LIBRARY]] procedures that add DLL or Operating System API functions.
* Supported with [[DECLARE LIBRARY]] [[SUB]] and [[FUNCTION]] procedure declarations when passing '''numerical values only'''.
* Passing numerical values BYVAL assures that the original numerical variable value is not changed by another procedure.
* Use [[parenthesis]] around program [[SUB]] or [[FUNCTION]] parameters passed BY VALUE. Ex: ''CALL Procedure ((x&), (y&))''
''Example:'' Passing parameters "by value" using [[parenthesis|brackets]] when calling a [[SUB]] or [[FUNCTION]] in Qbasic or QB64.
''Historical:''
* Qbasic versions below 7 do not use BYVAL unless the [[SUB]] program referred to is from a different programming language.
* PDS versions can use BYVAL as it is intended in any [[SUB]] or [[FUNCTION]] parameters.
* BYVAL can also be used with [[ABSOLUTE]] in Qbasic only.
{{PageErrors}}
* '''Do not use BYVAL before [[STRING]] or [[TYPE]] variables or in regular prograam [[SUB]] or [[FUNCTION]] parameters!'''
* '''Many Qbasic keyword variable names CAN be used with a [[STRING]] suffix($) ONLY! You CANNOT use them without the suffix, use a numerical suffix or use [[DIM]], [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements!'''
''Example 1:'' BYVAL is used to preserve the values sent to an external procedure so they remain the same after they are used:
{{CodeStart}} '' ''
{{Cl|CALL}} MySUB (a%, (b%), (c%)) 'CALL SUB
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} xoffset&, {{Cl|BYVAL}} yoffset&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{CodeEnd}}
: ''Note:'' Since the DLL library was already used by QB64 SDL(up to v.954), it did not require a DLL name. GL would!
MySUB a%, b%, (c%) 'call SUB again without CALL
''Example 2:'' Passing parameters "by value" using [[parenthesis|brackets]] when calling a [[SUB]] or [[FUNCTION]] in Qbasic or QB64.
{{CodeStart}} '' ''
{{Cl|CALL}} MySUB (a%, (b%), (c%)) 'CALL SUB b and c stay 0 after sub
MySUB a%, b%, (c%) 'call SUB again without CALL only c stays 0 after sub
{{Cl|PRINT}} "Outside procedure: "; a%, b%, c%
{{Cl|PRINT}} "After procedures: "; a%, b%, c%
{{Cl|SUB}} MySUB (a%, b%, c%)
a% = a% + 1: b% = b% + 1: c% = c% + 1
@ -32,7 +48,7 @@ a% = a% + 1: b% = b% + 1: c% = c% + 1
{{OutputStart}}
Inside procedure: 1 1 1
Inside procedure: 2 1 1
Outside procedure: 2 1 0
After procedures: 2 1 0
{{OutputEnd}}
:''Explanation:'' Both SUB calls pass just the '''values''' of b% and c% to the procedure. The first variable, a%, is passed by '''reference''' (the default) so the value was changed by the SUB procedure. Brackets can only be used in the [[CALL]] or function reference!
@ -40,8 +56,8 @@ Outside procedure: 2 1 0
{{PageSeeAlso}}
* [[DECLARE LIBRARY]]
* [[SUB]], [[FUNCTION]]
* [[DECLARE]], [[DECLARE (non-BASIC statement)]]
* [[CALL]]
* [[CALL]], [[ALIAS]]
* [[DECLARE]], [[DECLARE (non-BASIC statement)]] {{text|(not used by QB64)}}
* [[Libraries#C++_Variable_Types|C++ Variable Types]]

View file

@ -19,40 +19,41 @@
* Qbasic requires [[CALL ABSOLUTE]] only. It does not have to be [[DECLARE]]d.
''Example:''
''Example:'' How parameters are passed in two [[SUB]] calls, one with CALL using brackets and one without CALL or brackets:
{{CodeStart}} '' ''
{{Cl|DIM}} a {{Cl|AS}} {{Cl|INTEGER}}
{{Cl|DIM}} {{Cl|SHARED}} b {{Cl|AS}} {{Cl|INTEGER}}
{{Cl|DIM}} a {{Cl|AS}} {{Cl|INTEGER}} 'value not shared with SUB
{{Cl|DIM}} {{Cl|SHARED}} b {{Cl|AS}} {{Cl|INTEGER}} 'value shared with any SUB
a = 1
b = 1
{{Cl|CALL}} helloworld
{{Cl|CALL}} helloworld
b = 2
c = 3
{{Cl|SUB}} helloworld
{{Cl|CALL}} helloworld (a) 'a passed to c parameter with CALL
helloworld a 'a passed to c parameter w/o CALL
{{Cl|END}}
{{Cl|SUB}} helloworld (c) 'SUB parameter variables are always inside of brackets in SUB code
{{Cl|PRINT}} "Hello World!"
{{Cl|PRINT}} a
{{Cl|PRINT}} b
a = a + 1
b = b + 1
{{Cl|PRINT}} a, b, c
a = a + 1 'a is a SUB value of 0 when printed which may increase inside SUB only
b = b + 1 'b is a shared value which can increase anywhere
c = c + 1 'c is a SUB parameter value from a in calls which may increase inside SUB only
{{Cl|END SUB}} '' ''
{{CodeEnd}}
''Returns:''
{{OutputStart}}Hello World!
0
1
0 2 1
Hello World!
0
2 {{OutputEnd}}
: ''Explanation:'' When the subroutine is [[CALL]]ed the code inside the subroutine is executed until it reaches the [[END SUB]] statement or an [[EXIT SUB]] statement. Since the variable {{Parameter|a}} that is outside of the subroutine isn't [[SHARED]] it will have no effect in the subroutine, the variable {{Parameter|a}} inside the subroutine is only valid inside the subroutine, and whatever value {{Parameter|a}} has outside of it makes no difference within the subroutine.
0 3 1
{{OutputEnd}}
: ''Explanation:'' Variable '''{{Parameter|a}}''' that is outside of the subroutine isn't [[SHARED]] so it will have no effect inside the subroutine, the variable {{Parameter|a}} inside the subroutine is only valid inside the subroutine, and whatever value {{Parameter|a}} has outside of it makes no difference within the subroutine.
:The variable {{Parameter|b}} on the other hand is [[SHARED]] with the subroutines and thus can be changed in the subroutine. The variable {{Parameter|a}} is initiated with 0 as default when created, thus it will return 0 since it wasn't changed within the subroutine.
:The variable '''{{Parameter|b}}''' on the other hand is [[SHARED]] with the subroutines and thus can be changed in the subroutine. The variable {{Parameter|a}} is initiated with 0 as default when created, thus it will return 0 since it wasn't changed within the subroutine.
:''Note:'' CALL doesn't need to be used in order to call a subroutine. Adding the name of the sub to the code like this will do:
:The variable '''{{Parameter|c}}''' is the [[SUB]] parameter variable that passes values into the sub. Its value could be changed by the passed parameter value or inside of the subroutine. The un-shared '''{{Parameter|c}}''' variable value outside of the sub is irrelevant within the subroutine.
::::::'''{{text|helloworld|green}}'''
: Also; note that the variable {{Parameter|a}} outside of the subroutine is different from the variable {{Parameter|a}} inside the subroutine since {{Parameter|a}} isn't {{KW|SHARED}} through subroutines, variable {{Parameter|b}} on the other hand is {{KW|SHARED}} through subroutines and thus is the same within the subroutine as outside of it.
:''Note:'' CALL doesn't need to be used in order to call a subroutine. Just using the name of the sub with parameters and no brackets will do: '''{{text|helloworld a|green}}'''
{{PageSeeAlso}}

View file

@ -14,13 +14,8 @@
* '''NOTE: QB64 does not currently support INT 33h mouse functions above 3 or {{KW|BYVAL}} in an ABSOLUTE statement!'''
{{PageExamples}}
:::''Typical ABSOLUTE mouse program demonstrates the AX% mouse functions:''
::: (Copy only the code not marked as Demo Code to use it in your program.)
:::::''Can also be used in QuickBASIC 4.x and QBasic 1.x''
''Example 1:'' Typical ABSOLUTE mouse program demonstrates the AX% mouse functions in QuickBASIC 4.x and QBasic 1.x:
{{CodeStart}}
{{Cl|DECLARE}} {{Cl|SUB}} MouseDriver (AX%, BX%, CX%, DX%, LB%, RB%, EX%)
{{Cl|DIM}} {{Cl|SHARED}} mouse$ ' Hardware communications resource string (created in SUB MouseDriver)
{{Cl|DIM}} {{Cl|SHARED}} CX%, DX%, LB%, RB% ' CX = column, DX = row, LB and RB are left and right buttons
@ -155,8 +150,7 @@ MouseData:
''Explanation:'' The circle isn't shown in this output screen, but when you run the example you can move the mouse into a circle in the middle of the screen and the text will change color to reflect that you are inside the circle, you can also use the mousebuttons and the color will change.
:::::---------------------------------------------------------------------
<center>'''An Absolute substitution for INTERRUPT that can be used by all QB versions including PDS(7.1)'''</center>
''Example 2:'' An Absolute substitution for INTERRUPT that can be used by all QB versions including PDS(7.1):
{{CodeStart}}

View file

@ -3,35 +3,31 @@
{{PageSyntax}}
:{{KW|CDBL}}({{Parameter|n}})
:: doublevalue = '''CDBL('''''expression''''')'''
* Rounds to the closest {{KW|DOUBLE}}-precision decimal point value.
* Also can be used to define a value as {{KW|DOUBLE}}-precision.
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Rounds to the closest [[DOUBLE]] floating decimal point value.
* Also can be used to define a value as {{KW|DOUBLE}}-precision up to 15 decimals.
''Example:''
''Example:'' Prints a double-precision version of the single-precision value stored in the variable named A.
{{CodeStart}}
A = 454.67
{{Cl|PRINT}} A; {{Cl|CDBL}}(A)
{{CodeEnd}}
{{OutputStart}}
454.67 454.6700134277344
{{OutputStart}} 454.67 454.6700134277344
{{OutputEnd}}
:Prints a double-precision version of the single-precision value stored in the variable named A. The last 11 numbers in the double-precision number change the value in this example, since A was previously defined to only two-decimal place accuracy.
: The last 11 numbers in the double-precision number change the value in this example, since A was previously defined to only two-decimal place accuracy.
{{PageSeeAlso}}
*{{KW|CINT}}, {{KW|CLNG}}, {{KW|CSNG}}, {{KW|_ROUND}}
* [[CINT]], [[CLNG]]
* [[CSNG]], [[_ROUND]]
{{PageNavigation}}

View file

@ -19,7 +19,7 @@
* Module screen modes will not change unless that is desired. '''QB64 currently does not retain the [[SCREEN]] mode!'''
* Use when modules are too large to compile(Over 100K approx.). Split the modules up. NOT necessary with '''QB64'''!
* Variable data can be passed in files instead of using [[COMMON SHARED]] values. '''QB64''' uses files to pass [[COMMON]] lists.
* '''NOTE: [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not currently available in Linux or Mac operating systems!]]'''
* '''NOTE: CHAIN is no longer required using QB64 as it can run larger modules: [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not currently available in Linux or Mac operating systems!]]'''
''Example:'' CHAIN looks for same file type extension as program module (BAS or EXE) in QB 4.5.

35
internal/help/CINT.txt Normal file
View file

@ -0,0 +1,35 @@
The {{KW|CINT}} function rounds decimal point numbers up or down to the nearest {{KW|INTEGER}} value.
{{PageSyntax}}
:: value = '''CINT('''''expression''''')'''
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Values greater than .5 are rounded up. Values lower than .5 are rounded down just like "bankers rounding".
* Half(.5) [[SINGLE]] values are rounded to the nearest EVEN integer value whether it is up or down.
* ''Warning:'' Since {{KW|CINT}} is used for integer values, the input values cannot exceed 32767 to -32768!
* Use {{KW|CLNG}} for {{KW|LONG}} integer values exceeding Integer limitations.
* Note: When decimal point values are given to Basic functions requiring [[INTEGER]]s the value will be CINTed.
''Example:'' Shows how CINT rounds values up or down as in bankers rounding.
{{CodeStart}} '' ''
a% = {{Cl|CINT}}(1.49): b% = {{Cl|CINT}}(1.50): c = 11.5
{{Cl|COLOR}} c: {{Cl|PRINT}} a%, b%, c '' ''
{{CodeEnd}}
{{OutputStart}}{{text|1 2 11.5|red}}
{{OutputEnd}}
:''Note:'' Qbasic functions requiring [[INTEGER]] values such as text or graphic coordinates and {{KW|COLOR}} will be rounded like {{KW|CINT}}. Half values are rounded to the nearest even integer value.
{{PageSeeAlso}}
* {{KW|CLNG}}, {{KW|CSNG}}, {{KW|CDBL}}
* {{KW|INT}}, {{KW|FIX}}, {{KW|_ROUND}}
{{PageNavigation}}

View file

@ -3,7 +3,7 @@ The {{KW|CIRCLE}} statement is used in graphics {{KW|SCREEN (statement)|SCREEN}}
{{PageSyntax}}
: '''CIRCLE''' [{{KW|STEP}}]'''({{Parameter|Column}}, {{Parameter|Row}}), {{Parameter|radius%}}[, {{Parameter|colour%}}][,''' {{Parameter|startRadian!}}, {{Parameter|stopRadian!}}] [, {{Parameter|aspect!}}]
: '''CIRCLE''' [{{KW|STEP}}]'''('''{{Parameter|Column}}''',''' {{Parameter|Row}}'''),''' {{Parameter|radius%}}''',''' [{{Parameter|colour%}}][, {{Parameter|startRadian!}}, {{Parameter|stopRadian!}}] [, {{Parameter|aspect!}}]
{{Parameters}}
@ -20,10 +20,103 @@ The {{KW|CIRCLE}} statement is used in graphics {{KW|SCREEN (statement)|SCREEN}}
* Radians move in a counter clockwise direction from 0 to 2 * Pi. Zero and 2 * Pi are the same circle radian at 3 o'clock.
* Negative radian values can be used to draw lines from the end of an arc or partial ellipse to the circle center.
* Commas after the {{Parameter|colour%}} parameter are not required when creating a normal circle. Color can also be omitted.
* The QB64 and QB graphic cursor is set to the center of the program window on program start.
* '''CIRCLE can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only!'''
''Example:'' Program illustrates how the CIRCLE command using a negative radian value can be used to create the hands of a clock.
<center>'''Circle.BI Include file or [[SUB]] to use when using [[PAINT]] with pie charts or arc slices:'''</center>
{{TextStart}} 'CIRCLE.BI
'**
'** QB64 temporary replacement CIRCLE command.
'**
'** The CIRCLE command in QB64 has a few bugs listed below:
'**
'** - radian end points are not calculate properly when creating arcs
'** - center line to radian end points do not close properly due to previous bug listed
'**
'** This circle command replacement works very similiarly to the native CIRCLE command:
'**
'** SYNTAX: CIRCLES x%, y%, radius!, color~&, start_radian!, end_radian!, aspect_ratio!
'**
'** x% - center X coordinate of circle
'** y% - center Y coordinate of circle
'** radius! - the radius of the circle
'** color~& - the circle's color
'** start_radian! - the radian on circle curcunference to begin drawing at
'** end_radian! - the radian on circle circumference to end drawing at
'** aspect_ratio! - the aspect ratio of the circle
'**
'** '''NOTE: unlike the native CIRCLE command, all arguments MUST be supplied.''' For example,
'** with the native command this will draw a perfect circle with the default color,
'** start radian, end radian and aspect ratio:
'**
'** CIRCLE (319, 239), 100
'**
'** To do the same thing with this replacement command you must supply everything:
'**
'** CIRCLES 319, 239, 100, _RGB32(255, 255, 255), 0, 0, 0
'**
'** ACKNOWLEGEMENTS: The FOR/NEXT step formula was was written by Codeguy for Unseen
'** Machine's Visual library EllipseXS command. Specifically:
'** MinStep! = 1 / (2 * 3.1415926535 * Radius!)
'**
'**
'** Includes performance tweaks made by SMcNeill on 02/02/13 - specifically removing a few redundant * -1
'** statements and converting the FOR/NEXT loop to a DO loop for a ~3% increase in performance.
'**
'** Corrected bug in which variables being passed in were being modified and passed back - 02/02/13
'**
'''SUB CIRCLES (cx%, cy%, r!, c~&, s!, e!, a!)'''
DIM s%, e%, nx%, ny%, xr!, yr!, st!, en!, asp! ' local variables used
st! = s! ' copy start radian to local variable
en! = e! ' copy end radian to local variable
asp! = a! ' copy aspect ratio to local variable
IF asp! <= 0 THEN asp! = 1 ' keep aspect ratio between 0 and 4
IF asp! > 4 THEN asp! = 4
IF asp! < 1 THEN xr! = r! * asp! * 4 ELSE xr! = r! ' calculate x/y radius based on aspect ratio
IF asp! > 1 THEN yr! = r! * asp! ELSE yr! = r!
IF st! < 0 THEN s% = -1: st! = -st! ' remember if line needs drawn from center to start radian
IF en! < 0 THEN e% = -1: en! = -en! ' remember if line needs drawn from center to end radian
IF s% THEN ' draw line from center to start radian?
nx% = cx% + xr! * COS(st!) ' yes, compute starting point on circle's circumference
ny% = cy% + yr! * -SIN(st!)
LINE (cx%, cy%)-(nx%, ny%), c~& ' draw line from center to radian
END IF
IF en! <= st! THEN en! = en! + 6.2831852 ' come back around to proper location (draw counterclockwise)
stepp! = 0.159154945806 / r!
c! = st! ' cycle from start radian to end radian
DO
nx% = cx% + xr! * COS(c!) ' compute next point on circle's circumfrerence
ny% = cy% + yr! * -SIN(c!)
PSET (nx%, ny%), c~& ' draw the point
c! = c! + stepp!
LOOP UNTIL c! >= en!
IF e% THEN LINE -(cx%, cy%), c~& ' draw line from center to end radian if needed
'''END SUB'''
{{TextEnd}}
''Example 1:'' Finding when the mouse is inside of a circular area:
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
r& = 200 'radius change circle size and position here
cx& = 320 'center x horizontal
cy& = 240 'center y vertical
DO
i = {{Cl|_MOUSEINPUT}}
x& = {{Cl|_MOUSEX}}
y& = {{Cl|_MOUSEY}}
xy& = ((x& - cx&) ^ 2) + ((y& - cy&) ^ 2) 'Pythagorean theorem
{{Cl|IF...THEN|IF}} r& ^ 2 >= xy& {{Cl|THEN}} {{Cl|CIRCLE}} (cx&, cy&), r&, 10 {{Cl|ELSE}} {{Cl|CIRCLE}} (cx&, cy&), r&, 12
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit '' ''
{{CodeEnd}}
: ''Explanation:'' The square of the circle radius will be greater than or equal to the sum of the square of the mouse coordinates minus the center position when the pointer is inside of the circle. In this example the circle color will change from red to green.
''Example 2:'' Program illustrates how the CIRCLE command using a negative radian value can be used to create the hands of a clock.
{{CodeStart}} '' ''
{{Cl|CONST}} PI = 3.141593 'The mathematical value of PI to six places
{{Cl|DIM}} clock(60) 'A dimensioned array to hold 60 radian points
@ -117,9 +210,9 @@ previoushour% = hours% 'hold current hour for later use
{{PageSeeAlso}}
* {{KW|STEP}}
* {{KW|LINE}}
* {{KW|SCREEN (statement)}}
* [[STEP]], [[DRAW]]
* [[LINE]], [[PSET]], [[PRESET]]
* [[SCREEN]], [[SCREEN (function)]]
{{PageNavigation}}

View file

@ -1,19 +1,19 @@
The ''CLEAR''' statement clears all variable and array element values in a program. It does not affect constant values!
''Syntax:'' CLEAR [, ''stacksize&'' , ''stackspace&'']
''Syntax:'' '''CLEAR''' [, ''stacksize&'' , ''stackspace&'']
{{PageDescription}}
* Optional ''stacksize'' parameter was not required as Qbasic managed that. '''All three parameters are ignored by QB64!'''
* Optional ''stacksize'' parameter was not required as Qbasic managed that. '''All parameters and commas are ignored by QB64!'''
* The ''stackspace'' parameter sets the stack space to be added to the stack. Two commas kept Qbasic compatible with BASICA.
* Normally used to clear all program variable and [[Arrays|array]] values where numerical values become zero and string values become null.
* It does not clear [[CONST|constant]] values.
* Closes all opened files also.
* [[$DYNAMIC]] arrays will need to be [[REDIM|re-dimensioned]] or an [[ERROR Codes|error]] will occur when referenced because the array is removed.
* [[$DYNAMIC]] or [[REDIM]] arrays will need to be [[REDIM|re-dimensioned]] or an [[ERROR Codes|error]] will occur when referenced because it was removed.
''Example:'' Using CLEAR to clear array elements.
''Example:'' Using CLEAR to clear array elements from [[STATIC|static]] arrays or arrays created using [[DIM]].
{{CodeStart}} '' ''
{{Cl|CLS}}
{{Cl|DIM}} array(10) 'create a {{Cl|$STATIC}} array
@ -29,9 +29,10 @@ array(5) = 23
{{PageSeeAlso}}
* [[ERASE]]
* [[REDIM]]
* [[Arrays]]
* [[ERASE]] {{text|(array names only)}}
* [[REDIM]] {{text|(array sizes only)}}
* [[_PRESERVE]] {{text|(REDIM arrays only)}}
* [[Arrays]], [[&B|_BIT arrays]]
{{PageNavigation}}

View file

@ -2,7 +2,11 @@ The {{KW|CLNG}} function rounds decimal point numbers up or down to the nearest
{{PageSyntax}}
:{{Parameter|a%}} = {{KW|CLNG}}({{Parameter|DecimalPointNumber#}})
:: value = '''CLNG('''''expression''''')'''
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
@ -24,10 +28,10 @@ The {{KW|CLNG}} function rounds decimal point numbers up or down to the nearest
{{OutputEnd}}
{{PageSeeAlso}}
*{{KW|CINT}}, {{KW|INT}}, {{KW|CSNG}}, {{KW|CDBL}}, {{KW|_ROUND}}
* [[CINT]], [[INT]]
* [[CSNG]], [[CDBL]]
* [[_ROUND]]
{{PageNavigation}}

View file

@ -16,6 +16,7 @@ The {{KW|COLOR}} statement is used to change the color of text and background in
* '''[[SCREEN]] modes 2 and 11 cannot use the COLOR keyword as they are monochrome with white foreground!'''
* An [[ERROR Codes|illegal function error]] will occur if a background color is used in other screen modes!
* To change the ''background'' color only, use a comma and the color. EX: COLOR ,background%
* In '''GW-Basic''' a third border color parameter could be used while in SCREEN 0. The third argument can still be passed in SCREEN 0. Using the third argument in other screen modes will give "Illegal Function Call" Error or will '''crash''' without error in 32-bit screens.
==Screen Mode Attributes==
@ -59,44 +60,83 @@ The {{KW|COLOR}} statement is used to change the color of text and background in
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==RGB Palette Intensities==
RGB intensity values can be converted to Hexadecimal values to create the [[LONG]] [[_PALETTECOLOR]] value in non-32 bit screens:
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
alpha$ = "FF" 'solid alpha colors only
{{Cl|OUT}} {{Cl|&H}}3C8, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 20 'set black background to dark blue
{{Cl|PRINT}} "Attribute = Hex value Red Green Blue "
{{Cl|PRINT}}
{{Cl|COLOR}} 7
{{Cl|FOR...NEXT|FOR}} attribute = 0 {{Cl|TO}} 15
{{Cl|OUT}} {{Cl|&H}}3C7, attribute 'set color attribute to read
red$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&H}}3C9) * 4) 'convert port setting to 32 bit values
grn$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&H}}3C9) * 4)
blu$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&H}}3C9) * 4)
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(red$) = 1 {{Cl|THEN}} red$ = "0" + red$ '2 hex digits required
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(grn$) = 1 {{Cl|THEN}} grn$ = "0" + grn$ 'for low or zero hex values
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(blu$) = 1 {{Cl|THEN}} blu$ = "0" + blu$
hex32$ = "{{Cl|&H}}" + alpha$ + red$ + grn$ + blu$
{{Cl|_PALETTECOLOR}} attribute, {{Cl|VAL}}(hex32$) 'VAL converts hex string to a LONG 32 bit value
{{Cl|IF...THEN|IF}} attribute {{Cl|THEN}} {{Cl|COLOR}} attribute 'exclude black color print
{{Cl|PRINT}} "{{Cl|COLOR}}" + {{Cl|STR$}}(attribute) + " = " + hex32$, red$, grn$, blu$ 'returns closest attribute
{{Cl|NEXT}} '' ''
{{CodeEnd}}
{{OutputStart}}Attribute Hex value Red Green Blue
<center>'''Basic's 16 Default Color Attributes (non-[[DAC]])'''</center>
{{OutputStart}}{{text|  Attribute    Description     Red   Green   Blue 32 HEX HTML Name |Gold}}
 0 Black 0 0 0 000000 Black
{{text|  1 Dark Blue 0 0 42 00008B DarkBlue|#00008B}}
{{text|  2 Dark Green 0 42 0 006400 DarkGreen|#006400}}
{{text|  3 Dark Cyan 0 42 42 008B8B DarkCyan|#008B8B}}
{{text|  4 Dark Red 42 0 0 8B0000 DarkRed|#8B0000}}
{{text|  5 Dark Magenta 42 0 42 8B008B DarkMagenta|#8B008B}}
{{text|  6 Dark Yellow 42 21 0 DAA520 GoldenRod|#DAA520}}
{{text|  7 Light Grey 42 42 42 D3D3D3 LightGrey|#D3D3D3}}
{{text| 8 Dark Grey 21 21 21 696969 DimGray|#696969}}
{{text|  9 Blue 21 21 63 0000FF Blue|#1515FF}}
{{text| 10 Green 21 63 21 15FF15 Lime|#15FF15}}
{{text| 11 Cyan 21 63 63 15FFFF Cyan|#15FFFF}}
{{text| 12 Red 63 21 21 FF1515 Red|#FF1515}}
{{text| 13 Magenta 63 21 63 FF15FF Magenta|#FF15FF}}
{{text| 14 Yellow 63 63 21 FFFF00 Yellow|#FFFF00}}
{{text| 15 White 63 63 63 FFFFFF White|#FFFFFF}} '' ''
{{text|COLOR 0 <nowiki>=</nowiki> &HFF000050 00 00 50|#A8A8A8}}
{{text|COLOR 1 <nowiki>=</nowiki> &HFF0000A8 00 00 A8|#0050A8}}
{{text|COLOR 2 <nowiki>=</nowiki> &HFF00A800 00 A8 00|#00A800}}
{{text|COLOR 3 <nowiki>=</nowiki> &HFF00A8A8 00 A8 A8|#00A8A8}}
{{text|COLOR 4 <nowiki>=</nowiki> &HFFA80000 A8 00 00|#A80000}}
{{text|COLOR 5 <nowiki>=</nowiki> &HFFA800A8 A8 00 A8|#A800A8}}
{{text|COLOR 6 <nowiki>=</nowiki> &HFFA85400 A8 54 00|#A85400}}
{{text|COLOR 7 <nowiki>=</nowiki> &HFFA8A8A8 A8 A8 A8|#A8A8A8}}
{{text|COLOR 8 <nowiki>=</nowiki> &HFF545454 54 54 54|#545454}}
{{text|COLOR 9 <nowiki>=</nowiki> &HFF5454FC 54 54 FC|#5454FC}}
{{text|COLOR 10 <nowiki>=</nowiki> &HFF54FC54 54 FC 54|#54FC54}}
{{text|COLOR 11 <nowiki>=</nowiki> &HFF5454FC 54 FC FC|#54FCFC}}
{{text|COLOR 12 <nowiki>=</nowiki> &HFFFC5454 FC 54 54|#FC5454}}
{{text|COLOR 13 <nowiki>=</nowiki> &HFFFC54FC FC 54 FC|#FC54FC}}
{{text|COLOR 14 <nowiki>=</nowiki> &HFFFCFC54 FC FC 54|#FCFC54}}
{{text|COLOR 15 <nowiki>=</nowiki> &HFFFCFCFC FC FC FC|#FCFCFC}}
{{OutputEnd}}
<center>[http://www.w3schools.com/html/html_colornames.asp HTML Color Table Values and Names] or [http://www.tayloredmktg.com/rgb/#OR Other RGB colors]</center>
::: ''Note:'' '''QB64''' 32 bit color intensity values from 0 to 255 can be found by multiplying above values by 4.
:''Explanation:'' The RGB intensity values are multiplied by 4 to get the [[_RGB]] intensity values as [[HEX$|Hexadecimal]] values. The individual 2 digit [[HEX$]] intensity values can be added to "&HFF" to make up the 32 bit hexadecimal string value necessary for [[VAL]] to return to [[_PALETTECOLOR]]. The statement is only included in the example to show how that can be done with any 32 bit color value.
<center>'''Note:''' Black has a blue hex value of 50 due to the [[OUT]] background color setting which makes it dark blue.</center>
''Summary:'' The red, green, and blue intensity values can be changed using {{KW|OUT}} or {{KW|PALETTE}} statements. Some '''Qbasic''' RGB color attribute values can be changed in [[DAC]] {{KW|SCREEN (statement)|SCREEN}} modes and the [[DAC]] RGB intensity settings may be different.
<center></center>
<center>'''Color Port access using INP and OUT'''</center>
<center>'''Reading and setting Color Port intensities using [[INP]] and [[OUT]]'''</center>
:::::::::OUT &H3C7, attribute : Set port to read RGB settings
:::::::::color_intensity = INP(&H3C9) 'reads present setting
::::::::'''{{text|OUT &H3C7, attribute|green}}''' 'Set port to read RGB settings with:
:::::::::'''{{text|color_intensity <nowiki>=</nowiki> INP(&H3C9)|green}}''' 'reads present intensity setting
:::::::::OUT &H3C8, attribute : Set port to write RGB settings
:::::::::OUT &H3C9, color_intensity : Writes new settings
::::::::'''{{text|OUT &H3C8, attribute|green}}''' 'Set port to write RGB settings with:
:::::::::'''{{text|OUT &H3C9, color_intensity|green}}''' 'writes new intensity setting
* After every 3 reads or writes, changes to next higher color attribute. Loops can be used to set more than one attribute's intensities.
* Color port setting of Red, Green and Blue intensities can be done in ascending order.
* Color port attribute intensity values range from 0 to 63(1/4 of the 32 bit values) only in Qbasic 4 and 8 bit screen modes.
<center>'''Hexadecimal 32 bit colors can be set in 16 or 256 color screen modes with [[_PALETTECOLOR]]'''</center>
''Example:'' Changing light gray text in [[SCREEN]] 0 to a 32 bit custom color using a [[LONG]] HTML hexadecimal value:
{{CodeStart}} '' ''
{{Cl|COLOR}} 7
{{Cl|PRINT}} "Color 7 is gray"
K$ = {{Cl|INPUT$}}(1)
{{Cl|_PALETTECOLOR}} 7, {{Cl|&H}}FFDAA520 ' FF alpha makes the color translucent
{{Cl|PRINT}} "Color 7 is now Goldenrod in {{Cl|SCREEN}} 0! '' ''
{{CodeEnd}}
{{OutputStart}}
{{text|Color 7 is gray|#A8A8A8}}
{{text|Color 7 is now Goldenrod in SCREEN 0!|#DAA520}}
{{OutputEnd}}
: ''Explanation:'' [[_RGB32]] could be used to make custom 32 bit colors or HTML values could be used after &HFF for solid colors.
''See also:'' [[HEX$ 32 Bit Values]] to learn more about hexadecimal color values.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==Examples:==
@ -203,6 +243,7 @@ text$ = "HelloWorld"
{{CodeEnd}}
{{WhiteStart}}'''{{text|Black on bright white!|#000000}}'''
{{WhiteEnd}}
----
: ''Explanation:'' Since QB64 does not use [[DAC]] [[SCREEN]] 0 limitations, changing color intensities for custom background colors is possible.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>

View file

@ -1,47 +1,76 @@
The '''COMMAND$''' function returns the DOS commandline arguments passed when a program is run.
The '''COMMAND$''' [[STRING]] function returns the spaced [[DOS]] command line argument(s) passed when a program is run.
''Syntax:'' variable$ = COMMAND$
{{PageSyntax}}
::: option$ = [[COMMAND$]][(count%)]
* The [[STRING|string]] return value is any parameter following the filename in a [[RUN]] or command line statement.
* Qbasic returns [[UCASE$|uppercase]] [[STRING]] parameters no matter what case they were sent originally.
* Useful when the programmer wants to send specific program options to the command line for later use by the called program.
* The [[STRING]] return value is any '''spaced quoted or unquoted''' parameter(s) following the filename in a [[RUN]] or command line statement.
* '''QB64''' does not '''require or return all [[UCASE$|uppercase]]''' values so keep that fact in mind when checking parameters passed!
* Useful when the programmer wants to add options to the command line of a program for later use by another program.
* COMMAND$ was not available in QuickBasic versions below 4.0
* In '''QB64 only''', COMMAND$ can work as an array to return specific elements passed to the command line. COMMAND$(2) would return the '''spaced''' second parameter passed at the command line. This can be used on modern operating systems to successfully retrieve file names and arguments which contain spaces properly. (versions after May 20, 2015)
* Use the [[_COMMANDCOUNT]] function to find the number of spaced parameters passed to a program via the command line. (versions after May 20, 2015) '''{{text|See ''Example 2''|green}}'''.
* Reading the spaced command options in the '''COMMAND$(i)''' array in a loop can also be done and reading a COMMAND$ without parameters is also possible. (versions after May 20, 2015) '''{{text|See ''Example 3''|green}}'''.
* COMMAND$ was '''not available in QuickBasic versions below 4.0''' and returned [[UCASE$|uppercase]] [[STRING]] parameters no matter what case they were sent originally.
''Example:'' Compile both programs. ProgramA [[RUN]]s ProgramB with a parameter passed following the filename:
''Example 1:'' Compile both programs. ProgramA [[RUN]]s ProgramB with a parameter passed following the filename:
{{CodeStart}}
{{Cl|LOCATE}} 12, 36: {{Cl|PRINT}} "ProgramA"
{{Cl|LOCATE}} 23, 25: {{Cl|PRINT}} "Press any key to run ProgramB"
K$ = {{Cl|INPUT$}}(1)
{{Cl|RUN}} "ProgramB FS" 'pass FS parameter to ProgramB in QB64
{{Cl|RUN}} "ProgramB FS" 'pass FS parameter to ProgramB in QB64 or QB4.5
{{Cl|END}}
{{Cl|SYSTEM}}
{{CodeEnd}}
: ''ProgramB'' checks for fullscreen parameter pass in QB64 and goes full screen.
{{CodeStart}} '' ''
{{Cl|LOCATE}} 12, 36: {{Cl|PRINT}} "ProgramB"
parameter$ = {{Cl|UCASE$}}({{Cl|COMMAND$}})
{{Cl|LOCATE}} 17, 36: {{Cl|PRINT}} "ProgramB"
parameter$ = {{Cl|UCASE$}}({{Cl|COMMAND$}}) 'QB64 only as QB4.5 will always return upper case
{{Cl|LOCATE}} 20, 33: {{Cl|PRINT}} "Parameter = " + parameter$
{{Cl|IF...THEN|IF}} {{Cl|LEFT$}}(parameter$, 2) = "FS" {{Cl|THEN}} {{Cl|_FULLSCREEN}} 'parameter changes to full screen
{{Cl|END}} '' ''
{{CodeEnd}}
{{OutputStart}} Parameter = FS.EXE
{{OutputStart}}
ProgramB
Parameter = FS.EXE
{{OutputEnd}}
''Example 2:'' Program gets the number of parameters passed to the program, and then prints those parameters to the screen one at a time.
{{CodeStart}}count = {{Cl|_COMMANDCOUNT}}
{{Cl|FOR...NEXT|FOR}} c = 1 {{Cl|TO}} count
{{Cl|PRINT}} {{Cl|COMMAND$}}(c) 'or process commands sent
{{Cl|NEXT}}
{{CodeEnd}}
{{OutputStart}}-1
a data file
{{OutputEnd}}
: ''Explanation: If we start ''ThisProgram.exe'' with the command line '''ThisProgram -l "a data file"''', COMMAND$ will return a single string of "-1 a data file" which might be hard to process and interpret properly, but COMMAND$(1) would return "-l" and COMMAND$(2) would return the quoted "a data file" option as separate entries for easier parsing and processing.
''Example 3:'' As part of the command array upgrade, you can also just read the array to see how many commands were sent:
{{CodeStart}}DO
count = count + 1
cmd$ = {{Cl|COMMAND$}}(count)
{{Cl|IF...THEN|IF}} cmd$ = "" {{Cl|THEN}} {{Cl|EXIT DO}} 'read until an empty return
{{Cl|PRINT}} cmd$ 'or process commands sent
{{Cl|LOOP}} '' ''
count = count - 1 'save the number of parameters sent to this program when run
{{CodeEnd}}
:'''Note:''' When using this command [[DO]] loop read procedure, the spaced commands sent must not be empty strings as the count will end!
''See also:''
* [[SHELL]], [[RUN]]
* [[UCASE$]], [[LCASE$]]
* [[_COMMANDCOUNT]]
{{PageNavigation}}

View file

@ -54,6 +54,7 @@ Enter the radius of a circle or zero to quit? ''0''
{{PageSeeAlso}}
* {{KW|DIM}}, {{KW|SHARED}}
* {{KW|STATIC}}, {{KW|COMMON}}
* [http://doc.pcsoft.fr/en-US/?6510001 Windows 32 API constant values]
{{PageNavigation}}

View file

@ -1,12 +1,17 @@
The '''COS''' function returns the cosine of an angle measured in radians.
The '''COS''' function returns the horizontal component or the cosine of an angle measured in radians.
::::::''Syntax:'' value! = COS(''radian_angle!'')
{{PageSyntax}}
::: value! = '''COS('''''radian_angle!''''')'''
{{Parameters}}
* The ''radian_angle'' must be measured in radians.
* The ''radian_angle'' must be measured in radians. To convert from degrees to radians, multiply degrees * π/180.
{{PageDescription}}
* To convert from degrees to radians, multiply degrees * π/180.
* [[COS]]INE is the horizontal component of a unit vector in the direction theta (θ).
* COS(x) can be calculated in either [[SINGLE]] or [[DOUBLE]] precision depending on its argument.
::: COS(4) = -.6536436 ...... COS(4#) = -.6536436208636119
@ -90,6 +95,7 @@ DEGREES% = RADIANS * 180 / PI = 45
''See also:''
* [[_PI]] {{text|(QB64 function)}}
* [[SIN]] {{text|(sine)}}
* [[ATN]] {{text|(arctangent)}}
* [[TAN]] {{text|(tangent)}}

View file

@ -2,31 +2,32 @@
To converts a numerical value to the closest [[SINGLE]]-precision number.
::::::'''Syntax:''' CSNG(n)
{{PageSyntax}}
:: singlevalue = '''CSNG('''''expression''''')'''
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
* n must be a numeric value (see the CINT and CDBL functions).
* Also used to define a value as SINGLE-precision.
{{PageDescription}}
* Returns the closest [[SINGLE]] decimal point value
* Also used to define a value as [[SINGLE]]-precision up to 7 decimals.
''Example:''
{{CodeStart}}
A# = 975.3421222#
PRINT A#, CSNG(A#)
{{CodeEnd}}
{{OutputStart}}
975.3421222      975.3421
{{OutputStart}}975.3421222      975.3421
{{OutputEnd}}
''See also:''
[[CDBL]], [[CLNG]], [[CINT]], [[INT]], [[_ROUND]]
* [[CDBL]], [[CLNG]]
* [[CINT]], [[INT]]
* [[_ROUND]]
{{PageNavigation}}

View file

@ -10,7 +10,7 @@ The '''DATA''' statement creates a line of fixed program information separated b
* DATA is best placed after the main program code. '''QB64 DATA can be placed inside a [[SUB]] or [[FUNCTION]] procedures!'''
* [[RESTORE]] will only read the first data field if the DATA is not labeled or RESTORE call uses no label.
* When using multiple DATA fields, label each data field with a line label so that '''each''' data pointer can be reset for multiple reads with [[RESTORE]] ''linelabel''. Otherwise RESTORE will only read the '''first''' data field!
* Comma separations are flexible to allow column alignments when creating them. Spaces are ignored unless inside of quotes.
* QB comma separations were flexible to allow column alignments when creating them. QB64 removes spacing between commas.
* [[STRING]] DATA values with end spaces, QB keywords and commas in them '''require''' quotation marks.
* DATA fields can only be created by the programmer and cannot be changed by a user or lost.
* Comments after a data line require a colon before the comment.

View file

@ -3,10 +3,10 @@ The '''DECLARE''' statement is used to tell Qbasic that a [[SUB]] or [[FUNCTION]
{{PageSyntax}}
:: DECLARE SUB ProcedureName ([parameters [[AS]] type])
:: '''DECLARE''' {SUB|FUNCTION} ProcedureName ([''parameter'' [[AS]] type[, ...]])
* '''QB64 ignores DECLARE statements, so define the parameter [[TYPE]]s in the SUB procedure!'''
* '''QB64 ignores DECLARE SUB or FUNCTION statements, so define the parameter [[TYPE]]s in the SUB procedure!'''
* Parameters MUST be placed in parenthesis separated by commas when necessary.
* Empty parenthesis are required when no parameters are used.
* Declarations should be placed at the top of the main program code after {{KW|Metacommand}} and {{KW|DEFINT|DEF}} statements if used.
@ -18,7 +18,8 @@ The '''DECLARE''' statement is used to tell Qbasic that a [[SUB]] or [[FUNCTION]
''See also:''
* [[SUB]], [[FUNCTION]], [[BYVAL]]
* [[SUB]], [[FUNCTION]]
* [[CALL]], [[BYVAL]]
* [[DECLARE LIBRARY]] (QB64 ONLY)

View file

@ -2,31 +2,39 @@ The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]]
{{PageSyntax}}
::: DECLARE [DYNAMIC|CUSTOMTYPE|STATIC] LIBRARY [{''"Library_filename"''|''"Headerfile"''}]
::: '''DECLARE''' [DYNAMIC|CUSTOMTYPE|STATIC] '''LIBRARY''' [{''"Library_filename"''|''"Headerfile"''}]
::: {[[SUB]]|[[FUNCTION]]} [''procedure_name'' {{KW|ALIAS}}] ''library_procedure'' ([{{KW|BYVAL}}] ''parameter {{KW|AS}}'', ...)
::::.
::::. 'other SUBs or Functions as required
::::.
::: END DECLARE
::: '''END DECLARE'''
* '''This QB64 procedure is available in the Dec 3, 2010 WINDOWS version .923 or later ONLY!'''
* The declaration can be used with C++ sub-procedures, Windows API, the QB64 SDL Library and '''QB64''' Dynamic Link Libraries.
* The ''Library name'' is only necessary if a Library is NOT already loaded by QB64. Do not include the ''.DLL'' or ''.H'' file name extension.
* ''Library filename''s can be listed to combine more than one DLL or Header file name or path into one DECLARE LIBRARY block.
* C procedures can use a header file name. File code must be included with program code. Do not include the ''.h'' extension.
{{Parameters}}
* The ''Library name'' is needed if a Library is NOT already loaded by QB64. Do not include the ''.DLL'', ''LIB'' or ''.H'' file extension.
* ''Procedure_name'' is any program procedure name you want to designate by using [[ALIAS]] with the ''Library_procedure'' name.
* ''Library procedure'' is the actual procedure name used inside of the library or header file.
''Library Types:''
* '''[[DECLARE DYNAMIC LIBRARY|DYNAMIC]]''' links a program to functions in dynamically linkable libraries. At present, only .DLL files are supported
* '''CUSTOMTYPE''' is already implied when using [[DECLARE DYNAMIC LIBRARY]]. This type of library just allows the same flexibility to apply when referencing STATIC libraries that are used to refer to dynamic libraries. Supports shared object (*.so) libraries
* '''STATIC''' is the same as [[DECLARE LIBRARY]] except that it prioritizes linking to static libraries (*.a/*.o) over shared object (*.so) libraries, if both exist. As Windows doesn't use shared libraries (DLLs are different) this does not affect Windows users.
{{PageDescription}}
* The declaration can be used with C++ sub-procedures, Windows API and QB64 SDL Libraries.
* ''Library filename''s can be listed to combine more than one DLL or Header file name or path into one DECLARE LIBRARY block.
* C procedures can use a header file name. File code must be included with program code. Do not include the ''.h'' extension.
* ''Parameters'' used by the Library procedure must be passed by value ([[BYVAL]]) except for [[STRING]] characters.
* When using a procedure from an '''unsupported''' Dynamic Link Library (DLL file) use [[DECLARE DYNAMIC LIBRARY]].
* '''CUSTOMTYPE''' is already implied when using [[DECLARE DYNAMIC LIBRARY]]. This type of library just allows the same flexibility to apply when referencing STATIC libraries that are used to refer to dynamic libraries.
* '''STATIC''' is the same as [[DECLARE LIBRARY]] except that it prioritizes linking to static libraries (*.a/*.o) over shared object (*.so) libraries, if both exist. As Windows doesn't really use shared libraries (DLLs are a bit different) this does not affect Windows users.
* The [[_OFFSET]] in memory can be used in '''CUSTOMTYPE''', '''STATIC''' and '''DYNAMIC LIBRARY''' declarations.
* Declarations can be made inside of [[SUB]] or [[FUNCTION]] procedures. Declarations do not need to be at program start.
* '''NOTE: It is up to the user to document and determine the suitability of all Libraries and procedures they choose to use! QB64 cannot guarantee that ANY procedure will work and cannot quarantee ANY troubleshooting help!'''
''Example 1:'' Using a QB64 SDL library procedure as a program SUB procedure to move the mouse pointer to a designated position.
''Example 1:'' Using a '''QB64 SDL ONLY''' library procedure as a program SUB procedure to move the mouse pointer to a coordinate.
{{CodeStart}} '' ''
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} SDL_WarpMouse ({{Cl|BYVAL}} column {{Cl|AS}} {{Cl|LONG}}, {{Cl|BYVAL}} row {{Cl|AS}} {{Cl|LONG}}) 'SDL procedure name
@ -49,11 +57,17 @@ SDL_WarpMouse x, y 'call SDL library procedure
{{small|Code by Galleon}}
:''Explanation:'' The SDL Library is already included and loaded with QB64, so these procedures are directly available for use.
<center>'''Using ALIAS to create a program SUB or FUNCTION'''</center>
<center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''</center>
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&, {{Cl|BYVAL}} row&)
{{Cl|DECLARE LIBRARY|END DECLARE}} '' ''
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&, {{Cl|BYVAL}} row&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|_DELAY}} 2
MouseMove 100, 100
{{Cl|_DELAY}} 2
MouseMove 200, 200 '' ''
{{CodeEnd}}
:''Explanation:'' When a Library procedure is used to represent another procedure name use [[ALIAS]] instead. Saves creating a SUB!
@ -122,6 +136,7 @@ PRINT "&H" + HEX$(GetLPTPortAddress%(1))
* [[OpenGL Libraries]]
* [[SFML Libraries]]
* [[SQL Client]]
* [http://www.qb64.net/forum/index.php?topic=11810.msg102081#msg102081 DECLARE LIBRARY and C++ Variable Types]
{{PageNavigation}}

View file

@ -2,12 +2,13 @@ The '''DEFDBL''' statement defines all designated undefined variables AS [[DOUBL
{{PageSyntax}}
:: DEFDBL firstletters
:: '''DEFDBL ''letter'''''[-''range'']
* The first letters can be from A-Z or any other range.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* DEFDBL sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''

View file

@ -2,8 +2,7 @@ The '''DEFINT''' statement defines all designated undefined variables AS [[INTEG
{{PageSyntax}}
:: DEFINT firstletters
:: '''DEFSINT ''letter'''''[-''range'']
* The variable first letters can be from A-Z or any other range.
@ -11,7 +10,8 @@ The '''DEFINT''' statement defines all designated undefined variables AS [[INTEG
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* DEFINT allows users to create larger graphical arrays up to the integer limits.
* The maximum value of a signed Integer variable is 32767. Minimum is -32768.
* {{KW|UNSIGNED}} Integer values from 0 to 65535. See {{KW|_DEFINE}}
* [[UNSIGNED]] Integer values from 0 to 65535 must use [[_DEFINE]]
* DEFINT sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''
@ -23,7 +23,6 @@ The '''DEFINT''' statement defines all designated undefined variables AS [[INTEG
''See also:''
* [[DEFSNG]], [[DEFLNG]], [[DEFDBL]], [[DEFSTR]], [[_DEFINE]]

View file

@ -2,13 +2,14 @@ The '''DEFLNG''' statement defines all designated undefined variables AS [[LONG]
{{PageSyntax}}
:: DEFLNG firstletters
:: '''DEFSTR ''letter'''''[-''range'']
* The variable first letters can be from A-Z or any other range.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* [[UNSIGNED]] [[LONG]] Integer values from 0 to 4,294,967,295 must use [[_DEFINE]].
* DEFLNG sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''

View file

@ -2,14 +2,14 @@ The '''DEFSNG''' statement defines all designated undefined variables AS [[SINGL
{{PageSyntax}}
:: DEFSNG firstletters
:: '''DEFSNG ''letter'''''[-''range'']
* The variable first letters can be from A-Z or any other range.
* You can also use commas for specific untyped variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* DEFSNG is normally the Qbasic default assignment for undefined variables anyhow.
* DEFSNG is normally the Qbasic default type assignment for undefined variables without type suffixes.
* DEFSNG sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''

View file

@ -2,13 +2,14 @@ The '''DEFSTR''' statement defines all designated undefined variables AS [[STRIN
{{PageSyntax}}
:: DEFSTR firstletters
:: '''DEFSTR ''letter'''''[-''range'']
* The variable first letters can be from A-Z or any other range.
* The variable starting letters can be from A-Z or any other range.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not defined otherwise.
* DEFSTR sets the [[type]] of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program(even in conditional statement blocks not executed and subsequent [[SUB]] procedures).
* '''Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!'''

61
internal/help/DIR$.txt Normal file
View file

@ -0,0 +1,61 @@
The '''DIR$''' function below is '''NOT A QB64 FUNCTION!''' This page supplies equivalent QB code:
{{PageSyntax}}
::: filename$ = '''DIR$('''{filespec$|""}''')'''
The DIR$ function used in PDS(7.1) returns a filename or a list when more than one exist. The file spec can use a path and/or wildcards.
{{CodeStart}} '' ''
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT}}
{{Cl|LINE INPUT}} "Enter a file spec: ", spec$
file$ = DIR$(spec$) 'use a file spec ONCE to find the last file name listed
{{Cl|PRINT}} DIRCount%, file$, 'function can return the file count using {{Cl|SHARED}} variable
{{Cl|IF...THEN|IF}} DIRCount% > 1 {{Cl|THEN}}
DO
K$ = {{Cl|INPUT$}}(1)
file$ = DIR$("") ''''use an empty string parameter to return a list of files!'''
{{Cl|PRINT}} file$,
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}(file$) = 0 'file list ends with an empty string
{{Cl|END IF}}
{{Cl|NEXT}}
{{Cl|END}}
{{Cl|FUNCTION}} DIR$ (spec$)
{{Cl|CONST}} TmpFile$ = "DIR$INF0.INF", ListMAX% = 500 'change maximum to suit your needs
{{Cl|SHARED}} DIRCount% 'returns file count if desired
{{Cl|STATIC}} Ready%, Index%, DirList$()
{{Cl|IF...THEN|IF}} {{Cl|NOT}} Ready% {{Cl|THEN}} {{Cl|REDIM}} DirList$(ListMAX%): Ready% = -1 '{{Cl|DIM}} array first use
{{Cl|IF...THEN|IF}} spec$ > "" {{Cl|THEN}} 'get file names when a spec is given
{{Cl|SHELL}} {{Cl|_HIDE}} "DIR " + spec$ + " /b > " + TmpFile$
Index% = 0: DirList$(Index%) = "": ff% = {{Cl|FREEFILE}}
{{Cl|OPEN}} TmpFile$ {{Cl|FOR...NEXT|FOR}} {{Cl|APPEND}} {{Cl|AS}} #ff%
size& = {{Cl|LOF}}(ff%)
{{Cl|CLOSE}} #ff%
{{Cl|IF...THEN|IF}} size& = 0 {{Cl|THEN}} {{Cl|KILL}} TmpFile$: {{Cl|EXIT FUNCTION}}
{{Cl|OPEN}} TmpFile$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #ff%
{{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|NOT}} {{Cl|EOF}}(ff%) {{Cl|AND (boolean)|AND}} Index% < ListMAX%
Index% = Index% + 1
{{Cl|LINE INPUT (file statement)|LINE INPUT}} #ff%, DirList$(Index%)
{{Cl|LOOP}}
DIRCount% = Index% '{{Cl|SHARED}} variable can return the file count
{{Cl|CLOSE}} #ff%
{{Cl|KILL}} TmpFile$
{{Cl|ELSE}} {{Cl|IF...THEN|IF}} Index% > 0 {{Cl|THEN}} Index% = Index% - 1 'no spec sends next file name
{{Cl|END IF}}
DIR$ = DirList$(Index%)
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' The function will verify that a file exists (even if it is empty) by returning it's name or it returns an empty string if no file exists. It can return a list of file names by using an empty string parameter("") after sending a wildcard spec to get the first file name. The number of file names found is returned by using the SHARED variable, '''DIRCount%'''. Unlike the PDS DIR$ function, '''it MUST use an empty string parameter until QB64 supports optional parameters!''' The function does NOT delete empty files.
''See also:''
* [[FILES]]
* [[KILL]]
* [[SHELL]]
{{PageNavigation}}

View file

@ -2,11 +2,17 @@
{{PageSyntax}}
:{{KW|DO}} [{{{KW|WHILE}}|{{KW|UNTIL}}} condition]
:'''[[DO]]''' [{{{KW|WHILE}}|{{KW|UNTIL}}} condition]
:.
:.
:.
:{{KW|LOOP}} [{{{KW|WHILE}}|{{KW|UNTIL}}} condition]
:'''[[LOOP]]'''
:'''[[DO]]'''
:.
:.
:.
:'''[[LOOP]]''' [{{{KW|WHILE}}|{{KW|UNTIL}}} condition]
{{PageDescription}}
@ -18,17 +24,15 @@
::[[WHILE]] checks if the condition is True before running loop code again.
* NOTE: You cannot use a condition after both the DO and LOOP statements at the same time!
* Use '''[[EXIT]] DO''' to exit a DO loop within the loop code.
* If a loop has no exit condition, it will never stop!
* If a loop never meets an exit condition requirement, it will never stop!
* '''Condition expressions are required after WHILE or UNTIL or QB64 will return a compiler error!'''
{{Template:RelationalTable}}
{{PageExamples}}
:''Example 1:'' Using WHILE to clear the keyboard buffer.
''Example 1:'' Using WHILE to clear the keyboard buffer.
{{CodeStart}}
DO WHILE {{Cl|INKEY$}} <> "": LOOP ' checks evaluation before running loop code
@ -38,8 +42,7 @@ DO: LOOP WHILE INKEY$ <> "" ' checks evaluation after one run of
{{CodeEnd}}
:''Example 2:'' Using UNTIL to clear the keyboard buffer.
''Example 2:'' Using UNTIL to clear the keyboard buffer.
{{CodeStart}}
DO UNTIL {{Cl|INKEY$}} = "": LOOP ' checks evaluation before running loop code
@ -49,11 +52,17 @@ DO: LOOP UNTIL {{Cl|INKEY$}} = "" ' checks evaluation after one run of
{{CodeEnd}}
:''Example 3:'' Using a one time DO loop to exit ANY of several FOR LOOPs, without using [[GOTO]]. SUB reads header contents of a [[BSAVE]] file that may include embedded RGB color settings before the image.
''Example 3:'' Using a one time DO loop to exit ANY of several FOR LOOPs, without using [[GOTO]].
:SUB reads header contents of a [[BSAVE]] file that may include embedded RGB color settings before the image.
{{CodeStart}} '' ''
{{Cl|DEFINT}} A-Z
{{Cl|SUB}} CheckScreen 'find Screen mode (12 or 13) and image dimensions
{{Cl|INPUT}} "Enter a BSAVE file name to read the file for screen mode:"', filenm$
CheckScreen filenm$
{{Cl|END}}
{{Cl|DEFINT}} A-Z
{{Cl|SUB}} CheckScreen (Filename$) 'find Screen mode (12 or 13) and image dimensions
DIM Bsv AS {{Cl|STRING}} * 1
DIM Header AS STRING * 6
@ -124,17 +133,17 @@ COLOR 14: LOCATE 10, 25
{{Cl|END SUB}} '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
''Explanation:'' The SUB procedure reads a file that was [[BSAVE]]d previously. If the RGB colors are stored before the image, the values can only be between 0 and 63. Higher values indicate that the image width and height are located there and that there are no stored color values to be read. SUB later displays the dimensions of the file image that [[GET (graphics statement)|GET]] placed in the file array. The loop is set to only run once by creating '''a TRUE [[UNTIL]] statement''' such as 1 = 1. When a screen mode cannot be determined, the user must select one.
:''Explanation:'' The SUB procedure reads a file that was [[BSAVE]]d previously. If the RGB colors are stored before the image, the values can only be between 0 and 63. Higher values indicate that the image width and height are located there and that there are no stored color values to be read. SUB later displays the dimensions of the file image that [[GET (graphics statement)|GET]] placed in the file array. The loop is set to only run once by creating '''a TRUE [[UNTIL]] statement''' such as 1 = 1. When a screen mode cannot be determined, the user must select one.
:Dimensions and location of width and height information indicates the screen mode as [[SCREEN (statement)|SCREEN]] 13 if it has 768 RGB values and dimensions of 320 X 200 max. If the file only holds 64 settings and/or is larger than 320 X 200, it uses SCREEN 12 or 9. The procedure [[EXIT]]s the DO LOOP early when the image size is found with or without custom color settings.
Dimensions and location of width and height information indicates the screen mode as [[SCREEN (statement)|SCREEN]] 13 if it has 768 RGB values and dimensions of 320 X 200 max. If the file only holds 64 settings and/or is larger than 320 X 200, it uses SCREEN 12 or 9. The procedure [[EXIT]]s the DO LOOP early when the image size is found with or without custom color settings.
Divide SCREEN 13 [[GET (graphics statement)|GET]] widths by 8.
: Divide SCREEN 13 [[GET (graphics statement)|GET]] widths by 8.
{{PageSeeAlso}}
* {{KW|EXIT DO}}
* {{KW|WHILE...WEND}}
* {{KW|FOR...NEXT}}
* [[EXIT DO]]
* [[WHILE...WEND]]
* [[FOR...NEXT]]
{{PageNavigation}}

View file

@ -3,18 +3,18 @@
{{PageSyntax}}
:: DRAW draw_string$
:: '''DRAW''' draw_string$
* The draw string can be a draw value in quotation marks or a [[STRING]] variable using DRAW function letters.
* DRAW starting coordinates can be set using [[PSET]], [[PRESET]], [[CIRCLE]] or [[LINE]] ending positions.
* Other graphic objects can be located at or relative to the last DRAW position.
* DRAW starting coordinates can be set using [[PSET]], [[PRESET]], [[CIRCLE]] or [[LINE]] ending positions. [[PSET]] or [[PRESET]] colors pass too.
* Other graphic objects can be located at or relative to the last DRAW position using [[STEP]].
* DRAW can adopt colors from other graphics objects such as [[PSET]], [[LINE]] and [[CIRCLE]] statements.
* Draw strings use letters followed by the number of pixels to move, an angle, coordinate or a color value.
* Draw strings are flexible with spacing. Spacing is not required! DRAW will look for a number value when needed.
* Draw strings are flexible with spacing. '''Spacing is not required!''' DRAW will look for a number value after a valid letter.
* DRAW statements are not Case sensitive. Use upper or lower case.
:* "'''C''' n" designates the color n to be used in the draw statement string following use. [[PSET]] or [[PRESET]] colors work too.
:* "'''B'''" (Blind) before a line move designates that the line move will be hidden. Use to offset from a "P" or [[PAINT]] border.
:* "'''C''' n" designates the color attribute or [[_RGB]] [[STR$|string]] numerical color value to be used in the draw statement immediately after.
:* "'''M''' x, y" can move to another coordinate area of the screen. When a + or - sign is used before a coordinate,
::it is a relative coordinate move similar to using the [[STEP]] graphics keyword. DRAW "M+=" + [[VARPTR$]](variable%)
:* "'''N'''" before a line move designates that the drawn line will return to the line start position. Saves moves!
@ -23,18 +23,16 @@
:* "'''X'''" + [[VARPTR$]](value) can draw another substring.
* Certain letter designations create line moves on the SCREEN. Each move is followed by the number of pixels:
:* "'''U''' n" draws a line UP n pixels.
:* "'''D''' n" draws a line DOWN n pixels.
:* "'''L''' n" draws a line LEFT n pixels.
:* "'''R''' n" draws a line RIGHT n pixels.
:* "'''D''' n" draws a line vertically DOWN n pixels.
:* "'''E''' n" draws a diagonal / line going UP and RIGHT n pixels each direction.
:* "'''F''' n" draws a diagonal \ line going DOWN and RIGHT n pixels each direction.
:* "'''G''' n" draws a diagonal / LINE going DOWN and LEFT n pixels each direction.
:* "'''H''' n" draws a diagonal \ LINE going UP and LEFT n pixels each direction.
:* "'''L''' n" draws a line horizontally LEFT n pixels.
:* "'''R''' n" draws a line horizontally RIGHT n pixels.
:* "'''U''' n" draws a line vertically UP n pixels.
* Angles are used to rotate the draw moves following their use. U could become a down move.
* Angles are used to rotate ALL draw moves following their use. U could become a down move or even rotate.
:* "'''A''' n" can use values of 1 to 3 to rotate up to 3 90 degree(270) angles.
:* '''TA''' n" can use any n angle from -360 to 0 to 360 to rotate a DRAW (Turn Angle). "TA0" resets to normal.
:* When [[VARPTR$]] is used DRAW functions such as '''TA''' angles use an equal sign: "TA=" + VARPTR$(angle%)
@ -73,7 +71,7 @@
''Explanation:'' To place 12 circles in a circle each move is 30 degrees. PSET sets the center of the circular path every loop. TA moves counter-clockwise with positive degree angles. Once TA sets the angle a blind Up move is at that angle. The hour circles use the end point of the blind line as centers using the STEP relative coordinates of 0. After the circles are drawn, a draw "P" string paints the circle centers. DRAW paint strings use the last coordinate position also.
''Example 3:'' Creating a moving second hand for the clock above (SCREEN 12).
''Example 3:'' Creating a moving second hand for the clock above (SCREEN 12). (See [[TIME$]] example 1)
{{CodeStart}}
DO: sec$ = {{Cl|RIGHT$}}({{Cl|TIME$}}, 2) ' get actual seconds from TIME$ function
@ -91,7 +89,7 @@
''Explanation:'' The degrees to move from the original UP line move is calculated by dividing 360/60 seconds in a full rotation. That value of 6 is made negative to use TA correctly and multiplied by the [[VAL]]ue of seconds from the TIME$ function. The degree angle is converted by [[STR$]] to a string and added to the DRAW string using the [[STRING]] '''concatenation +''' operator. DO NOT USE SEMICOLONS to create DRAW strings! Once the second hand is placed on the screen, a loop waits for the second value to change. It then erases the hand and it repeats the process again.
''Example 4:'' Creating digital displays using DRAW format strings to create the LED segments.
''Example 4:'' Creating digital displays using DRAW format strings to create the LED segments. (See [[SELECT CASE|SELECT EVERYCASE]] example 5)
{{CodeStart}}
{{Cl|SCREEN}} 12
DO
@ -137,10 +135,35 @@ DO
:''Explanation:'' The DRAW strings can be used more than once with different [[PSET]] positions to create more digits.
''Example 5:'' Using 32 bit or [[_RGB]] color [[STR$|string]] values when using the DRAW C text statement
{{CodeStart}} '' ''
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 800, 12)
{{Cl|PRINT}} {{Cl|_ALPHA}}(10), {{Cl|_RED}}(10), {{Cl|_GREEN}}(10), {{Cl|_BLUE}}(10)
{{Cl|SLEEP}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 800, 32) 'comment out this line to use the non-32 bit screen mode 12
{{Cl|PRINT}} {{Cl|_ALPHA}}(10), {{Cl|_RED}}(10), {{Cl|_GREEN}}(10), {{Cl|_BLUE}}(10)
{{Cl|PSET}} (400, 400), 0 ' move to 320, 240... draw will start where pset leaves off
c = 14
{{Cl|DIM}} k {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}}
k = {{Cl|_RGB}}(80, 255, 80)
{{Cl|FOR...NEXT|FOR}} repeat = 1 {{Cl|TO}} 16
{{Cl|FOR...NEXT|FOR}} p = 0 {{Cl|TO}} 359
c = c + 1: d = c / 14
{{Cl|DRAW}} "c" + {{Cl|STR$}}(k) + " ta" + {{Cl|STR$}}(p) + " bu " + {{Cl|STR$}}(d) + "l7 u7 r7 d7 bd " + {{Cl|STR$}}(d)
{{Cl|NEXT}} p
{{Cl|NEXT}} repeat
{{CodeEnd}}
: ''Explanation:'' DRAW strings will ignore spaces between letters and numbers so string trimming is not necessary.
''See also:''
* [[LINE]], [[PSET]], [[PRESET]], [[CIRCLE]]
* [[PAINT]], [[SCREEN (statement)|SCREEN]]
* [[COLOR]], [[PLAY]]
* [[TIME$]]
{{PageNavigation}}

View file

@ -1,4 +1,4 @@
The '''ENVIRON$''' function returns a [[STRING]] environmental value from the PC's environmental settings list.
The '''ENVIRON$''' function returns a [[STRING]] environmental value from the '''Windows''' PC's environmental settings list.
@ -10,17 +10,20 @@ The '''ENVIRON$''' function returns a [[STRING]] environmental value from the PC
* The function can use an [[INTEGER]] ''list_number'' order value or [[STRING]] ''systemID$'' parameter.
* ''List_number'' refers to the number order of the environmental list. Returns are not in any particular numerical order.
* ''SystemID'' is the specific [[STRING]] parameter requested. Returns that environmental [[STRING]] setting only:
::* "BLASTER" returns current Sound Blaster settings if installed.
::* "COMPUTERNAME" returns OEM serial number of the PC.
::* "HOMEPATH" returns current user's Administrator or "OWNER" folder path.
::* "OS" returns the Windows Operating System version.
::* "PATH" returns full Windows path settings
::* "PROGRAMFILES" returns path to Program files folder normally "C:\PROGRAM FILES"
::* "PROMPT" returns current OS prompt setting. Windows 95 and 98 had version in brackets "[WIN 98]$P$G"
::* "SYSTEMROOT" returns the absolute path to the Windows folder including the drive letter. Normally "C:\WINDOWS"
::* "TEMP" returns path to TEMP folder. Normally "C:\TEMP"
::* "USERNAME" returns the current Administrator name or "OWNER".
: ''Note:'' There are other possible system settings that are not listed! Run ''Example 1'' to see the list on your computer.
::* "BLASTER" = current Sound Blaster settings if installed.
::* "COMPUTERNAME" or "USERDOMAIN" = OEM PC serial number or the computer name assigned by owner.
::* "HOMEDRIVE" or "SystemDrive" = Windows root drive, normally C: on single partition drives.
::* "HOMEPATH" = current user's Administrator or the single user's "OWNER" folder path.
::* "OS" = Windows Operating System version. Often WindowsNT these days.
::* "PATH" = full Windows path settings that windows uses to look for file extensions in PATHEXT below.
::* "PATHEXT = Windows extensions used: COM, EXE, BAT, CMD, VBS, VBE, JS, JSE, WSF, WSH, MSC
::* "PROCESSOR_ARCHITECTURE" = x86 for 32 or 64 bit so far.
::* "PROGRAMFILES" = path to Program files folder normally "C:\PROGRAM FILES"
::* "PROMPT" = $P$G normaly on Windows NT. Windows 95 and 98 = "[WIN 98]$P$G" but cannot run QB64!
::* "SYSTEMROOT" or "windir" = path to the Windows folder including the drive letter like "C:\WINDOWS"
::* "TEMP" or "TMP" = path to TEMP folder. "C:\TEMP" or the user specific temp folder on later versions.
::* "USERNAME" = current Administrator name or "OWNER".
: ''Note:'' There are other possible system settings that are not listed or never used on older versions! Run ''Example 1''
* The OS in Win 9X or ME can be found in the "PROMPT" parameter ID. Returns are limited in Win 9X and ME.
* ''Note:'' '''QB64''' may not return the same environment list as Qbasic or SET does in DOS.
@ -36,6 +39,32 @@ The '''ENVIRON$''' function returns a [[STRING]] environmental value from the PC
{{Cl|IF...THEN|IF}} i {{Cl|MOD}} 20 = 0 {{Cl|THEN}} {{Cl|PRINT}} "Press a key": {{Cl|SLEEP}}: {{Cl|CLS}}
{{Cl|LOOP}} {{Cl|UNTIL}} setting$ = ""
{{CodeEnd}}
{{OutputStart}}
ALLUSERSPROFILE=C:\ProgramData
COMPUTERNAME=TED-LAPTOP
ComSpec=C:\WINDOWS\system32\cmd.exe
HOMEDRIVE=C:
HOMEPATH=\Users\Ted
LOCALAPPDATA=C:\Users\Ted\AppData\Local
OS=Windows_NT
Path=C:\PROGRAMDATA\ORACLE\JAVA\JAVAPATH;C:\WINDOWS\SYSTEM32;C:\WINDOWS;
C:\WINDOWS\SYSTEM32\WBEM;C:\WINDOWS\SYSTEM32\WINDOWSPOWERSHELL\V1.0\;C:\
WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32
\WindowsPowerShell\v1.0\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 14 Stepping 8, GenuineIntel
ProgramFiles=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
SystemRoot=C:\WINDOWS
TEMP=C:\Users\TED\AppData\Local\Temp
TMP=C:\Users\TED\AppData\Local\Temp
USERDOMAIN=TED-LAPTOP
USERNAME=Ted
USERPROFILE=C:\Users\Ted
{{OutputEnd}}
:''Note:'' Windows environmental settings are listed alphabetically, 20 at a time. '''QB64 may not read all of them or return an empty string!''' The settings above were returned with SET in DOS. PROMPT returned nothing where SET returned $P$G.
''Example 2:'' Creating a shortcut on a user's desktop for QB64.EXE using the program's icon. Must be run in program's folder to work!

View file

@ -1,4 +1,4 @@
The '''ENVIRON''' statement is used to temporarily set or change an environmental string value.
The '''ENVIRON''' statement is used '''in Windows''' to temporarily set or change an environmental string value.

View file

@ -3,7 +3,7 @@ The '''EOF''' Function indicates that the end of a file has been reached.
{{PageSyntax}}
:: DO WHILE [[NOT]] EOF(filenumber%)
:: DO WHILE [[NOT]] EOF(filenumber&)
* Filenumber is the number of the file being read. # is not required.

View file

@ -2,7 +2,7 @@ The '''FIELD''' statement creates a [[STRING]] type definition for a [[RANDOM|ra
{{PageSyntax}}
:{{KW|FIELD}} [#]{{Parameter|fileNumber%}} {{Parameter|fieldWidth1%}} AS {{Parameter|variable1$}}[, {{Parameter|fieldWidthN%}} AS {{Parameter|variableN$}}]
:{{KW|FIELD}} [#]{{Parameter|fileNumber&}} {{Parameter|fieldWidth1%}} AS {{Parameter|variable1$}}[, {{Parameter|fieldWidthN%}} AS {{Parameter|variableN$}}]
{{PageDescription}}
@ -15,9 +15,7 @@ The '''FIELD''' statement creates a [[STRING]] type definition for a [[RANDOM|ra
* Do NOT re-assign a field defined variable value or use it in an [[INPUT]] statement if you want the variable to remain a field!
''Example:'' Comparing a TYPE definition with a FIELD {{KW|STRING|string}} definition.
Demo using a TYPE definition to create a file:
''Example:'' Comparing a [[TYPE]] definition with a FIELD [[STRING|string]] definition. Demo using a [[TYPE]] definition to create a file:
{{CodeStart}} '' ''
{{Cl|TYPE}} ClientType
CName {{Cl|AS}} {{Cl|STRING}} * 30 '30 bytes
@ -83,9 +81,9 @@ Demo using the FIELD statement to read the file:
{{PageSeeAlso}}
* {{KW|OPEN}}
* {{KW|GET}}, {{KW|PUT}}
* {{KW|LSET}}, {{KW|RSET}}
* [[OPEN]], [[TYPE]]
* [[GET]], [[PUT]]
* [[LSET]], [[RSET]]
{{PageNavigation}}

View file

@ -102,11 +102,14 @@ A member created a [[FILELIST$ (function)]] that uses the mouse and does not aff
* [[SHELL]], [[SCREEN (function)]] {{text|(See Example 2)}}
* [[CHDIR]], [[MKDIR]]
* [[RMDIR]], [[KILL]]
* [[_CWD$]], [[_STARTDIR$]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
* [[DOS]], [[Batch Files]], [[DOS#DIR|DIR]]
* [[Windows_Libraries#File_Exist|Windows File Exist Library]]
* [[Windows_Libraries#File_Open_and_Save_Dialog|Windows Open and Save Dialog Boxes]]
* [[C_Libraries#Console_Window|C Console Library]]
* [[FILELIST$]], [[DIR$]] {{text|(member file list array functions)}}
{{PageNavigation}}

View file

@ -3,11 +3,17 @@ The '''FIX''' function rounds a numerical value to the next whole number closest
{{PageSyntax}}
:: result = [[FIX]](''expression'')
:: result = '''FIX('''''expression''''')'''
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* [[FIX]] effectively truncates (removes) the fractional part of ''expression'', returning the integer part.
* This means that [[FIX]] rounds down for positive values and up for negative values.
* Use [[INT]] to round down negative values. Positive values are rounded down by both.
''Example 1:'' Showing the behavior of [[FIX]] with positive and negative decimal point values.
@ -43,9 +49,10 @@ The '''FIX''' function rounds a numerical value to the next whole number closest
''See also:''
* [[CINT]], [[CLNG]], [[_ROUND]]
* [[INT]], [[CINT]]
* [[CLNG]], [[_ROUND]]
* [[MOD]], [[\|Integer Division]]
* [[/|Normal division]]
{{PageNavigation}}

View file

@ -3,24 +3,32 @@ The '''FOR''' statement creates a counter loop using specified start and stop nu
{{PageSyntax}}
:: '''FOR ''counter_variable'' = ''start_value'' TO ''stop_value''''' [STEP ''increment'']
:: '''FOR ''counter_variable'' = ''start_value'' [[TO]] ''stop_value''''' [{{KW|STEP}} ''increment'']
:: .
:: .
:: .
:: '''NEXT''' [''counter_variable'']
{{Parameters}}
* The FOR ''counter_variable'' name is required to define the counter span and may also be used after the NEXT keyword.
* The ''start_value'' [[TO]] ''stop_value'' can be any literal or variable numerical type. BOTH values are required!
* [[STEP]] can be used for a loop ''increment'' other than the default plus 1 and can be any positive or negative literal or variable numerical value as long as the STEP value corresponds to the loop's ''start value'' and ''stop value''s.
* [[NEXT]] ends the FOR loop code block and increments the counter to the next value even when it exceeds the stop limit.
''Usage:''
* FOR NEXT counter loops must be within the proper start, stop and increment values or the entire loop code block will not be executed.
* Avoid changing the FOR ''counter_variable'''s value inside of the loop. This obfuscates code and is a poor programming practice!
* Once the loop has been started, changing the ''start_value'', ''stop_value'' or ''increment'' value will not affect loop execution.
* Use '''[[EXIT]] FOR''' to leave a FOR loop early when a certain condition is met inside of the loop.
* [[STEP]] can be used for a loop ''increment'' other than the default 1 and can be any literal or variable numerical value.
* '''If the [[STEP]] ''increment'' value does not match the ''start_value'' [[TO]] ''stop_value'' the FOR loop block will be ignored!'''
:* If ''start_value'' is less than ''stop_value'', use default increment or positive [[STEP]] value or the loop will NOT be executed.
:* If ''start_value'' is more than ''stop_value'', use a negative [[STEP]] interval or the loop will NOT be executed.
:* The [[STEP]] ''increment'' value cannot be changed inside of the loop!
* Use '''[[EXIT]] FOR''' to leave a FOR loop early when a certain condition is met inside of the loop.
* The [[NEXT]] counter variable name is not required. NEXT loop increments can be separated by colons in nested FOR loops.
* '''NOTE: The counter value AFTER a FOR loop will be incremented one more than the ''stop_value'' requested by the loop!'''
* '''Beware of FOR loop counts that EXCEED the count variable's type limits and may repeat without error in QB64!'''
@ -51,6 +59,10 @@ PRINT "After loop, i ="; i '' ''
bye {{OutputEnd}}
''See Example:''
* [http://qb64.net/wiki/index.php?title=Controller_Devices#Example Example that shows how ignoring bad FOR loops can work to a program's advantage without errors.]
''See also:''
* [[NEXT]], [[STEP]]
* [[DO...LOOP]], [[WHILE...WEND]]

View file

@ -1,4 +1,4 @@
The '''FREEFILE''' function returns an unused file access number.
The '''FREEFILE''' function returns an [[INTEGER]] value that is an unused file access number.
{{PageSyntax}}
@ -6,7 +6,9 @@ The '''FREEFILE''' function returns an unused file access number.
* FREEFILE values should be given to unique variables so that each file has a specific variable value assigned to it.
* The file number variable can later be used to read, write or [[CLOSE]] that file.
* Once the number is assigned in an [[OPEN]] statement, the file number can later be used to read, write or [[CLOSE]] that file.
* Files numbers [[CLOSE]]d are made available to FREEFILE for reuse immediately.
* FREEFILE returns are normally sequential starting with 1. Only file numbers in use will not be returned.
* [[OPEN]] each file number after each FREEFILE return or the values returned may be the same!
* [[OPEN COM]] statements cannot use any number assigned to files already OPEN!

View file

@ -2,30 +2,33 @@ A '''FUNCTION''' block statement is used when creating a function procedure to r
{{PageSyntax}}
:: '''FUNCTION name'''[type-suffix] [(''parameters'')]
:: .
:: .
:: .
:: '''FUNCTION procedure_name'''[type-suffix] [(''parameters'')]
:: ...
:: ... 'variable definitions and procedure statements
:: ...
:: '''END FUNCTION'''
* The function type can be any variable type that it will return to the program and is represented by the type suffix. '''Currently cannot use FUNCTION name [[AS]] type!'''
* The function type can be any variable type that it will return to the program and is represented by the type suffix.
* '''QB64 currently cannot use FUNCTION name [[AS]] type!''' This VB functionality is promised in the future.
* Functions hold ONE return value in the function's name which is a variable type. Other values can be passed through ''parameter(s)''.
* Functions are often referred to in program calculations, not called like SUB procedures. [[CALL]] cannot be used with functions!
* If there are no parameters passed or they are [[SHARED]] the ''parameters'' and parenthesis are not required.
* The [[IDE]] may '''require''' that an '''intermediate variable''' be used when calculations define the function's value more than once! In those cases, make the Function's name equal to the intermediate variable's value at the end of the Function.
* Variable names within the procedure do not have to match the names used in the reference parameters, just the value types.
* A Function needs to return the value to something such as a variable or as a argument for a sub, function or statement.
* All [[$DYNAMIC|dynamic]] variable values return to 0 or null strings when the procedure is exited except when a variable or the entire function is [[STATIC]]. This can save program memory as all [[$DYNAMIC|dynamic]] memory used in a FUNCTION is released on procedure exit.
* FUNCTION procedure code can use [[GOSUB]] and [[GOTO]] line numbers or labels inside of the procedure when necessary.
* For early function exits use [[EXIT]] [[FUNCTION]] before [[END FUNCTION]] and [[GOSUB]] procedures using [[RETURN]].
* Once a FUNCTION is created and used, the Qbasic IDE will [[DECLARE]] it when the file is saved. QB64 doesn't need them!
* Functions are often referred to in program calculations, not called like SUB procedures. [[CALL]] cannot be used!
* The [[IDE]] can create the FUNCTION and END FUNCTION lines for you. Use the Make FUNCTION option in the Edit Menu. A box will come up for you to enter a name for the FUNCTION. Enter all code between the FUNCTION and [[END FUNCTION]] lines.
* '''QB64 ignores all procedural [[DECLARE]] statements!''' Define all ''parameter'' [[TYPE]]s in the FUNCTION procedure.
* Qbasic's IDE may place a [[DEFINT]], [[DEFSNG]], [[DEFLNG]], [[DEFDBL]] or [[DEFSTR]] statement before the FUNCTION line if it is used in the main module. It may even be the wrong variable type needed. It can be changed or removed when necessary.
* '''Images are not deallocated when the [[SUB]] or [[FUNCTION]] they are created in ends. Free them with [[_FREEIMAGE]].'''
* '''WARNING! Do not place DATA fields after [[SUB]] or [[FUNCTION]] procedures! QB64 will FAIL to compile properly!'''
: Qbasic allowed programmers to add DATA fields anywhere because the [[IDE]] separated the main code from other procedures.
* '''Recursive Functions will require a parameter to repeat internal references currently in QB64.'''
<center>'''Qbasic'''</center>
* Once a FUNCTION is created and used, the Qbasic IDE will [[DECLARE]] it when the file is saved. QB64 doesn't need them!
* The [[IDE]] can create the FUNCTION and END FUNCTION lines for you. Use the Make FUNCTION option in the Edit Menu. A box will come up for you to enter a name for the FUNCTION. Enter all code between the FUNCTION and [[END FUNCTION]] lines.
* Qbasic's IDE may place a [[DEFINT]], [[DEFSNG]], [[DEFLNG]], [[DEFDBL]] or [[DEFSTR]] statement before the FUNCTION line if it is used in the main module. It may even be the wrong variable type needed. It can be changed or removed when necessary.
* Qbasic allowed programmers to add DATA fields anywhere because the [[IDE]] separated the main code from other procedures.
''Example 1:'' A simple function that returns the current path. Place [[FUNCTION]] or [[SUB]] procedures after the program [[END]].

View file

@ -3,7 +3,7 @@ The '''GET #''' file or port device statement reads data by bytes or record posi
{{PageSyntax}}
:: '''GET #''filenumber%'',''' [''position''][, {''holdingvariable''|''holdingarray()''}]
:: '''GET #''filenumber&'',''' [''position''][, {''holdingvariable''|''holdingarray()''}]

View file

@ -42,7 +42,8 @@ GET (in regard to TCP/IP) reads unformatted(raw) data from an open connection, o
* [[PUT (TCP/IP statement)]], [[INPUT (TCP/IP statement)]]
* [[_OPENCLIENT]], [[_OPENHOST]]
* [[_OPENCONNECTION]], [[GET|GET #]]
* [[IP Configuration]], [[WGET]] (HTTP and FTP file transfer)
* [[IP Configuration]]
* [https://curl.haxx.se/ cURL], [[WGET]] (HTTP and FTP file transfer)
{{PageNavigation}}

View file

@ -2,7 +2,7 @@ The {{KW|GET (graphics statement)|GET}} statement is used in graphics to store a
{{PageSyntax}}
::: '''GET (''column1'', ''row1'')-(''column2'', ''row2''), ''Array''('''[''index'']''')'''[, ''offscreen_color'']
::: '''GET''' [STEP] '''(''column1'', ''row1'')-'''[STEP]'''(''column2'', ''row2''),''' ''Array''([''index''])[, ''offscreen_color'']
''[[Parameters]]:''
@ -13,8 +13,9 @@ The {{KW|GET (graphics statement)|GET}} statement is used in graphics to store a
''Usage:''
* The [[STEP]] keyword can be used to for coordinates relative to the last graphic coordinates used.
* A graphic screen mode MUST be used! See the [[SCREEN]] statement for graphic screen dimensions.
* '''QB64''' GET statements can use coordinates off of the screen when an ''off screen color'' is designated.
* '''QB64''' GET statements can use coordinates off of the screen when an ''off screen color'' is designated. [[STEP]] can be used for relative coordinates.
* The GET box coordinates are set just like a {{KW|LINE}} box statement is placed. You can use a box to find the correct GET area.
* Once GET has placed the pixel image data in the array, PUT the image or BSAVE it to a file.
* Once the image is stored in an array {{KW|PUT (graphics statement)|PUT}} can be used to place the image on the screen.
@ -68,34 +69,34 @@ The {{KW|GET (graphics statement)|GET}} statement is used in graphics to store a
{{CodeEnd}}
''Example 2:'' How to GET graphics from an image other than the present screen.
''Example 2:'' How to GET graphics from an image other than the present screen using [[_SOURCE]] and [[_DEST]]ination.
{{CodeStart}} '' ''
{{Cl|DIM}} img(20 * 20 + 4) {{Cl|AS}} {{Cl|INTEGER}} 'create img array to hold image data
a = {{Cl|_NEWIMAGE}}(800, 600, 13) 'image screen a emulates screen 13
{{Cl|DIM}} img(20 * 20 + 4) {{Cl|AS}} {{Cl|INTEGER}} 'create img% array to hold 20 by 20 image data
a& = {{Cl|_NEWIMAGE}}(800, 600, 13) 'larger surface a& emulates screen 13 colors & resolution
{{Cl|SCREEN (statement)|SCREEN}} 13 'program screen 13
{{Cl|_DEST}} a 'set desination as the image page a
{{Cl|_DEST}} a& 'set desination as the image page a&
{{Cl|CIRCLE}} (700, 300), 10, 10 'draw green circle on image page
{{Cl|_SOURCE}} a 'set source as image page a
{{Cl|GET}} (690, 290)-(710, 310), img()
{{Cl|_SOURCE}} a& 'set source as image page a&
{{Cl|GET}} (690, 290)-(710, 310), img() 'GET a square screen area similar to a LINE Box.
{{Cl|_DEST}} 0 'set destination as the program screen
{{Cl|PUT}} (100, 100), img() '' ''
{{Cl|PUT}} (100, 100), img() 'PUT the Top Left Corner of box area to pixel 100, 100
{{CodeEnd}}
: ''Notes:'' A [[_LOADIMAGE]] handle could also be used as a [[_SOURCE|source]] to GET a portion or all of an image file.
{{PageSeeAlso}}
* [[_PUTIMAGE]], [[_LOADIMAGE]]
* [[_MAPTRIANGLE]]
* [[PUT (graphics statement)|PUT]], [[BSAVE]], [[BLOAD]]
* [[PUT (graphics statement)|PUT]], [[STEP]]
* [[BSAVE]], [[BLOAD]]
* [[Scancodes]], [[Creating Sprite Masks]] {{text|(for non-box shaped sprites)}}
* [[Bitmaps]], [[GET and PUT Demo]]
{{PageNavigation}}

View file

@ -15,7 +15,30 @@
{{PageExamples}}
''Example:''
''Example:'' Simple usage of GOSUB
{{CodeStart}}
{{Cl|PRINT}} "1. It goes to the subroutine."
{{Cl|GOSUB}} subroutine
{{Cl|PRINT}} "3. And it returns."
{{Cl|END}}
subroutine:
{{Cl|PRINT}} "2. It is at the subroutine."
{{Cl|RETURN}}
{{CodeEnd}}
{{small|Code by Cyperium}}
{{OutputStart}}
1. It goes to the subroutine.
2. It is at the subroutine.
3. And it returns.
{{OutputEnd}}
''Example:'' What happens if two GOSUB executes then two RETURN's?
{{CodeStart}}
start:

View file

@ -3,7 +3,11 @@ The '''GOTO''' statement sends the procedure to a line label or a line number in
{{PageSyntax}}
::GOTO {linenumber|linelabel}
::GOTO {line_number|line_label}
''IF GOTO {{PageSyntax}}
:: IF x > 0 [[GOTO]] {line_number|line_label}
* Codeline is a ''[[line number|linenumber]]'' or ''linelabel'' in a procedure. Keep line numbers and labels inside of the main or sub-procedure body!
@ -37,7 +41,9 @@ second line
* [[GOSUB]], [[ON ERROR]]
* [[ON...GOTO]], [[ON...GOSUB]]
* [[DO...LOOP]], [[FOR...NEXT]]
* [[Line number]] {{text|(removal program)}}
* [[IF...THEN]], [[SELECT CASE]]
* [[line number]] /label
* [[Line number|Line number removal program]]
{{PageNavigation}}

View file

@ -10,7 +10,7 @@ The {{KW|HEX$}} function returns the base 16 hexadecimal representation of an [[
* If the parameter is not an Integer, it will be converted to one by HEX$.
* The function does not return a leading sign space so [[LTRIM$]] is not necessary.
* Can be used in place of [[STR$]] to trim both sides of positive decimal values 0 to 9 only.
* [[VAL]] can convert the string value back to a decimal value by prefixing the string return with "&H".
* [[VAL]] can convert the string value back to a decimal value by prefixing the string return with "&H", like; dec = VAL("&H" + hexvar$).
''Example:'' Comparing decimal, hexadecimal and octal string values 0 to 15.
@ -46,6 +46,20 @@ NEXT n% '' ''
''Note:'' Decimal [[STR$]] values contain a leading sign space so values require an extra space in the template using the slash format.
''Example:'' Converting hex value to decimal.
{{CodeStart}}
h$ = {{Cl|HEX$}}(255)
{{Cl|PRINT}} "Hex: "; h$
{{Cl|PRINT}} "Converting Hex value to Decimal:"; {{Cl|VAL}}("&H" + h$)
{{CodeEnd}}
{{OutputStart}}
Hex: FF
Converting Hex value to Decimal: 255
{{OutputEnd}}
{{PageSeeAlso}}
* [[OCT$]], [[STR$]], [[VAL]]
* [[&H]] {{text|(hexadecimal)}}, [[&O]] {{text|(octal)}}, [[&B]] {{text|(binary)}}

View file

@ -2,20 +2,26 @@
{{PageSyntax}}
:: IF ''condition'' THEN ''action'' {{Cb|ELSE}} evaluation = 0
''Line'' {{PageSyntax}}
:: '''IF''' ''condition statement'' '''THEN''' ''action'' [[ELSE]] other_action
:: '''IF''' ''condition statement'' [[GOTO]] ''linelabel''
''Block {{PageSyntax}}
:: IF ''condition statement'' [[THEN]]
''Block'' {{PageSyntax}}
:: '''IF''' ''condition statement'' '''[[THEN]]'''
::: ''action''
:: [[ELSEIF]] ''condition statement'' [[THEN]] ''action''
:: [[ELSEIF]] ''condition statement'' '''[[THEN]]''' ''action''
:: [[ELSE]] ''action''
:: [[END IF]]
:: '''END IF'''
* The ''conditional'' evaluation by '''IF''' must be true(-1) or a non-zero numerical value for the THEN ''action'' statements to be executed.
''GOTO {{PageSyntax}}
:: '''IF''' x > 0 [[GOTO]] {line_number|line_label}
* The ''conditional'' evaluation by '''IF''' must be true(-1) or a '''non-zero numerical value''' for the THEN ''action'' statements to be executed.
* Multiple conditional evaluations can be made using inclusive [[AND (boolean)|AND]] or alternative [[OR (boolean)|OR]] conditional expressions.
* [[THEN]] is not required when [[GOTO]] is used to send program flow to a line number or label.
* IF statements can also have alternative evaluations using [[ELSEIF]] and [[ELSE]] conditions.
* When the '''IF''' statement and/or code to be run is more than code line, an [[END IF]] statement '''MUST''' be used.
* With multiple code lines to run, end the IF statement with THEN and place all of the code on lines below that line.
@ -24,6 +30,7 @@
* The '''QB64''' IDE may red line the IF THEN statement line until END IF closes the statement block.
* Use '''[[colon]]s''' to execute multiple statements in a one line IF statement. You cannot use [[AND]] statements after [[THEN]]!
* An '''[[underscore]]''' can be used anywhere after the code on one line to continue it to the next line in '''QB64 ONLY'''.
* '''NOTE:''' [[STRING]] values can only be evaluated in an IF statement if a value is compared to a literal or [[CHR$]] string value. '''QB64 may not compile literal IF string statements or indicate an [[IDE]] coding error!''' Use [[LEN]] or [[ASC]] to compare strings numerically.
@ -51,39 +58,45 @@
''Example 1:'' One line IF statement
''Example 1:'' In a one line IF statement, only [[REM]] can be used to comment out the action without an [[END IF]] error:
{{CodeStart}} '' ''
IF x > 100 THEN PRINT x '' ''
{{Cl|INPUT}} "Enter a number over or under 100: ", x
{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}} {{Cl|PRINT}} x
{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}} {{Cl|REM}} {{Cl|PRINT}} x '' '
{{CodeEnd}}
''Example 2:'' IF statement blocks require that the IF THEN and END IF statements be separate from the code executed.
{{CodeStart}} '' ''
IF x > 100 THEN
{{Cl|INPUT}} "Enter a number over or under 100: ", x
{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}}
y = 200
PRINT y
PRINT x
END IF '' ''
{{Cl|PRINT}} y
{{Cl|PRINT}} x
{{Cl|END IF}} '' ''
{{CodeEnd}}
''Example 3:'' True or False evaluation of a numerical value executes only when the value is not 0. '''Cannot evaluate [[STRING]] values!'''
{{CodeStart}} '' ''
IF x THEN PRINT x '' ''
{{Cl|INPUT}} "Enter a number or just hit Enter: ", x
{{Cl|IF...THEN|IF}} x {{Cl|THEN}} {{Cl|PRINT}} x '' ''
{{CodeEnd}}
:Example will only print if a numerical value is True (positive or negative). (Equivalent to: IF x > 0 OR x < 0 THEN evaluation)
''Example 4:'' Multiple evaluations using parenthesis to determine the order.
{{CodeStart}} '' ''
IF (value% > 100 AND value% < 200) OR value% = 50 THEN PRINT "OK" '' ''
{{Cl|INPUT}} "Enter a number over or under 100 or 50: ", value
{{Cl|IF...THEN|IF}} (value% > 100 {{Cl|AND (boolean)|AND}} value% < 200) {{Cl|OR (boolean)|OR}} value% = 50 {{Cl|THEN}} {{Cl|PRINT}} "OK" '' ''
{{CodeEnd}}
''Example 5:'' Using multiple IF options in a one line statement.
{{CodeStart}} '' ''
x = 100 'change x value to see other evaluations
IF x > 200 THEN PRINT "High" {{Cl|ELSEIF}} x < 0 THEN PRINT "Low" {{Cl|ELSE}} PRINT "OK" '' ''
{{Cl|INPUT}} "Enter a number over or under 200: ", x
{{Cl|IF...THEN|IF}} x > 200 {{Cl|THEN}} {{Cl|PRINT}} "High" {{Cl|{{Cl|ELSEIF}}}} x < 0 {{Cl|THEN}} {{Cl|PRINT}} "Low" {{Cl|{{Cl|ELSE}}}} {{Cl|PRINT}} "OK"
'' ''
{{CodeEnd}}
@ -97,10 +110,25 @@ IF Key$ >= {{Cl|CHR$}}(65) AND Key$ <= {{Cl|CHR$}}(90) THEN PRINT "A
: ''Explanation:'' Long [[STRING]] expression values are compared by their cumulative [[ASCII]] code values.
<center>'''Qbasic decimal point value comparison errors'''</center>
* Floating decimal point numerical values may not be compared as exactly the same value. QB64 will compare them the same.
:''Example:'' Qbasic will print ''unequal'' in the IF comparison code below even though it is exactly the same value printed.
{{CodeStart}} '' ''
x# = 5 / 10
y# = 6 / 10
z# = x# + y#
{{Cl|PRINT}} x#, y#, z#
{{Cl|IF...THEN|IF}} x# + y# = z# {{Cl|THEN}} {{Cl|PRINT}} "equal" {{Cl|ELSE}} {{Cl|PRINT}} "unequal" '' ''
{{CodeEnd}}
: Note: QB64 will make the calculation correctly and print ''equal''. Change older program code that relies on the error accordingly.
''See also:''
*[[ELSEIF]], [[ELSE]]
*[[AND (boolean)]], [[OR (boolean)]]
*[[NOT]], [[SELECT CASE]], [[Boolean]]
* [[ELSEIF]], [[ELSE]]
* [[AND (boolean)]], [[OR (boolean)]]
* [[NOT]], [[GOTO]]
* [[SELECT CASE]]
* [[Boolean]] {{text|(numerical comparisons return a True or False value)}}
{{PageNavigation}}

View file

@ -88,23 +88,24 @@ The '''INKEY$''' Function returns user input as [[ASCII]] [[STRING]] character(s
==Examples==
''Example 1:'' Clearing the keyboard buffer
{{CodeStart}} '' ''
DO: LOOP UNTIL INKEY$ = "" '' ''
''Example 1:'' Clearing the keyboard buffer after [[SLEEP]] delays for later [[INPUT]].
{{CodeStart}}{{Cl|PRINT}} "Press any keyboard typing key to end SLEEP"
{{Cl|SLEEP}}
{{Cl|DO}}: K$ = {{Cl|INKEY$}}: {{Cl|PRINT}} K$: {{Cl|LOOP}} {{Cl|UNTIL}} K$ = "" '' ''
{{CodeEnd}}
:''Explanation:'' [[SLEEP]] key presses will be kept in the keyboard buffer and may be added into an [[INPUT]] later!
''Example 2:'' Entering a Ctrl + letter keypress combination.
{{CodeStart}}
{{Cl|PRINT}} "Press Ctrl + P to Print!"
DO: K$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} K$ <> ""
{{Cl|IF...THEN|IF}} K$ = {{Cl|CHR$}}(16) {{Cl|THEN}} {{Cl|PRINT}} "Ctrl + P was pressed! " + K$ {{Cl|ELSE}} {{Cl|PRINT}} K$ '' ''
''Example 2:'' Entering a Ctrl + letter keypress combination will print [[ASCII]] Control characters 1 to 26. .
{{CodeStart}}DO
K$ = {{Cl|INKEY$}}
{{Cl|IF...THEN|IF}} K$ <> "" {{Cl|THEN}} {{Cl|PRINT}} K$; " ";
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27) 'Esc key exit '' ''
{{CodeEnd}}
: ''Note:'' Other control key + letter combinations will print other [[ASCII]] control characters.
: ''Note:'' The above code will print Esc arrow, Backspace symbol, and 2 byte characters led by CHR$(0) in addition to normal keys.
''Example 3:'' In a keyboard read loop looking for uppercase "Y" or "N".
''Example 3:'' Use [[UCASE$]](INKEY$) in a keyboard read loop looking for uppercase "Y" or "N" user inputs to avoid multiple IF statements.
{{CodeStart}} '' ''
{{Cl|DO...LOOP|DO}}
{{Cl|PRINT}} "Do you want to continue? (Y/N): "; 'semicolon saves position for user entry
@ -136,6 +137,64 @@ DO: K$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} K$ <> ""
: ''Explanation:'' [[SLEEP]] waits for a keypress. It also allows background programs to share the processor and it leaves the keypress in the buffer for INKEY$. Keyboard string number characters range from [[ASCII]] codes 48 to 57. Any other entry is ignored by the IF statement. A decimal point (code 46) entry is allowed once in the input. The flag value stops further decimal point additions. Backspacing (code 8) is also allowed if the entry has at least one character. The cursor column returned by [[POS]](0) reverts too after the end of the entry when printed each loop. The loop exits when [Enter] (code 13) is pressed and the entry has a length.
''Example 5:'' Using arrow keys to move a text character. A change from a previous position tells program when to PRINT:
{{CodeStart}}movey = 1: movex = 1 'text coordinates can never be 0
at$ = "@" 'text sprite could be almost any ASCII character
{{Cl|LOCATE}} movey, movex: {{Cl|PRINT}} at$;
DO
px = movex: py = movey 'previous positions
B$ = {{Cl|INKEY$}}
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(72) {{Cl|AND (boolean)|AND}} movey > 1 {{Cl|THEN}} movey = movey - 1 'rows 1 to 23 only
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(80) {{Cl|AND (boolean)|AND}} movey < 23 {{Cl|THEN}} movey = movey + 1
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(75) {{Cl|AND (boolean)|AND}} movex > 1 {{Cl|THEN}} movex = movex - 1 'columns 1 to 80 only
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(77) {{Cl|AND (boolean)|AND}} movex < 80 {{Cl|THEN}} movex = movex + 1
{{Cl|IF...THEN|IF}} px <> movex {{Cl|OR (boolean)|OR}} py <> movey {{Cl|THEN}} 'only changes when needed
{{Cl|LOCATE}} py, px: {{Cl|PRINT}} {{Cl|SPACE$}}(1); 'erase old sprite
{{Cl|LOCATE}} movey, movex: {{Cl|PRINT}} at$; 'show new position
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} B$ = {{Cl|CHR$}}(27) 'ESCape key exit
{{Cl|END}}
{{CodeEnd}}
''Example 6:'' Using INKEY$ with the arrow or WASD keys to move the QB64 bee image sprite with [[_PUTIMAGE]]:
{{CodeStart}} '' ''
{{Cl|DIM}} image {{Cl|AS}} {{Cl|LONG}}
{{Cl|DIM}} x {{Cl|AS}} {{Cl|INTEGER}}
{{Cl|DIM}} y {{Cl|AS}} {{Cl|INTEGER}}
{{Cl|DIM}} Keypress {{Cl|AS}} {{Cl|STRING}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32)
x = 0
y = 0
image = {{Cl|_LOADIMAGE}}("QB64bee.png") 'Here I actually used the QB64 icon
DO
{{Cl|_PUTIMAGE}} (x, y), image
DO
Keypress = {{Cl|UCASE$}}({{Cl|INKEY$}})
' ***** The following line detects the arrow keys *****
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(Keypress) > 1 {{Cl|THEN}} Keypress = {{Cl|RIGHT$}}(Keypress, 1)
{{Cl|LOOP}} {{Cl|UNTIL}} Keypress > ""
{{Cl|CLS}} ' blank screen after valid key press to avoid smearing image on page
{{Cl|SELECT CASE}} Keypress
{{Cl|CASE}} "W", "H": y = y - 10 'Up
{{Cl|CASE}} "A", "K": x = x - 10 'Left
{{Cl|CASE}} "S", "P": y = y + 10 'Down
{{Cl|CASE}} "D", "M": x = x + 10 'Right
{{Cl|CASE}} "Q", {{Cl|CHR$}}(27): {{Cl|END}} 'Q or Esc Ends prog.
{{Cl|END SELECT}}
{{Cl|_PUTIMAGE}} (x, y), image
{{Cl|LOOP}} '' ''
{{CodeEnd}} {{small|Adapted from code by Daniel}}
: ''Note:'' The image can be placed off of the screen without error! The image moves 10 pixels to move faster. [[CLS]] eliminates any background.
''See also:''
* [[_KEYHIT]], [[_KEYDOWN]], [[_MAPUNICODE]]
* [[INPUT]], [[LINE INPUT]]

View file

@ -3,26 +3,32 @@ The '''INPUT''' statement requests a [[STRING]] or numerical keyboard entry from
{{PageSyntax}}
:: '''INPUT''' [;] '''"'''[Question or statement text]'''"{,|;}''' '''''variable[[type]]'''''[, ...]
:: '''INPUT ; ''variable[[type]]'''''[, ...]
:: '''INPUT''' [;] '''"'''[Question or statement text]'''"{,|;}''' '''''variable'''''[, ...]
:: '''INPUT ; ''variable'''''[, ...]
''[[Parameters]]:''
* [[semicolon]] after the INPUT keyword keeps the entry on the same row after enter is pressed and prevents screen roll.
* [[Quotation mark]]s are required except when just a semicolon follows INPUT. Just a question mark will appear before the entry cursor.
* The text MUST be a literal [[STRING|string]] created by the programmer if used. '''Use a [[PRINT]] before INPUT to create text using variables.'''
* The quoted text or question MUST be a literal [[STRING|string]] created by the programmer if used. '''Quoted text cannot use variables!'''
* [[Quotation mark]]s are required except when a semicolon follows INPUT. A question mark will appear before entry cursor.
* [[semicolon]] immediately after the text statement will display a ? mark with a space after it. Use a [[comma]] for input statements.
* ''variable [[type]]'' determines the allowable numerical value entries in QB64. Text can't be entered for numerical values except D, E or [[HEX$]].
* ''variable [[type]]'' determines the allowable numerical value entries in QB64. Text numerical entries limited to D, E, [[&H]], [[&O]] or [[&B]].
''Usage:''
* '''QB64 will not return Redo from start errors''' as user input is limited to input within the scope of the variable [[type]] used.
* INPUT is capable of returning more than one ''variable'' value by separating input variables with commas in the statement. The user will have to know to separate each entry value with a comma when they use it. '''Use [[LINE INPUT]] for text entries that may contain commas!'''
* [[STRING|String]] and numerical variables can both be used in multiple entry requests. Text cannot be entered as numerical variable values!
:: Text entries can use any entry including numerical. '''QB64 will ignore commas in single variable text entries!'''
:: Numerical entries can use numbers only up to the input variable's numerical [[TYPE]] limit.
:: [[INTEGER]], [[LONG]], and [[_INTEGER64]] entries will ignore decimal points entered and will use all numbers.
* INPUT is capable of returning more than one ''variable'' value by separating input variables with commas in the statement.
::The program user will have to know to separate each entry value with a comma when they use it.
:: [[STRING|String]] and numerical variables can both be used in multiple entry requests separated by commas.
:: '''QB64 will allow comma separated entries to not be entered by the user without error!'''
* '''Use [[LINE INPUT]] for text input entries that may contain commas such as address or name entries!'''
* The user must press enter for the INPUT procedure to end. Multiple entries can be skipped.
* Will accept the [[scientific notation]] letter D or E inside of [[SINGLE]] or [[DOUBLE]] numerical values.
* Numerical entries starting with [[&H]], [[&O]] and [[&B]] can be made also.
* INPUT removes all spaces preceeding or following a string value entry. QB64 doesn't remove the spaces
* INPUT removes all leading or trailing spaces in a string value entry. '''QB64 does NOT remove those spaces!'''
* The statement stops a program until enter is pressed. Not good in programs using a mouse (see [[INKEY$]] loops).
* Use [[_DEST]] [[_CONSOLE]] before INPUT statements to be used in a [[$CONSOLE|console]] window.
@ -55,8 +61,8 @@ You can drink beer!
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 29, 2 ' place dursor at beginning of prompt liine
{{Cl|PRINT}} "Enter a name to search for... "; 'print prompt on screen
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 29, 2 ' place cursor at beginning of prompt line
{{Cl|PRINT}} "Enter a name to search for... "; 'print prompt on screen with input to follow
{{Cl|COLOR}} 15: {{Cl|INPUT}} {{text|;|red}} "", name$ ' get search name from user
{{Cl|LOCATE}} 29, 2: {{Cl|PRINT}} {{Cl|SPC}}(78); ' erase previous prompt
n$ = {{Cl|UCASE$}}(name$) ' convert search name to upper case

View file

@ -11,6 +11,7 @@ The '''INPUT''' file mode can only [[OPEN]] existing files with data in them for
* Use the [[EOF]] function to avoid reading data past the end of a file and creating an [[ERROR Codes|INPUT error]]!
* Input file statements will use the same filenumber as the OPEN statement.
* The INPUT mode allows the same file to be opened in another mode with a different number.
* '''NOTE: [[LINE INPUT (file statement)|LINE INPUT]] will work faster in [[BINARY]] than INPUT mode in QB64 to stay compatible with QB.'''
''Example:'' Avoiding an INPUT mode or [[INPUT (file statement)|INPUT #]] read error using a FileExist function. QB64 can use the [[_FILEEXISTS]] function.

View file

@ -3,17 +3,18 @@ The '''INPUT #''' file or port statement reads sequential data using one variabl
{{PageSyntax}}
:: '''INPUT #''filenumber%'', ''variable_type'''''[, listof!, variables$,...]
:: '''INPUT #''filenumber&'', ''variable'''''[, listof!, variables$,...]
{{Parameters}}
* ''filenumber'' is an [[INTEGER]] number value used to [[OPEN]] the file FOR [[INPUT (file mode)|INPUT]] mode only.
* ''variable'' and [[type]] define the value or list of values to be returned from the file. Numeric types must match the values returned.
* ''filenumber'' is a positive [[LONG]] integer value used to [[OPEN]] the file FOR [[INPUT (file mode)|INPUT]] mode only.
* The [[type]] of the ''variable'' define the value or list of values to be returned from the file. Numeric types must match the values returned.
* As reflected in the syntax you can list a number of variables with different types seperated by a comma and they will hold the values in the file (keep in mind that the information in the file should reflect the variable types used).
''Usage:''
* The file number can be determined by the programmer or an unused number can be returned by the [[FREEFILE]] function.
* INPUT # reads file data from a filenumber% [[OPEN]]ed in the [[INPUT (file mode)|INPUT]] file mode.
* INPUT # reads file data from a filenumber& [[OPEN]]ed in the [[INPUT (file mode)|INPUT]] file mode.
* INPUT # can read one variable at a time from a list or read the entire list by [[comma]] separating a list of input variables.
* Variable types MUST match the numerical [[type]]s being read! [[STRING]] variables can return numeric values not in quotes.
* Leading or trailing spaces of [[STRING]] values must be inside of quotes. [[WRITE (file statement)|WRITE #]] writes strings inside of quotes automatically. [[PRINT (file statement)|PRINT #]] removes quotes.

41
internal/help/INSTR.txt Normal file
View file

@ -0,0 +1,41 @@
The '''INSTR''' function searches for the first occurance of a search [[STRING]] within a string and returns the position it was found.
{{PageSyntax}}
:: position% = INSTR([start%,] basestring$, searchstring$)
* The basestring position of the first character of the searchstring is returned by the function if found.
* Position returned will be 0 if the search found no matches in the base string.
* Start [[INTEGER]] position is optional. Must be at least 1 (start of a string) when used or an [[ERROR Codes|Illegal function call]] will occur.
* The Start position is useful when making multiple searches in the same string. Otherwise it starts at the beginning again!
* Base string and search string are any literal or variable [[STRING]] values.
* The search string should be smaller than the base string!
* Non-zero position return values can be used as a new start position by adding 1 to re-search the base string.
* In a loop, INSTR can search an entire file for occurences of certain words. See the [[MID$ (statement)|MID$]] statement example.
''Example:'' Reading more than one instance of a word in a string using the INSTR return value as the start value plus 1.
{{CodeStart}} '' ''
text$ = "The cats and dogs where playing, even though dogs don't like cats."
{{Cl|DO...LOOP|DO}}
findcats% = {{Cl|INSTR}}(findcats% + 1, text$, "cats") ' find another occurance after
{{Cl|IF...THEN|IF}} findcats% {{Cl|THEN}} {{Cl|PRINT}} "There is 'cats' in the string at position:"; findcats%
{{Cl|LOOP}} {{Cl|UNTIL}} findcats% = 0
findmonkey% = {{Cl|INSTR}}(text$, "monkeys") ' find any occurance?
PRINT findmonkey%; "'monkeys' were found so it returned:"; findmonkey% '' ''
{{CodeEnd}}
{{OutputStart}}There is 'cats' in the string at position: 5
There is 'cats' in the string at position: 62
0 'monkeys' were found so INSTR returned: 0
{{OutputEnd}}
: ''Explanation:'' When the INSTR return value is 0 there are no more instances of a string in a string so the search loop is exited.
''See also:''
* [[MID$]], [[MID$ (statement)]]
* [[LEFT$]], [[RIGHT$]]
{{PageNavigation}}

View file

@ -2,11 +2,17 @@ The '''INT''' function rounds a numeric value down to the next whole number or [
{{PageSyntax}}
:: result = [[INT]](''expression'')
:: result = '''INT('''''expression''''')'''
* [[INT]] returns the first whole number that is less than ''expression''.
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* [[INT]] returns the first whole number [[INTEGER]] that is less than the ''expression'' value.
* This means that [[INT]] rounds down for both positive and negative numbers.
* Use [[FIX]] to round negative values up. It is identical to INT with positive values.
''Example:'' Displaying the rounding behavior of [[INT]].
@ -23,7 +29,7 @@ PRINT INT(-2.5)
''See also:''
* [[CINT]], [[CLNG]], [[FIX]]
* [[CSNG]], [[CDBL]]
* [[_ROUND]]
* [[_ROUND]], [[_CEIL]]
{{PageNavigation}}

View file

@ -8,6 +8,7 @@
* Integers do not use decimal point values but will round those off to the nearest even whole number.
* Qbasic Integer values can range from -32768 to 32767 without an "overflow" error.
* For larger Integer values Qbasic can use the [[LONG]] Integer values.
* '''QB64''' INTEGER values greater than 32767 may become negative signed values as the top bit designates a negative value.
* '''QB64''' [[_UNSIGNED]] Integers can range from 0 to 65535.
* '''QB64''' _UNSIGNED [[_INTEGER64]] values range from 0 to 18446744073709551615
* Many Graphic programs require INTEGER arrays or DEFINT.
@ -18,11 +19,39 @@
* '''Warning: Qbasic keyword names cannot be used as numerical variable names with or without the type suffix!'''
''Example 1:'' Qbasic signed integers were limited from -32768 to 32767, but could not exceed 32767 or it would error:
{{CodeStart}} '' ''
{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 2000
i% = i% + 1
{{Cl|PRINT}} i%
{{Cl|LOOP}} {{Cl|UNTIL}} i% = 0 '' ''
{{CodeEnd}}
:''Explanation:'' In '''QB64''' the count will go to 32767, then count up from -32768 to 0 before repeating the process without error.
''Example 2:'' When a signed '''QB64''' INTEGER value exceeds 32767, the value may become a negative value:
{{CodeStart}} '' ''
i% = 38000
{{Cl|PRINT}} i% '' ''
{{CodeEnd}}{{OutputStart}}-27536
{{OutputEnd}}
:''Explanation:'' Use an [[_UNSIGNED]] INTEGER or a ~% variable type suffix for only positive integer values up to 65535.
''Example 3:'' In '''QB64''' [[_UNSIGNED]] INTEGER values greater than 65535 cycle over again from zero:
{{CodeStart}} '' ''
i~% = 70000
{{Cl|PRINT}} i~% '' ''
{{CodeEnd}}{{OutputStart}} 4464
{{OutputEnd}}
:''Explanation:'' In QB64 an unsigned integer value of 65536 would be 0 with values increasing by the value minus 65536.
''See also:''
* [[DIM]], [[DEFINT]]
* [[LONG]], [[_INTEGER64]]
* [[LEN]], [[MKI$]], [[CVI]]
* [[_UNSIGNED]]
* [[_DEFINE]], [[_UNSIGNED]]
* [[Variable Types]]
* [[&B]] (binary), [[&O]] (octal), [[&H]] (hexadecimal)
* [[\|Integer Division]], [[MOD]] (Integer remainder division)

View file

@ -3,7 +3,7 @@ The '''INTERRUPT''' statement is an assembly routine for accessing computer info
{{PageSyntax}}
:: [[CALL]] INTERRUPT(intnum, inregs, outregs)
:: '''[[CALL]] INTERRUPT('''''intnum'', ''inregs'', ''outregs''''')'''
@ -11,6 +11,7 @@ The '''INTERRUPT''' statement is an assembly routine for accessing computer info
* Interrupt number is the interrupt reference vector table address. See: [http://www.ctyme.com/intr/cat.htm Ralf Brown's Interrupt List]
* Inregs are the values placed into the call and outregs are the register return values.
* INTERRUPT can only use ax, bx, cx, dx, bp, si, di, and the flags values.
* '''NOTE: QB64 does not currently support INT 33h mouse functions above 3 or INT requests other than 33'''
* The [[TYPE]] definition below will work for both INTERRUPT and [[INTERRUPTX]] statement calls:
@ -37,7 +38,8 @@ The '''INTERRUPT''' statement is an assembly routine for accessing computer info
''See also:''
* [[$INCLUDE|$INCLUDE:]]
* [[QB.BI]], [[CALL ABSOLUTE]], [[INTERRUPTX]]
* [[QB.BI]], [[CALL ABSOLUTE]]
* [[INTERRUPTX]]
''Download Ethan Winer's FREE Qbasic Book and Programs:'' [http://www.ethanwiner.com/fullmoon.html WINER.ZIP]

View file

@ -3,13 +3,14 @@ The '''INTERRUPTX''' statement is an assembly routine for accessing computer inf
{{PageSyntax}}
:: [[CALL]] INTERRUPTX(intnum, inregs, outregs)
:: '''[[CALL]] INTERRUPTX('''intnum, inregs, outregs''')'''
*Available on QuickBasic versions 4 up, it requires the library to be loaded. Command line: QB.EXE /L in QB4.5 .
* Interrupt number is the interrupt reference vector table address. See: [http://www.ctyme.com/intr/cat.htm Ralf Brown's Interrupt List]
* Inregs are the values placed into the call and outregs are the register return values.
* INTERRUPTX can use all of the TYPE values when they are required.
* '''NOTE: QB64 does not currently support INT 33h mouse functions above 3 or INT requests other than 33'''
* The [[TYPE]] definition below will work for both [[INTERRUPT]] and INTERRUPTX statement calls:

View file

@ -1,5 +1,5 @@
__NOTOC__
<div id="toc"><p style="text-align: center"><br> '''Alphabetical QB64 Keyword Listings''' <br><br> '''QB64:'''  [[#uA|_A]] [[#uB|_B]] [[#uC|_C]] [[#uD|_D]] [[#uE|_E]] [[#uF|_F]] [[#uG|_G]] [[#uH|_H]] [[#uI|_I]] [[#uK|_K]] [[#uL|_L]] [[#uM|_M]] [[#uN|_N]] [[#uO|_O]] [[#uP|_P]] [[#uR|_R]] [[#uS|_S]] [[#uT|_T]] [[#uU|_U]] [[#uW|_W]]                <br><br>'''Qbasic:'''  [[#A|A]]   [[#B|B]]   [[#C|C]]   [[#D|D]]   [[#E|E]]    [[#F|F]]   [[#G|G]]   [[#H|H]]    [[#I| I]]    [[#K|K]]   [[#L|L]]   [[#M|M]]   [[#N|N]]    [[#O|O]]   [[#P|P]]    [[#R|R]]   [[#S|S]]    [[#T|T]]   [[#U|U]]   [[#V|V]]   [[#W|W]]   [[#X|X]]   <br><br>'''OpenGL:'''   [[#glA|A]]    [[#glB|B]]    [[#glC|C]]    [[#glD|D]]    [[#glE|E]]     [[#glF|F]]    [[#glG|G]]    [[#glH|H]]    [[#glI| I  ]]   [[#glL|L]]    [[#glM|M]]    [[#glN|N]]     [[#glO|O]]    [[#glP|P]]     [[#glR|R]]    [[#glS|S]]     [[#glT|T]]    [[#glV|V]]       <br><br> [[#symbols|Symbols]] '''   -   ''' [[#references|References]]<br><br>[[Full Story|{{small|Created by Cyperium}} ]]</p></div>
<div id="toc"><p style="text-align: center"><br> '''Alphabetical QB64 Keyword Listings''' <br><br>     '''QB 64:'''  [[#uA|_A]] [[#uB|_B]] [[#uC|_C]] [[#uD|_D]] [[#uE|_E]] [[#uF|_F]] [[#uG|_G]] [[#uH|_H]] [[#uI|_I]] [[#uK|_K]] [[#uL|_L]] [[#uM|_M]] [[#uN|_N]] [[#uO|_O]] [[#uP|_P]] [[#uR|_R]] [[#uS|_S]] [[#uT|_T]] [[#uU|_U]] [[#uV|_V]] [[#uW|_W]]                <br><br>'''Qbasic:'''  [[#A|A]]   [[#B|B]]   [[#C|C]]   [[#D|D]]   [[#E|E]]    [[#F|F]]   [[#G|G]]   [[#H|H]]    [[#I| I]]    [[#K|K]]   [[#L|L]]   [[#M|M]]   [[#N|N]]    [[#O|O]]   [[#P|P]]    [[#R|R]]   [[#S|S]]    [[#T|T]]   [[#U|U]]   [[#V|V]]   [[#W|W]]   [[#X|X]]   <br><br>'''OpenGL:'''   [[#glA|A]]    [[#glB|B]]    [[#glC|C]]    [[#glD|D]]    [[#glE|E]]     [[#glF|F]]    [[#glG|G]]    [[#glH|H]]    [[#glI| I  ]]   [[#glL|L]]    [[#glM|M]]    [[#glN|N]]     [[#glO|O]]    [[#glP|P]]     [[#glR|R]]    [[#glS|S]]     [[#glT|T]]    [[#glV|V]]       <br><br> [[#symbols|Symbols]] '''   -   ''' [[#references|References]]<br><br>[[Full Story|{{small|Menu Created by Cyperium}} ]]</p></div>
@ -15,11 +15,11 @@ __NOTOC__
<p style="text-align: center">Keywords without the underscore at the beginning should work with both QB 4.5 and QB64.</p>
<p style="text-align: center"> [https://dl.dropbox.com/u/10291175/QB64OfflineWiki.7z Download the QB64 WIKI for Offline Reference (7 Zip 5MB)].</p>
<p style="text-align: center"> [https://dl.dropbox.com/u/10291175/QB64OfflineWiki.7z Download the QB64 WIKI for Offline Reference (7 Zip 3.8MB)].</p>
<p style="text-align: center"> Offline WIKI Reference contributed by OlDosLover.</p>
<p style="text-align: center">If '''FireFox''' does not copy page example code correctly use another browser or download our '''Code Fix Addon''' :</p>
<p style="text-align: center">If '''FIREFOX''' does not copy page example code correctly use another browser or download our '''Code Fix Addon''' :</p>
<center>[[Mozilla FireFox Code Copy Add On]] (Information)</center>
@ -35,13 +35,23 @@ __NOTOC__
==QB64 specific keywords:==
<p style="text-align: center">The underscore prefix is reserved for QB64 _KEYWORDS only. Listed _KEYWORDS and un-commented $[[Metacommand]]s only work when compiled in QB64.</p>
<p style="text-align: center">The underscore prefix is reserved for QB64 _KEYWORDS only.</p>
<p style="text-align: center">Listed _KEYWORDS and un-commented $[[Metacommand]]s only work when compiled in QB64.</p>
<div id = "uA">_A</div>
* [[_ACOS]] (function) {{text|arccosine function returns the angle in radians based on an input [[COS]]ine value range from -1 to 1.}}
* [[_ACOSH]] (function) {{text|Returns the nonnegative arc hyperbolic cosine of x, expressed in radians.}}
* [[_ALPHA]] (function) {{text|returns the alpha channel transparency level of a color value used on a screen page or image.}}
* [[_ALPHA32]] (function) {{text|returns the alpha channel transparency level of a color value used on a 32 bit screen page or image.}}
* [[Mathematical_Operations|_ARCCOT]] (function) {{text|is the inverse function of the cotangent. . http://mathworld.wolfram.com/InverseCosecant.html}}
* [[Mathematical_Operations|_ARCCSC]] (function) {{text|is the inverse function of the cosecant. http://mathworld.wolfram.com/InverseCosecant.html}}
* [[Mathematical_Operations|_ARCSEC]] (function) {{text|is the inverse function of the secant. http://mathworld.wolfram.com/InverseSecant.html}}
* [[_ASIN]] (function) {{text|Returns the principal value of the arc sine of x, expressed in radians.}}
* [[_ASINH]] (function) {{text|Returns the arc hyperbolic sine of x, expressed in radians.}}
* [[_ATAN2]] (function) {{text|Returns the principal value of the [[ATN|arc tangent]] of y/x, expressed in radians.}}
* [[_ATANH]] (function) {{text|Returns the arc hyperbolic tangent of x, expressed in radians.}}
* [[_AUTODISPLAY]] (statement) {{text|enables the automatic display of the screen image changes previously disabled by [[_DISPLAY]].}}
* [[_AXIS]] (function) {{text|returns a [[SINGLE]] value between -1 and 1 indicating the maximum distance from center 0.}}
* [[_AXIS]] (function) {{text|returns a [[SINGLE]] value between -1 and 1 indicating the maximum distance from the device axis center, 0.}}
----
@ -53,8 +63,8 @@ __NOTOC__
* [[_BLEND (function)]] {{text|returns -1 if enabled or 0 if disabled by [[_DONTBLEND]] statement.}}
* [[_BLUE]] (function) {{text|function returns the palette or the blue component intensity of a 32-bit image color.}}
* [[_BLUE32]] (function) {{text|returns the blue component intensity of a 32-bit color value.}}
* [[_BUTTON]] (function) {{text|returns -1 when a button is pressed and 0 when button is released.}}
* [[_BUTTONCHANGE]] (function) {{text|returns -1 when a button has been pressed and 1 when released. Zero indicates no change.}}
* [[_BUTTON]] (function) {{text|returns -1 when a controller device button is pressed and 0 when button is released.}}
* [[_BUTTONCHANGE]] (function) {{text|returns -1 when a device button has been pressed and 1 when released. Zero indicates no change.}}
* [[_BYTE]] (%% numerical type) {{text|can hold signed values from -128 to 127 (one byte or _BIT * 8). Unsigned from 0 to 255.}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
@ -64,20 +74,29 @@ __NOTOC__
<div id = "uC">_C</div>
* [[$CHECKING]] (QB64 C++ [[Metacommand]]) {{text|turns event error checking OFF or ON. Do not comment or REM.}}
* [[_CEIL]] (function) {{text|Rounds x upward, returning the smallest integral value that is not less than x.}}
* [[_CLEARCOLOR (function)]] {{text|returns the current transparent color of an image.}}
* [[_CLEARCOLOR]] (statement) {{text|sets a specific color index of an image to be transparent}}
* [[_CLIP]] ([[PUT (graphics statement)|PUT]] graphics option) {{text|allows placement of an image partially off of the screen.}}
* [[_CLIPBOARD$]] (function) {{text|returns the operating system's clipboard contents as a [[STRING]].}}
* [[_CLIPBOARD$ (statement)]] {{text|sets and overwrites the [[STRING]] value in the operating system's clipboard.}}
* [[_COMMANDCOUNT]] (function) {{text|returns the number of arguments passed to the compiled program from the command line.}}
* [[_CONNECTED]] (function) {{text|returns the status of a TCP/IP connection handle.}}
* [[_CONNECTIONADDRESS$]] (TCP/IP function) {{text|returns a connected user's STRING IP address value using the handle.}}
* [[$CONSOLE]] (QB64 [[Metacommand]]) {{text|creates a console window that can be used throughout a program.}}
* [[$CONSOLE]] (QB64 [[Metacommand]]) {{text|creates a console window that can be used throughout a program. Do not comment!}}
* [[_CONSOLE]] (statement) {{text|used to turn a console window OFF or ON or to designate [[_DEST]] _CONSOLE for output.}}
* [[_CONSOLETITLE]] (statement) {{text|creates the title of the console window using a literal or variable [[STRING|string]].}}
* [[_CONTROLCHR]] {{text|[[OFF]] allows the control characters to be used as text characters. [[ON]](default) can use them as commands.}}
* [[_CONTROLCHR]] (statement) {{text|[[OFF]] allows the control characters to be used as text characters. [[ON]](default) can use them as commands.}}
* [[_CONTROLCHR (function)]] {{text| returns the current state of _CONTROLCHR as 1 when OFF and 0 when ON.}}
* [[_COPYIMAGE]] (function) {{text|copies an image handle value to a new designated handle.}}
* [[_COPYPALETTE]] (statement) {{text|copies the color palette intensities from one 4 or 8 BPP image to another image.}}
* [[Mathematical_Operations|_COT]] (function) {{text| the mathematical function cotangent defined by 1/TAN. http://mathworld.wolfram.com/Cotangent.html}}
* [[Mathematical_Operations|_COTH]] (function) {{text|Returns the hyperbolic cotangent. http://mathworld.wolfram.com/HyperbolicCotangent.html}}
* [[Mathematical_Operations|_COSH]] (function) {{text|Returns the hyperbolic cosine of x radians. http://mathworld.wolfram.com/HyperbolicCosine.html}}
* [[Mathematical_Operations|_CSC]] (function) {{text| the mathematical function cosecant defined by 1/SIN. http://mathworld.wolfram.com/Cosecant.html}}
* [[Mathematical_Operations|_CSCH]] (function) {{text|Returns the hyperbolic cosecant. http://mathworld.wolfram.com/HyperbolicCosecant.html}}
* [[_CV]] (function) {{text|converts any [[_MK$]] [[STRING]] value to the designated numerical type value.}}
* [[_CWD$]] (function) {{text|returns the current working directory as a [[STRING]] value.}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
@ -85,9 +104,16 @@ __NOTOC__
<div id = "uD">_D</div>
* [[_D2G]] (function) {{text|converts degrees to gradient angle values.}}
* [[_D2R]] (function) {{text|converts degrees to radian angle values.}}
* [[DECLARE LIBRARY|DECLARE LIBRARY (QB64 statement block)]] {{text|declares a C++, SDL or Operating System [[SUB]] or [[FUNCTION]] to be used.}}
* [[DECLARE DYNAMIC LIBRARY|DECLARE DYNAMIC LIBRARY (QB64 statement)]] {{text|declares DYNAMIC, CUSTOMTYPE or STATIC library(DLL) [[SUB]] or [[FUNCTION]].}}
* [[_DEFAULTCOLOR]] (function) {{text|returns the current default text color for an image handle or page.}}
* [[_DEFINE]] (statement) {{text|defines a range of variable names according to their first character as a data type.}}
* [[_DELAY]] (statement) {{text|suspends program execution for a [[SINGLE]] number of seconds.}}
* [[_DEPTHBUFFER]] (statement) {{text|enables, disables, locks or clears depth buffering in GL.}}
* [[_DESKTOPHEIGHT]] (function) {{text|returns the height of the desktop (not program window).}}
* [[_DESKTOPWIDTH]] (function) {{text|returns the width of the desktop (not program window).}}
* [[_DEST]] (statement) {{text|sets the current write image or [[SCREEN]] page destination for prints or graphics.}}
* [[_DEST (function)]] {{text|returns the current destination screen page or image handle value.}}
* [[_DEVICE$]] (function) {{text|returns a [[STRING]] expression listing a designated numbered input device name and types of input.}}
@ -96,6 +122,7 @@ __NOTOC__
* [[_DIREXISTS]] (function) {{text|returns -1 if the Directory folder name [[STRING|string]] parameter exists. Zero if it does not.}}
* [[_DISPLAY]] (statement) {{text|turns off the [[_AUTODISPLAY|automatic display]] while only displaying the screen changes when called.}}
* [[_DISPLAY (function)]] {{text|returns the handle of the current image that is displayed on the screen.}}
* [[_DISPLAYORDER]] (GL statement) {{text|designates the order to render software, hardware and custom-opengl-code.}}
* [[_DONTBLEND]] (statement) {{text|statement turns off default [[_BLEND]] 32 bit [[_ALPHA|alpha]] blending for the current image or screen.}}
* [[_DONTWAIT]] ([[SHELL]] action) {{text|specifies that the program should not wait until the shelled command/program is finished.}}
@ -104,6 +131,9 @@ __NOTOC__
<div id = "uE">_E</div>
* [[$ELSE]] (QB64 Pre-Compiler [[Metacommand]]) {{text|used in conjunction with $IF for the precompiler. Do not comment or REM.}}
* [[$ELSEIF]] (QB64 Pre-Compiler [[Metacommand]]) {{text|used in conjunction with $IF for the precompiler. Do not comment or REM.}}
* [[$END IF]] (QB64 Pre-Compiler [[Metacommand]]) {{text|used in conjunction with $IF for the precompiler. Do not comment or REM.}}
* [[_ERRORLINE]] (function) {{text|returns the source code line number that caused the most recent runtime error.}}
* [[_EXIT (function)]] {{text|prevents a user exit and indicates if a user has clicked the close X window button or CTRL + BREAK.}}
@ -129,6 +159,8 @@ __NOTOC__
<div id = "uG">_G</div>
* [[_G2D]] (function) {{text|converts gradient to degree angle values.}}
* [[_G2R]] (function) {{text|converts gradient to radian angle values.}}
* [[_GREEN]] (function) {{text|function returns the palette or the green component intensity of a 32-bit image color.}}
* [[_GREEN32]] (function) {{text|returns the green component intensity of a 32-bit color value.}}
@ -140,13 +172,15 @@ __NOTOC__
<div id = "uH">_H</div>
* [[_HEIGHT]] (function) {{text|returns the height of a designated image handle.}}
* [[_HIDE]] ([[SHELL]] action) {{text| hides the command line display during a shell.}}
* [[_HYPOT]] (function) {{text|Returns the hypotenuse of a right-angled triangle whose legs are x and y.}}
----
<div id = "uI">_I</div>
* [[_ICON]] (statement) {{text|designates a [[_LOADIMAGE]] image file handle to be used as the program's icon. QB64 cannot use icons!}}
* [[$IF]] (QB64 Pre-Compiler [[Metacommand]]) {{text|used to set an IF condition for the precompiler. Do not comment or REM.}}
* [[_ICON]] (statement) {{text|designates a [[_LOADIMAGE]] image file handle to be used as the program's icon. (Icons can be used in GL only!)}}
* [[_INTEGER64]] (&& numerical type) {{text|can hold whole numerical values from -9223372036854775808 to 9223372036854775807.}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
@ -156,6 +190,7 @@ __NOTOC__
<div id = "uK">_K</div>
*[[_KEYCLEAR]] (function) {{text|clears the keyboard buffers for INKEY$, _KEYHIT, and INP.}}
*[[_KEYHIT]] (function) {{text|returns [[ASCII]] one and two byte, SDL Virtual Key and [[Unicode]] keyboard key press codes.}}
*[[_KEYDOWN]] (function) {{text|returns whether CTRL, ALT, SHIFT, combinations and other keys are pressed.}}
@ -164,6 +199,7 @@ __NOTOC__
<div id = "uL">_L</div>
* [[$LET]] (QB64 Pre-Compiler [[Metacommand]]) {{text|used to set a flag variable for the precompiler. Do not comment or REM.}}
* [[_LASTAXIS]] (function) {{text|returns the number of axis available on a specified number device listed by [[_DEVICE$]].}}
* [[_LASTBUTTON]] (function) {{text|returns the number of buttons available on a specified number device listed by [[DEVICE$]].}}
* [[_LASTWHEEL]] (function) {{text|returns the number of scroll wheels available on a specified number device listed by [[_DEVICE$]].}}
@ -184,6 +220,7 @@ __NOTOC__
* [[_MEM]] (variable type) {{text|contains read only dot elements for the OFFSET, SIZE, TYPE and ELEMENTSIZE of a block of memory.}}
* [[_MEMCOPY]] (statement) {{text|copies a value from a designated OFFSET and SIZE [[TO]] a block of memory at a designated OFFSET.}}
* [[_MEMELEMENT]] (function) {{text|returns a [[_MEM]] block referring to a variable's memory (but not past it).}}
* [[_MEMEXISTS]] (function) {{text|verifies that a memory block exists for a memory variable name or returns zero.}}
* [[_MEMFILL]] (statement) {{text|fills a designated memory block OFFSET with a certain SIZE and TYPE of value.}}
* [[_MEMFREE]] (statement) {{text|frees a designated memory block in a program. Only free memory blocks once!}}
* [[_MEMGET]] (statement) {{text|reads a value from a designated memory block at a designated OFFSET}}
@ -199,7 +236,8 @@ __NOTOC__
* [[_MOUSEMOVE]] (statement) {{text|moves the mouse pointer to a designated position on the program [[SCREEN]].}}
* [[_MOUSEMOVEMENTX]] (function) {{text|returns the relative horizontal position of the mouse cursor compared to the previous position.}}
* [[_MOUSEMOVEMENTY]] (function) {{text|returns the relative vertical position of the mouse cursor compared to the previous position.}}
* [[_MOUSESHOW]] (statement) {{text|displays the mouse cursor after it has been hidden.}}
* [[_MOUSEPIPEOPEN]] (function) {{text|creates a pipe handle value for a mouse when using a virtual keyboard.}}
* [[_MOUSESHOW]] (statement) {{text|displays the mouse cursor after it has been hidden or can change the cursor shape in GL.}}
* [[_MOUSEWHEEL]] (function) {{text|returns the number of mouse scroll wheel "clicks" since last read.}}
* [[_MOUSEX]] (function) {{text|returns the current horizontal position of the mouse cursor.}}
* [[_MOUSEY]] (function) {{text|returns the current vertical position of the mouse cursor.}}
@ -210,7 +248,6 @@ __NOTOC__
<div id = "uN">_N</div>
* [[_NEWIMAGE]] (function) {{text|creates a designated size program [[SCREEN]] or page image and returns a handle value.}}
* [[_CLEARCOLOR|_NONE]] {{text|(_CLEARCOLOR option) disables transparency for color modes using a palette.}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
@ -223,7 +260,7 @@ __NOTOC__
* [[_OPENCLIENT]] (TCP/IP function) {{text|connects to a Host on the Internet as a Client and returns the Client status handle.}}
* [[_OPENCONNECTION]] (TCP/IP function) {{text|open's a connection from a client that the host has detected and returns a status handle.}}
* [[_OPENHOST]] (TCP/IP function) {{text|opens a Host and returns a Host status handle.}}
* [[_OS$]] (function) {{text|returns the Operating System and bit type that a QB64 program is currently running in.}}
* [[_OS$]] (function) {{text|returns the QB64 compiler version in which the program was compiled as [WINDOWS], [LINUX] or [MACOSX] and [32BIT] or [64BIT].}}
----
@ -232,13 +269,14 @@ __NOTOC__
<div id = "uP">_P</div>
* [[_PALETTECOLOR]] (statement) {{text|sets the color value of a palette entry of an image using 256 colors or less palette modes.}}
* [[_PALETTECOLOR (function)]] {{text|return the 32 bit attribute color setting of an image or screen page handle's palette.}}
* [[_PI]] (function) {{text|returns the value of '''π''' or parameter multiples for angle or [[CIRCLE|circle]] calculations.}}
* [[_PIXELSIZE]] (function) {{text|returns the pixel palette mode of a designated image handle.}}
* [[_PRESERVE]] ([[REDIM]] action) {{text|preserves the data presently in an array when [[REDIM]] is used.}}
* [[_PRINTIMAGE]] (statement) {{text|sends an image to the printer that is stretched to the current printer paper size.}}
* [[_PRINTMODE]] (statement) {{text|sets the text or _FONT printing mode on a background when using PRINT or [[_PRINTSTRING]].}}
* [[_PRINTMODE (function)]] {{text|returns the present [[_PRINTMODE]] value number.}}
* [[_PRINTSTRING]] (statement) {{text|locates and prints a text [[STRING|string]] using graphic coordinates.}}
* [[_PRINTWIDTH]] (function) {{text|returns the width of a string to be printed using [[_PRINTSTRING]].}}
* [[_PRINTWIDTH]] (function) {{text|returns the pixel width of a text string to be printed using [[_PRINTSTRING]].}}
* [[_PUTIMAGE]] (statement) {{text|maps a rectangular image source area to an image destination area.}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
@ -247,8 +285,15 @@ __NOTOC__
<div id = "uR">_R</div>
* [[_R2D]] (function) {{text|converts radians to degree angle values.}}
* [[_R2G]] (function) {{text|converts radians to gradient angle values.}}
* [[_RED]] (function) {{text|function returns the palette or the red component intensity of a 32-bit image color.}}
* [[_RED32]] (function) {{text|returns the red component intensity of a 32-bit color value.}}
* [[$RESIZE]] ([[Metacommand]]) {{text|used with ON allows a user to resize the GL program window where OFF does not. Do not comment!}}
* [[_RESIZE]] (statement) {{text|sets resizing of the window ON or OFF and sets the method as _STRETCH or _SMOOTH.}}
* [[_RESIZE (function)]] {{text|returns -1 when a program user wants to resize the GL program screen.}}
* [[_RESIZEHEIGHT]] (function) {{text|returns the requested new user GL screen height when [[$RESIZE]]:ON allows it.}}
* [[_RESIZEWIDTH]] (function) {{text|returns the requested new user GL screen width when [[$RESIZE]]:ON allows it.}}
* [[_RGB]] (function) {{text|returns the closest palette index OR the [[LONG]] 32 bit color value in 32 bit screens.}}
* [[_RGB32]] (function) {{text|returns the [[LONG]] 32 bit color value in 32 bit screens only}}
* [[_RGBA]] (function) {{text|returns the closest palette index OR the [[LONG]] 32 bit color value in 32 bit screens with the [[ALPHA]]}}
@ -261,18 +306,25 @@ __NOTOC__
<div id = "uS">_S</div>
* [[Mathematical_Operations#Derived_Mathematical_Functions|_SEC]] (function) {{text| the mathematical function secant defined by 1/COS. http://mathworld.wolfram.com/Secant.html}}
* [[Mathematical_Operations#Derived_Mathematical_Functions|_SECH]] (function) {{text|Returns the hyperbolic secant. http://mathworld.wolfram.com/HyperbolicSecant.html}}
* [[_SCREENCLICK]] (statement) {{text|simulates clicking on a point on the desktop screen with the left mouse button.}}
* [[$SCREENHIDE]] (QB64 [[Metacommand]]) {{text|hides the program window from view.}}
* [[_SCREENHIDE]] (statement) {{text|hides the program window from view.}}
* [[_SCREENEXISTS]] (function) {{text|returns a -1 value once a screen has been created.}}
* [[$SCREENHIDE]] (QB64 [[Metacommand]]) {{text|hides the program window from view. Do not comment!}}
* [[_SCREENHIDE]] (statement) {{text|hides the program window from view.}}
* [[_SCREENICON (function)]] {{text|returns -1 or 0 to indicate if the window has been minimized to an icon on the taskbar.}}
* [[_SCREENICON]] (statement) {{text|minimizes the program window to an icon on the taskbar.}}
* [[_SCREENIMAGE]] (function) {{text|creates an image of the current desktop and returns an image handle.}}
* [[_SCREENMOVE]] (statement) {{text|positions program window on the desktop using designated coordinates or the _MIDDLE option.}}
* [[_SCREENPRINT]] (statement) {{text|simulates typing text into a Windows program using the keyboard.}}
* [[$SCREENSHOW]] (QB64 [[Metacommand]]) {{text|displays that program window after it was hidden by the [[$SCREENHIDE]] metacommand.}}
* [[$SCREENSHOW]] (QB64 [[Metacommand]]) {{text|displays that program window after it was hidden by [[$SCREENHIDE]]. Do not comment!}}
* [[_SCREENSHOW]] (statement) {{text|displays the program window after it has been hidden by [[_SCREENHIDE]].}}
* [[_SCREENX]] (function) {{text|returns the program window's upper left corner horizontal position on the desktop.}}
* [[_SCREENY]] (function) {{text|returns the program window's upper left corner vertical position on the desktop.}}
* [[_SETALPHA]] (statement) {{text|sets the alpha channel transparency level of some or all of the pixels of an image.}}
* [[_SHELLHIDE]] (function) {{text|returns the code sent by a program exit using [[END]] or [[SYSTEM]] followed by an [[INTEGER]] value.}}
* [[Mathematical_Operations|_SINH]] (function) {{text|Returns the hyperbolic sine of x radians.}}
* [[_SNDBAL]] (statement) {{text|attempts to set the balance or 3D position of a sound file with the SYNC capability.}}
* [[_SNDCLOSE]] (statement) {{text|frees and unloads an open sound using the sound handle created by [[_SNDOPEN]].}}
* [[_SNDCOPY]] (function) {{text|copies a sound handle value to a new designated handle.}}
@ -281,6 +333,7 @@ __NOTOC__
* [[_SNDLIMIT]] (statement) {{text|stops playing a sound after it has been playing for a set number of seconds.}}
* [[_SNDLOOP]] (statement) {{text|plays a sound repeatedly until [[_SNDSTOP]] is used.}}
* [[_SNDOPEN]] (function) {{text|loads a sound file and returns a sound handle.}}
* [[_SNDOPENRAW]] (GL function) {{text|opens a new channel to shove [[_SNDRAW]] content into without mixing.}}
* [[_SNDPAUSE]] (statement) {{text|stops playing a sound file that has the PAUSE capability until resumed.}}
* [[_SNDPAUSED]] (function) {{text|returns the current pause status of a sound file handle.}}
* [[_SNDPLAY]] (statement) {{text|plays a sound file handle that was created by [[_SNDOPEN]] or [[_SNDCOPY]].}}
@ -289,12 +342,16 @@ __NOTOC__
* [[_SNDPLAYING]] (function) {{text|returns the current playing status of a sound handle.}}
* [[_SNDRATE]] (function) {{text|returns the sound card sample rate to set [[_SNDRAW]] durations.}}
* [[_SNDRAW]] (statement) {{text|creates mono or stereo sounds from calculated wave frequency values.}}
* [[_SNDRAWLEN]] ([[_SNDRAW]] function) {{text|returns a value until the [[_SNDRAW]] buffer is empty.}}
* [[_SNDRAWDONE]] (GL statement) {{text|pads a [[_SNDRAW]] stream so the final (partially filled) buffer section is played.}}
* [[_SNDRAWLEN]] (function) {{text|returns a value until the [[_SNDRAW]] buffer is empty.}}
* [[_SNDSETPOS]] (statement) {{text|sets the playing position of a sound handle.}}
* [[_SNDSTOP]] (statement) {{text|stops playing a sound handle.}}
* [[_SNDVOL]] (statement) {{text|sets the volume of a sound file handle that has the VOL capability.}}
* [[_SOURCE]] (statement) {{text|sets the source image handle.}}
* [[_SOURCE (function)]] {{text|returns the present source image handle value.}}
* [[_STARTDIR$]] (function) {{text|returns the user's program calling path as a [[STRING]].}}
* [[_STRCMP]] (function) {{text|compares the relationship between two strings.}}
* [[_STRICMP]] (function) {{text|compares the relationship between two strings, without regard for case-sensitivity.}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
@ -303,6 +360,7 @@ __NOTOC__
<div id = "uT">_T</div>
* [[Mathematical_Operations|_TANH]] (function) {{text|Returns the hyperbolic tangent of x radians.}}
* [[_TITLE]] (statement) {{text|sets the program title [[STRING|string]] value.}}
@ -317,9 +375,17 @@ __NOTOC__
----
<div id = "uV">_V</div>
* [[$VIRTUALKEYBOARD]] (QB64 metacommand) {{text|turns the virtual keyboard ON or OFF in Android device programs. Do not comment!}}
----
<div id = "uW">_W</div>
* [[_WHEEL]] (function) {{text|returns -1 when a controller wheel is scrolled up and 1 when scrolled down. Zero indicates no activity.}}
* [[_WHEEL]] (function) {{text|returns -1 when a control device wheel is scrolled up and 1 when scrolled down. Zero indicates no activity.}}
* [[_WIDTH (function)]] {{text|returns the width of a [[SCREEN]] or image handle.}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
@ -328,13 +394,13 @@ __NOTOC__
<center>([[Keyword Reference - Alphabetical#QB64 specific keywords:|Go to Top of QB64 specific keywords]])</center>
==Original QBasic keywords:==
<p style="text-align: center">These Qbasic keywords (with a few noted exceptions) will work in QB64.</p>
'''<p style="text-align: center">These Qbasic keywords (with a few noted exceptions) will work in all versions of QB64.</p>'''
<div id = "A">A</div>
* [[ABS]] (function) {{text|converts any negative numerical value to a positive value.}}
* [[CALL ABSOLUTE|ABSOLUTE]] (statement) {{text|is used to access computer interrupt registers.}}
* [[ACCESS]] (file statement) {{text|sets the read and write access of a file when opened.}}
* [[ALIAS]] ([[DECLARE (non-BASIC statement)]]) {{text|denotes the actual name of an imported [[FUNCTION]] or [[SUB]] procedure.}}
* [[ALIAS]] (QB64 [[DECLARE LIBRARY]] statement) {{text|denotes the actual name of an imported [[FUNCTION]] or [[SUB]] procedure.}}
* [[AND]] (logical operator) {{text|is used to compare two numerical values bitwise.}}
* [[AND (boolean)]] {{text| conditonal operator is used to include another evaluation in an [[IF...THEN]] or [[Boolean]] statement.}}
* [[ANY]] (variable type) {{text|disables type checking for a variable used in a [[SUB]] or [[FUNCTION]] declaration.}}
@ -361,7 +427,7 @@ __NOTOC__
<div id = "C">C</div>
* [[CALL]] (statement) {{text|optional statement that sends the program to a [[SUB]] procedure.}}
* [[CALL]] (statement) {{text|optional statement that sends the program to a [[SUB]] procedure. Requires parameters be enclosed in brackets(parenthesis).}}
* [[CALL ABSOLUTE]] (statement) {{text|is used to access computer interrupt registers.}}
* [[CALLS]] (non-BASIC call statement)
* [[CASE]] ([[SELECT CASE]] condition) {{text|designates specific conditions in a [[SELECT CASE]] statement block.}}
@ -413,6 +479,7 @@ __NOTOC__
* [[DEFSNG]] (statement) {{text|defines a set of undefined variable name starting letters as [[SINGLE]] type numerical values.}}
* [[DEFSTR]] (statement) {{text|defines a set of undefined variable name starting letters as [[STRING]] type values.}}
* [[DIM]] (statement) {{text|defines a variable as a specified type and can size a [[STATIC]] array.}}
* [[DIR$]] (PDS function) {{text|derived function code used to find a list of files by name. '''NOT A QB64 FUNCTION'''}}
* [[DO...LOOP]] (statement) {{text|sets a recursive procedure loop that can be ignored or exited using conditional arguments.}}
* [[DOUBLE]] (numerical type #) {{text|8 byte value limited to values up to 15 decimal places.}}
* [[DRAW]] (statement) {{text|uses a special [[STRING|string]] format that draws graphical lines in specific directions.}}
@ -524,8 +591,8 @@ __NOTOC__
* [[LEN]] (function) {{text|returns the length or number of characters in a [[STRING]] value in bytes.}}
* [[LET]] (statement) {{text|assigns a variable a literal value. Not required!}}
* [[LINE]] (statement) {{text|creates a graphic line or box on the [[SCREEN]].}}
* [[LINE INPUT]] (statement) {{text|a user input that can return a [[STRING]] value only.}}
* [[LINE INPUT (file statement)]] {{text|reads an entire file line and returns it as a [[STRING]] value.}}
* [[LINE INPUT]] (statement) {{text|user input can be any text character including commas and quotes as a [[STRING]] value only.}}
* [[LINE INPUT (file statement)]] {{text|returns an entire text file line and returns it as a [[STRING]] value.}}
* [[KEY LIST|LIST]] {{text|displays the current [[ON KEY(n)]] function key(F1 to F10) "soft key" settings.}}
* [[LOC]] (function) {{text|returns the present file byte position or number of bytes in the [[OPEN COM]] buffer.}}
* [[LOCATE]] (statement) {{text|sets the text cursor's row and column position for a [[PRINT]] or [[INPUT]] statement.}}
@ -581,7 +648,7 @@ __NOTOC__
* [[ON PLAY(n)]] (statement) {{text|sets up a [[PLAY]] event procedure call.}}
* [[ON STRIG(n)]] (statement) {{text|sets up a joystick button event procedure call.}}
* [[ON TIMER(n)]] (statement) {{text|sets up a timed event procedure call.}}
* [[ON UEVENT]] (statement) {{text|sets up an interrupt event procedure call.}}
* [[ON UEVENT]] (statement) '''{{text|Currently NOT supported in QB64!}}'''
* [[ON...GOSUB]] (statement) {{text|sets up a numberical event procedure call.}}
* [[ON...GOTO]] (statement) {{text|sets up a numberical event procedure call.}}
* [[OPEN]] (file statement) {{text|opens a file name for an access mode with a specific file number.}}
@ -709,7 +776,7 @@ __NOTOC__
<div id = "U">U</div>
* [[UBOUND]] (function) {{text|returns the upper-most index number of a designated [[arrays|array]].}}
* [[UCASE$]] (function) {{text|returns an uppercase representation of a specified [[STRING]].}}
* [[UEVENT]] (statement)
* [[UEVENT]] (statement) '''{{text|Currently NOT supported in QB64!}}'''
* [[UNLOCK]] (statement) {{text|unlocks a designated file or portions of it.}}
* [[UNTIL]] (condition) {{text|evaluates a [[DO...LOOP]] condition until it is True.}}
@ -758,6 +825,9 @@ __NOTOC__
-->
==OpenGL specific keywords:==
<center>'''All QB64 GL keywords must use the underscore _gl prefix with the alphabetically listed function names.'''</center>
<center>'''The following keywords cannot be used in QB64 SDL versions .954 and below!'''</center>
<div id = "glA">_glA</div>
* [[_glAccum]] (statement) {{text|OpenGL command}}
@ -769,7 +839,7 @@ __NOTOC__
----
<div id = "glB">_glB</div>
* [[_glBegin]] (statement) {{text|OpenGL command}}
* [[_glBindTexture]] (statement) {{text|OpenGL command}}
* [[_glBindTexture]] (statement) {{text|OpenGL command binds a named texture to a texturing target}}
* [[_glBitmap]] (statement) {{text|OpenGL command}}
* [[_glBlendFunc]] (statement) {{text|OpenGL command}}
@ -778,12 +848,12 @@ __NOTOC__
<div id = "glC">_glC</div>
* [[_glCallList]] (statement) {{text|OpenGL command}}
* [[_glCallLists]] (statement) {{text|OpenGL command}}
* [[_glClear]] (statement) {{text|OpenGL command}}
* [[_glClear]] (statement) {{text|OpenGL command clears buffers to preset values}}
* [[_glClearAccum]] (statement) {{text|OpenGL command}}
* [[_glClearColor]] (statement) {{text|OpenGL command}}
* [[_glClearDepth]] (statement) {{text|OpenGL command}}
* [[_glClearColor]] (statement) {{text|OpenGL command specifies clear values for the color buffers}}
* [[_glClearDepth]] (statement) {{text|OpenGL command specifies the depth value used when the depth buffer is cleared. Initial value is 1.}}
* [[_glClearIndex]] (statement) {{text|OpenGL command}}
* [[_glClearStencil]] (statement) {{text|OpenGL command}}
* [[_glClearStencil]] (statement) {{text|OpenGL command specifies the index used when the stencil buffer is cleared. Initial value is 0.}}
* [[_glClipPlane]] (statement) {{text|OpenGL command}}
* [[_glColor3b]] (statement) {{text|OpenGL command}}
* [[_glColor3bv]] (statement) {{text|OpenGL command}}
@ -818,24 +888,24 @@ __NOTOC__
* [[_glColor4uiv]] (statement) {{text|OpenGL command}}
* [[_glColor4us]] (statement) {{text|OpenGL command}}
* [[_glColor4usv]] (statement) {{text|OpenGL command}}
* [[_glColorMask]] (statement) {{text|OpenGL command}}
* [[_glColorMask]] (statement) {{text|OpenGL command enables and disables writing of frame buffer color components}}
* [[_glColorMaterial]] (statement) {{text|OpenGL command}}
* [[_glColorPointer]] (statement) {{text|OpenGL command}}
* [[_glCopyPixels]] (statement) {{text|OpenGL command}}
* [[_glCopyTexImage1D]] (statement) {{text|OpenGL command}}
* [[_glCopyTexImage2D]] (statement) {{text|OpenGL command}}
* [[_glCopyTexSubImage1D]] (statement) {{text|OpenGL command}}
* [[_glCopyTexSubImage2D]] (statement) {{text|OpenGL command}}
* [[_glCopyTexImage1D]] (statement) {{text|OpenGL command copies pixels into a 1D texture image}}
* [[_glCopyTexImage2D]] (statement) {{text|OpenGL command copies pixels into a 2D texture image}}
* [[_glCopyTexSubImage1D]] (statement) {{text|OpenGL command copies a one-dimensional texture subimage}}
* [[_glCopyTexSubImage2D]] (statement) {{text|OpenGL command copiess a two-dimensional texture subimage}}
* [[_glCullFace]] (statement) {{text|OpenGL command}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
----
<div id = "glD">_glD</div>
* [[_glDeleteLists]] (statement) {{text|OpenGL command}}
* [[_glDeleteTextures]] (statement) {{text|OpenGL command}}
* [[_glDepthFunc]] (statement) {{text|OpenGL command}}
* [[_glDepthMask]] (statement) {{text|OpenGL command}}
* [[_glDepthRange]] (statement) {{text|OpenGL command}}
* [[_glDeleteTextures]] (statement) {{text|OpenGL command deletes named textures}}
* [[_glDepthFunc]] (statement) {{text|OpenGL command specifies the value used for depth buffer comparisons}}
* [[_glDepthMask]] (statement) {{text|OpenGL command enables or disables writing into the depth buffer}}
* [[_glDepthRange]] (statement) {{text|OpenGL command specifies mapping of near clipping plane to window coordinates. Initial value 0.}}
* [[_glDisable]] (statement) {{text|OpenGL command}}
* [[_glDisableClientState]] (statement) {{text|OpenGL command}}
* [[_glDrawArrays]] (statement) {{text|OpenGL command}}
@ -1017,9 +1087,7 @@ __NOTOC__
* [[_glPolygonOffset]] (statement) {{text|OpenGL command}}
* [[_glPolygonStipple]] (statement) {{text|OpenGL command}}
* [[_glPopAttrib]] (statement) {{text|OpenGL command}}
* [[_glPopClientAttrib]] (st
4a13
atement) {{text|OpenGL command}}
* [[_glPopClientAttrib]] (statement) {{text|OpenGL command}}
* [[_glPopMatrix]] (statement) {{text|OpenGL command}}
* [[_glPopName]] (statement) {{text|OpenGL command}}
* [[_glPrioritizeTextures]] (statement) {{text|OpenGL command}}
@ -1049,6 +1117,7 @@ atement) {{text|OpenGL command}}
* [[_glRasterPos3sv]] (statement) {{text|OpenGL command}}
* [[_glRasterPos4d]] (statement) {{text|OpenGL command}}
* [[_glRasterPos4dv]] (statement) {{text|OpenGL command}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
* [[_glRasterPos4f]] (statement) {{text|OpenGL command}}
* [[_glRasterPos4fv]] (statement) {{text|OpenGL command}}
* [[_glRasterPos4i]] (statement) {{text|OpenGL command}}

View file

@ -25,7 +25,7 @@
:::: Offline WIKI Reference contributed by OlDosLover
:If '''FireFox''' does not copy page example code correctly use another browser or:
:If '''FIREFOX browser''' does not copy page example code correctly use another browser or:
::::Download page: [[Mozilla FireFox Code Copy Add On]]
@ -166,7 +166,7 @@
* [[_INTEGER64]] (&& numerical [[TYPE|type]]) {{text|values -9223372036854775808 to 9223372036854775807. [[_UNSIGNED|Unsigned]] to 18446744073709551615.}}
* [[_MEM]] (variable type) {{text|contains read only dot elements for the OFFSET, SIZE, TYPE and ELEMENTSIZE of a block of memory.}}
* [[_OFFSET]](%& variable type) {{text|can store any memory offset integer value when using [[DECLARE LIBRARY]] or [[_MEM]]ory only.}}
* [[_UNSIGNED]] {~ numerical [[TYPE|type]]) {{text|defines a numerical value as being positive only using QB64.}}
* [[_UNSIGNED]] {~ numerical [[TYPE|type]]) {{text|defines an integer numerical value as being positive only in QB64.}}
* [[COMMON]] (statement) {{text|shares common variable values with other Linked or [[CHAIN]]ed programs.}}
@ -200,15 +200,17 @@
* [[_DIREXISTS]] (function) {{text|returns -1 if the directory folder name [[STRING|string]] parameter exists. Zero if it does not.}}
* [[_CLIPBOARD$ (statement)]] {{text|sends [[STRING]] data to the Clipboard.}}
* [[_CLIPBOARD$]] (function) {{text|returns the current contents of the Clipboard as a [[STRING|string]].}}
* [[_CWD$]] (function) {{text|returns the current working directory path as a [[STRING]].}}
* [[_DONTWAIT]] (SHELL action) {{text|allows the program to continue without waiting for the other program to close.}}
* [[_FILEEXISTS]] (function) {{text|returns -1 if the file name [[STRING|string]] parameter exists. Zero if it does not.}}
* [[_HIDE]] (SHELL action) {{text|hides the [[DOS]] screen output during a shell.}}
*[[_LASTBUTTON]] (function) {{text|returns the number of buttons available on a specified number device listed by [[DEVICE$]].}}
* [[_OS$]] (function) {{text|returns the Operating System of the computer a QB64 program is running in.}}
* [[_OS$]] (function) {{text| returns the QB64 compiler version in which the program was compiled as [WINDOWS], [LINUX] or [MACOSX] and [32BIT] or [64BIT].}}
* [[_SCREENCLICK]] {{text|simulates clicking the mouse at a position on the screen to get focus.}}
* [[_SCREENIMAGE]] {{text|captures the current desktop screen image.}}
* [[_SCREENPRINT]] {{text|simulates keyboard entries on the desktop.}}
* [[_SHELLHIDE]] (function) {{text|executes a [[DOS]] command or calls another program. Returns codes sent by [[END]] or [[SYSTEM]].}}
* [[_STARTDIR$]] (function) {{text|returns the user's program calling path as a [[STRING]].}}
* [[CHDIR]] (statement) {{text|changes the program path to a new path.}}
@ -225,6 +227,141 @@
<center>''See also:'' [[Keyword_Reference_-_By_usage#Console_Window|Console Window]] to display [[DOS]] commands.</center>
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
== Error Codes ==
The following table describes the error codes that are reported by the '''QB64''' compiler, as well as possible causes and solutions:
{| border="1" cellpadding="2"
|-
! colspan="6"|QB/64 Error Codes
|-
! Code || Description || Common cause/Resolution || QB64 Differences
|-
| 1 || [[NEXT]] without [[FOR]] || Missing loop end or look for a missing [[END IF]] or [[END SELECT]] statement. || none
|-
| 2 || Syntax error || Mistyped keyword statements or puctuation errors can create syntax errors. || none
|-
| 3 || [[RETURN]] without [[GOSUB]] || Place sub-procedure line label after program [[END]] or [[EXIT]] in a [[SUB]]-procedure.|| none
|-
| 4 || Out of DATA || A [[READ]] has read past the end of [[DATA]]. Use [[RESTORE]] to reset to data start. . || none
|-
| 5 || Illegal function call || A parameter passed does not match the function type or exceeds certain function limitations. See [[Illegal Function]]. || none
|-
| 6 || Overflow || A numerical value has exceeded the limitations of a [[Variable Types|variable type]]. || none
|-
| 7 || Out of memory || A module has exceeded the 64K memory limitation of QB. Try breaking the code up to smaller modules.|| no limit
|-
| 8 || Label not defined || [[GOTO]] or [[GOSUB]] tries to branch to a label that doesn't exist. || none
|-
| 9 || Subscript out of range || An [[Arrays|array's]] [[UBOUND|upper]] or [[LBOUND|lower]] [[DIM|dimensioned]] boundary has been exceeded. || none
|-
| 10 || Duplicate definition || You can't define a variable twice with [[DIM]], the first time a variable is used it is also defined. || none
|-
| 11 || Division by zero || You cannot divide any value by zero! Even using [[MOD]]. || none
|-
| 12 || Illegal in direct mode || A statement (like [[DIM]]) in the Immediate window wasn't allowed. || N/A
|-
| 13 || Type mismatch || A [[SUB]] or [[FUNCTION]] parameter does not match the procedure Declaration. || none
|-
| 14 || Out of [[STRING|string]] space || A module has exceeded the 32767 text character limit. Use SUB print procedures. || no limit.
|-
| 16 || String formula too complex. || A string formula was too long or [[INPUT]] statement requested more than 15 strings || N/A
|-
| 17 || Cannot continue. || The program while debugging has changed in a way that it cannot continue. || no debug
|-
| 18 || Function not defined. || The function used by the program must be defined. Did you include the .bi file while using a library? || none
|-
| 19 || No [[RESUME]]. || Use [[RESUME]] at the end of the [[ON ERROR]] [[GOTO]] routine, not [[RETURN]]. || none
|-
| 20 || RESUME without error. || [[RESUME]] can only be used in an error handler called by [[ON ERROR]] [[GOTO]]. || none
|-
| 24 || Device timeout. || Use DS0 (DSzero)in the [[OPEN COM]] statement to avoid modem timeouts. || none
|-
| 25 || Device fault. || Device not connected or does not exist. || none
|-
| 26 || [[FOR]] without [[NEXT]]. || Missing loop end or look for a missing [[END IF]] or [[END SELECT]] statement. || none
|-
| 27 || Out of paper || A printer paper error when using [[LPRINT]]. || none
|-
| 29 || [[WHILE]] without [[WEND]]. || [[WEND]] must end a [[WHILE]] loop. Otherwise look for missing [[END IF]] or [[END SELECT]] || none
|-
| 30 || [[WEND]] without [[WHILE]] || Missing loop end or look for a missing [[END IF]] or [[END SELECT]] statement. || none
|-
| 33 || Duplicate label || Line numbers or labels cannot be used twice in a procedure. || none
|-
| 35 || Subprogram not defined. || Often occurs when the Quickbasic Library is not used with [[CALL ABSOLUTE]] or [[INTERRUPT]] or a [[SUB]] or [[FUNCTION]] procedure has not been created for a [[CALL]]. || none
|-
| 37 || Argument-count mismatch || The number of sub-procedure [[parameters]] do not match the call. || none
|-
| 38 || Array not defined || [[Arrays]] using more than 10 elements must be [[DIM|DIMensioned]]. || none
|-
| 40 || Variable required. || [[LEN]] cannot read literal numerical values. A [[GET]] or [[PUT]] statement must specify a variable when reading or writing a file opened in [[BINARY]] mode. || none
|-
| 50 || [[FIELD]] overflow. || A [[FIELD]] statement tried to allocate more bytes than were specified for the record length of a random access file. || none
|-
| 51 || Internal error. || An internal malfunction occured in QuickBASIC or QB64. || none
|-
| 52 || Bad file name or number. || The filename must follow the rules for filenames in the OS and use filenumbers from 1 and 255. Use [[FREEFILE]] to avoid duplicate [[OPEN]] file numbers. || none
|-
| 53 || File not found. || File not in current directory or path. Use [[_FILEEXISTS]] to verify file names. || none
|-
| 54 || Bad file mode. || File access mode does not match a current [[OPEN]] file procedure. || none
|-
| 55 || File already open. || [[CLOSE]] a file to open it in a different mode. || none
|-
| 56 || FIELD statement active. || '''WRITEME''' || N/A
|-
| 57 || Device I/O error. || '''WRITEME''' || N/A
|-
| 58 || File already exists. || The filename specified in the [[NAME]] statement was identical to a file that already exists. || none
|-
| 59 || Bad record length. || Record length exceeds 32767 bytes or is 0 || none
|-
| 61 || Disk full. || The amount of data to write to the disk was more than the free space available, remove some files you don't need and try again. || none
|-
| 62 || Input past end of file. || Check for the end of file with [[EOF]] when reading from a file. || none
|-
| 63 || Bad record number. || [[GET]] read exceeds number of records in a [[RANDOM]] file. || none
|-
| 64 || Bad file name || File name contains illegal characters or exceeds 12 characters. || none
|-
| 67 || Too many files || Over 15 files are open in Qbasic. || none
|-
| 68 || Device unavailable. || Device does not exist, busy or not connected. || none
|-
| 69 || Communication-buffer overflow. || '''WRITEME''' || N/A
|-
| 70 || Permission denied || A file or port is in use on a network, blocked, read only or locked. || none
|-
| 71 || Disk not ready. || Disk is busy or has no media. || none
|-
| 72 || Disk-media error. || Improper media format or bad data. || none
|-
| 73 || Feature unavailable. || Based on the DOS version available. || none
|-
| 74 || Rename across disks. || '''WRITEME''' || N/A
|-
| 75 || Path/File access error. || File or path cannot be accessed. || none
|-
| 76 || Path not found. || Path is not access-able or does not exist. Use [[_DIREXISTS]] to check paths.|| none
|-
| 97 || (no error message) || Can be used to trigger an error trap event with [[ERROR]] 97, nothing else will cause this error, so create your own errors for [[ON ERROR]]. || none
|-
|}
<center>'''N/A means Not Available or Not Applicable to QB64.'''</center>
{| border="1" cellpadding="2"
! colspan="6"|QB64 Error Codes
|-
! Code || Description || Common cause/resolution || QB Differences
|-
| 258 || Invalid handle || Zero or bad handle values cannot be used by the QB64 procedure creating the error. || N/A
|}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
== Error Trapping: ==
@ -359,6 +496,52 @@
<center> See also: [[Unicode]], [[Code Pages|Unicode Code Pages]] or [[ASCII|ASCII Code Table]]</center>
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
== Game Controller Input (Joystick): ==
* [[_AXIS]] (function) {{text|returns a [[SINGLE]] value between -1 and 1 indicating the maximum distance from device axis center 0.}}
* [[_BUTTON]] (function) {{text|returns -1 when a device button is pressed and 0 when button is released.}}
* [[_BUTTONCHANGE]] (function) {{text|returns -1 when a device button has been pressed and 1 when released. Zero indicates no change.}}
* [[_DEVICE$]] (function) {{text|returns a [[STRING]] expression listing a designated numbered input device name and types of input.}}
* [[_DEVICEINPUT]] (function) {{text|returns the [[_DEVICES]] number of an [[_AXIS]], [[_BUTTON]] or [[_WHEEL]] event.}}
* [[_DEVICES]] (function) {{text|returns the number of input devices found on a computer system including the keyboard and mouse.}}
* [[_LASTAXIS]] (function) {{text|returns the number of axis available on a specified number device listed by [[_DEVICE$]].}}
*[[_LASTBUTTON]] (function) {{text|returns the number of buttons available on a specified number device listed by [[DEVICE$]].}}
* [[_LASTWHEEL]] (function) {{text|returns the number of scroll wheels available on a specified number device listed by [[_DEVICE$]].}}
* [[_MOUSEMOVEMENTX]] (function) {{text|returns the relative horizontal position of the mouse cursor compared to the previous position.}}
* [[_MOUSEMOVEMENTY]] (function) {{text|returns the relative vertical position of the mouse cursor compared to the previous position.}}
* [[_WHEEL]] (function) {{text|returns -1 when a device wheel is scrolled up and 1 when scrolled down. Zero indicates no activity.}}
* [[ON STRIG(n)]] (event statement) {{text|directs program flow upon a button press event of a game controller device.}}
* [[STICK]] (function) {{text|returns the directional axis coordinate values from 1 to 254 of game port (&H201) or USB controller devices.}}
* [[STRIG]] (function) {{text|returns the True or False button press status of game port (&H201) or USB controller devices.}}
* [[STRIG(n)]] (statement) {{text|enables, suspends or disables event trapping of STRIG button return values.}}
<center> See also: [[Windows_Libraries#Game_Pad|Windows Game Pad]] or [[SDL_Libraries#Joystick|SDL Joystick]] Libraries.</center>
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==Graphic GL Special Commands==
<center>[http://www.qb64.net/wiki/index.php/Keyword_Reference_-_Alphabetical#glA Full list of QB64 _GL prefixed statements and functions] </center>
* [[_COPYIMAGE]] (function) {{text|can copy a software surface to a hardware accelerated surface handle using mode 33.}}
* [[_DISPLAY]] (statement) {{text|renders surfaces visible in the [[_DISPLAYORDER]] previously set in the QB64GL program.}}
* [[_DISPLAYORDER]] (GL statement) {{text|sets the rendering order of _SOFTWARE, _HARDWARE and _GLRENDER with [[_DISPLAY]].}}
* [[_LOADIMAGE]] (function) {{text|can load images as hardware accelerated using mode 33.}}
* [[_MOUSESHOW]] (statement) {{text|a special string parameter after command in GL allows some special cursor shapes.}}
* [[_PUTIMAGE]] (statement) {{text|can place GL surfaces and allows the _SMOOTH action to blend stretched surfaces.}}
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
== Graphics and Imaging: ==
@ -375,7 +558,7 @@
* [[_FULLSCREEN]] (statement) {{text|sets the full screen mode of the screen window. Alt + Enter can do it manually.}}
* [[_FREEIMAGE]] (statement) {{text|releases an image handle value from memory when no longer needed.}}
* [[_HEIGHT]] (function) {{text|returns the height of an image handle or current write page.}}
* [[_ICON]] (function) {{text|places an image in the title bar using a [[_LOADIMAGE]] handle. Cannot use Icons!}}
* [[_ICON]] (function) {{text|places an image in the title bar using a [[_LOADIMAGE]] handle. (Icons can be used in GL only!)}}
* [[_LOADIMAGE]] (function) {{text|loads a graphic file image into memory and returns an image handle.}}
* [[_MAPTRIANGLE]] (statement) {{text|maps a triangular portion of an image to a destination image or screen page.}}
* [[_NEWIMAGE]] (function) {{text|prepares a window image or page surface and returns the handle value.}}
@ -413,46 +596,12 @@
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
== Joystick and Game Controller Input: ==
* [[_AXIS]] (function) {{text|returns a [[SINGLE]] value between -1 and 1 indicating the maximum distance from device axis center 0.}}
* [[_BUTTON]] (function) {{text|returns -1 when a device button is pressed and 0 when button is released.}}
* [[_BUTTONCHANGE]] (function) {{text|returns -1 when a device button has been pressed and 1 when released. Zero indicates no change.}}
* [[_DEVICE$]] (function) {{text|returns a [[STRING]] expression listing a designated numbered input device name and types of input.}}
* [[_DEVICEINPUT]] (function) {{text|returns the [[_DEVICES]] number of an [[_AXIS]], [[_BUTTON]] or [[_WHEEL]] event.}}
* [[_DEVICES]] (function) {{text|returns the number of input devices found on a computer system including the keyboard and mouse.}}
* [[_LASTAXIS]] (function) {{text|returns the number of axis available on a specified number device listed by [[_DEVICE$]].}}
*[[_LASTBUTTON]] (function) {{text|returns the number of buttons available on a specified number device listed by [[DEVICE$]].}}
* [[_LASTWHEEL]] (function) {{text|returns the number of scroll wheels available on a specified number device listed by [[_DEVICE$]].}}
* [[_MOUSEMOVEMENTX]] (function) {{text|returns the relative horizontal position of the mouse cursor compared to the previous position.}}
* [[_MOUSEMOVEMENTY]] (function) {{text|returns the relative vertical position of the mouse cursor compared to the previous position.}}
* [[_WHEEL]] (function) {{text|returns -1 when a device wheel is scrolled up and 1 when scrolled down. Zero indicates no activity.}}
* [[ON STRIG(n)]] (event statement) {{text|directs program flow upon a button press event of a game controller device.}}
* [[STICK]] (function) {{text|returns the directional axis coordinate values from 1 to 254 of game port (&H201) or USB controller devices.}}
* [[STRIG]] (function) {{text|returns the True or False button press status of game port (&H201) or USB controller devices.}}
* [[STRIG(n)]] (statement) {{text|enables, suspends or disables event trapping of STRIG button return values.}}
<center> See also: [[Windows_Libraries#Game_Pad|Windows Game Pad]] or [[SDL_Libraries#Joystick|SDL Joystick]] Libraries.</center>
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
== Keyboard Input: ==
* [[_CONTROLCHR]] (statement) {{text|[[OFF]] allows the control characters to be used as text characters. [[ON]](default) can use them as commands.}}
* [[_CONTROLCHR (function)]] {{text| returns the current state of _CONTROLCHR as 1 when OFF and 0 when ON.}}
* [[_EXIT (function)]] {{text|prevents a program user exit and indicates if a user has clicked the close X window button or CTRL + BREAK.}}
* [[_KEYDOWN]] (function) {{text|returns whether modifying keys like CTRL, ALT, SHIFT, and any other keys are pressed.}}
* [[_KEYHIT]] (function) {{text|returns ASCII one and two byte, SDL Virtual Key and Unicode keyboard key press codes.}}
* [[_SCREENPRINT]] (statement) {{text|simulates typing text into another OS program using the keyboard.}}
@ -548,13 +697,13 @@
== Memory Handling and Clipboard: ==
* [[_CLIPBOARD (function)]] {{text|returns the current [[STRING]] contents of the system Clipboard.}}
* [[_CLIPBOARD (statement)]] {{text|sets and overwrites the [[STRING]] contents of the current system Clipboard.}}
* [[_OFFSET (function)]] {{text|returns the memory offset of a variable when used with [[DECLARE LIBRARY]] and [[_MEM]]ory only.}}
* [[_CLIPBOARD$ (function)]] {{text|returns the current [[STRING]] contents of the system Clipboard.}}
* [[_CLIPBOARD$ (statement)]] {{text|sets and overwrites the [[STRING]] contents of the current system Clipboard.}}
* [[_MEM (function)]] {{text|returns _MEM block referring to the largest continuous memory region beginning at a designated variable's offset.}}
* [[_MEM]] (variable type) {{text|contains read only dot elements for the OFFSET, SIZE, TYPE and ELEMENTSIZE of a block of memory.}}
* [[_MEMCOPY]] (statement) {{text|copies a value from a designated OFFSET and SIZE [[TO]] a block of memory at a designated OFFSET.}}
* [[_MEMELEMENT]] (function) {{text|returns a [[_MEM]] block referring to a variable's memory (but not past it).}}
* [[_MEMEXISTS]] (function) {{text|verifies that a memory block exists for a memory variable name or returns zero.}}
* [[_MEMFILL]] (statement) {{text|fills a designated memory block OFFSET with a certain SIZE and TYPE of value.}}
* [[_MEMFREE]] (statement) {{text|frees a designated memory block in a program. Only free memory once!}}
* [[_MEMGET]] (statement) {{text|reads a designated value from a designated memory OFFSET}}
@ -785,7 +934,9 @@
* [[_SNDPLAYING]] (function) {{text|returns whether a sound handle is being played.}}
* [[_SNDRATE]] (function) {{text|returns the sample rate frequency per second of the current computer's sound card.}}
* [[_SNDRAW]] (statement) {{text|plays sound wave sample frequencies created by a program.}}
* [[_SNDRAWDONE]] (statement) {{text|pads a [[_SNDRAW]] stream so the final (partially filled) buffer section is played.}}
* [[_SNDRAWLEN]] (function) {{text|returns the length, in seconds, of a _SNDRAW sound currently queued.}}
* [[_SNDRAWOPEN]] (function) {{text|returns a handle to a new, separate [[_SNDRAW]] audio stream.}}
* [[_SNDSETPOS]] (statement) {{text|changes the current/starting playing position of a sound in seconds.}}
* [[_SNDSTOP]] (statement) {{text|stops a playing or paused sound handle.}}
* [[_SNDVOL]] (statement) {{text|sets the volume of a sound handle being played.}}
@ -803,6 +954,8 @@
* [[_CLIPBOARD$]] (function) {{text|returns the current [[STRING]] contents of the system Clipboard.}}
* [[_CLIPBOARD$ (statement)]] {{text|sets the [[STRING]] contents of the current system Clipboard.}}
* [[_CONTROLCHR]] (statement) {{text|[[OFF]] allows the control characters to be used as text characters. [[ON]](default) can use them as commands.}}
* [[_CONTROLCHR (function)]] {{text| returns the current state of _CONTROLCHR as 1 when OFF and 0 when ON.}}
* [[_CV]] (function) {{text|used to convert [[_MK$]] [[ASCII]] [[STRING|string]] values to numerical values.}}
* [[_MK$]] (function) {{text|converts any numerical type into an [[ASCII]] [[STRING|string]] value that must be converted back using [[_CV]].}}
@ -899,9 +1052,7 @@
* [[_FONT]] (statement) {{text|sets the current [[_LOADFONT]] function font handle to be used by [[PRINT]] or [[_PRINTSTRING]].}}
* [[_MAPUNICODE]] (statement) {{text|maps a [[Unicode]] value to an [[ASCII]] character code value.}}
* [[_PRINTSTRING]] (statement) {{text|prints text or custom font strings using graphic column and row coordinate positions.}}
* [[_SCREENPRINT]] (s
4ab9
tatement) {{text|simulates typing text into a Windows program using the keyboard.}}
* [[_SCREENPRINT]] (statement) {{text|simulates typing text into a Windows program using the keyboard.}}
* [[CHR$]] (function) {{text|returns the text character associated with a certain [[ASCII]] character code as a one byte [[STRING]].}}
@ -971,7 +1122,12 @@ tatement) {{text|simulates typing text into a Windows program using the keyboard
* [[_HEIGHT]] (function) {{text|returns the height of a [[_SCREENIMAGE]] handle to get the desktop resolution.}}
* [[_ICON]] (statement) {{text|creates a program icon from an image file handle created by [[_LOADIMAGE]]. Cannot use .ICO files!}}
* [[_NEWIMAGE]] (statement) {{text|function prepares a window image surface and returns the handle value.}}
* [[$RESIZE]] ([[Metacommand]]) {{text|used with ON allows a user to resize the program window where OFF does not.}}
* [[_RESIZE (function)]] {{text|returns -1 when a program user wants to resize the GL program screen.}}
* [[_RESIZEHEIGHT]] (function) {{text|returns the requested new user screen height when [[$RESIZE]]:ON allows it.}}
* [[_RESIZEWIDTH]] (function) {{text|returns the requested new user screen width when [[$RESIZE]]:ON allows it.}}
* [[_SCREENCLICK]] {{text|simulates clicking the mouse at a position on the screen to get focus.}}
* [[_SCREENEXISTS]] (function) {{text|returns a -1 value once a screen has been created.}}
* [[$SCREENHIDE]] (QB64 [[Metacommand]]) {{text|hides the program window throughout the program until [[$SCREENSHOW]] is used.}}
* [[_SCREENHIDE]] (statement) {{text|hides the main program window in a section of code until [[_SCREENSHOW]] is used.}}
* [[_SCREENIMAGE]] (function) {{text|creates an image of the current desktop and returns an image handle.}}

View file

@ -1,8 +1,8 @@
The {{KW|LCASE$}} function changes the uppercase letters of a {{KW|STRING}} to lowercase.
The '''LCASE$''' function changes the uppercase letters of a {{KW|STRING}} to lowercase.
{{PageSyntax}}
:''result$'' = {{KW|LCASE$}}({{Parameter|text$}})
:''result$'' = '''LCASE$('''{{Parameter|text$}}''')'''
{{PageDescription}}
@ -10,19 +10,19 @@ The {{KW|LCASE$}} function changes the uppercase letters of a {{KW|STRING}} to l
* Will not affect non alphabet string characters.
{{PageExamples}}
:The following code
''Example:'' The following code guarantees that all user letter entries will be lower case:
{{CodeStart}}{{Cl|PRINT}} "Do you want to continue? (y/n)"
{{Cl|DO...LOOP|DO}}
K$ = {{Cl|LCASE$}}({{Cl|INKEY$}})
{{Cl|DO...LOOP|LOOP}} {{Cl|DO...LOOP|UNTIL}} K$ = "y" {{Cl|OR}} K$ = "n"
{{CodeEnd}}
{{PageSeeAlso}}
* {{KW|UCASE$}}
* [[UCASE$]] {{text|(upper case)}}
* [[INKEY$]]
* [[INPUT$]]
{{PageNavigation}}

View file

@ -3,14 +3,18 @@ The '''LEFT$''' string function returns a part of a [[STRING]] from the start a
{{PageSyntax}}
:: LEFT$(stringvalue$, numberofcharacters%)
:: '''LEFT$('''''stringvalue$'', ''numberofcharacters%''''')'''
{{Parameters}}
* The ''stringvalue$'' can be any [[STRING]] variable of [[ASCII]] text characters.
* The ''numberofcharacters'' [[INTEGER]] value determines the number of characters to return from left end of string.
* The string value can be any string of [[ASCII]] characters as a string variable.
* If the number of characters exceeds the string length the entire string is returned.
* Number of characters cannot be a negative value.
* LEFT$ returns always starts at the first character of the string, even when a space. [[LTRIM$]] can remove leading spaces.
{{PageDescription}}
* If the number of characters exceeds the string length the entire string is returned. Use [[LEN]] to determine a string length.
* LEFT$ returns always start at the first character of the string, even when a space. [[LTRIM$]] can remove leading spaces.
* '''The Number of characters cannot be a negative value.'''
''Example 1:'' Getting the left portion of a string value.
@ -59,7 +63,7 @@ This is your sentence to change your words.{{OutputEnd}}
* [[RIGHT$]], [[MID$]]
* [[LTRIM$]], [[RTRIM$]]
* [[MID$ (statement)]]
* [[INSTR]]
* [[INSTR]], [[LEN]]
{{PageNavigation}}

View file

@ -3,26 +3,49 @@ The '''LINE''' statement is used in graphics [[SCREEN (statement)|SCREEN]] modes
{{PageSyntax}}
: LINE [STEP](column1, row1)-[STEP](column2, row2), color%[, [{B|BF}]][, style%]
: '''LINE''' [STEP] [(''column1'', ''row1'')]'''-'''[STEP] '''('''''column2'', ''row2'''''),''' ''color''[, [{B|BF}], style%]
* Can use [[STEP]] keyword for graphics coordinates relative to a previously placed objects.
{{Parameters}}
* Can use [[STEP]] keyword for graphics coordinates relative to the previously placed object before either set of coordinates.
* The optional parameters (''column1'', ''row1'') set the first coordinate or use the last previous object coordinate when omitted.
* The dash and second coordinate parameters (''column2'', ''row2'') must be designated to complete the line or box.
* The [[INTEGER]] ''color'' attribute or [[LONG]] [[_RGB32]] 32 bit color value sets the line, box or full box color.
* Optional '''B''' creates a box outline using the start and end coordinates as diagonal corners. '''BF''' creates a filled box.
* The ''style'' [[INTEGER]] value sets dashed lines with varying patterns when using values from 0 to 32767.
{{PageDescription}}
* Creates a colored line from coordinate1 to coordinate2 if the box options(B or BF) are omitted. Can be drawn partially offscreen.
* Creates a colored box outline if the '''B''' option is used.
* Creates a color filled box if the '''BF''' option is used.
* Style is any [[INTEGER]] value from 0 to 32767. It creates dashed lines or box outlines. The Box comma is required with style even when not creating a box. The lines are created where the style value's bits are on. '''BF cannot be used with style.'''
* '''B''' creates a box outline with each side parallel to the program screen sides. '''BF''' creates an identical filled box.
* '''B''' can be used with style to create a dash pattern on all 4 box sides. '''BF cannot be used with style.'''
* Both commas are required with style even when not creating a box. The lines are created where the style determines.
* The QB64 and QB graphic cursor is set to the center of the program window on program start.
* '''LINE can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only!'''
''Example:'' Creating styled lines and boxes with the LINE statement. Different style values create different dashed line spacing.
''Example 1:'' Following one line with another by omitting the second line's first coordinate parameter bracket entirely:
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|LINE}} (100, 100)-(200, 200), 10 'creates a line
{{Cl|LINE}} -(400, 200), 12 'creates a second line from end of first
{{Cl|END}} '' ''
{{CodeEnd}}
:''Explanation:'' The full equivalent LINE statement would be: '''{{text|LINE(200, 200)-(400, 200), 12|green}}'''
''Example 2:'' Creating styled lines and boxes with the LINE statement. Different style values create different dashed line spacing.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|LINE}} (100, 100)-(300, 300), 10, , 63 'creates a styled line
{{Cl|LINE}} (100, 100)-(300, 300), 12, B , 255 'creates styled box shape
{{Cl|LINE}} (100, 100)-(300, 300), 12, B, 255 'creates styled box shape
{{Cl|END}} '' ''
{{CodeEnd}}
:''Explanation:'' The first diagonal dashed green line bisects the red dashed square from Top Left to Bottom Right Corners.
''See also:''

View file

@ -22,6 +22,7 @@ The '''LINE INPUT''' statement requests a [[STRING]] keyboard entry from a progr
* LINE INPUT does not trim off leading or trailing spaces in the string entry like [[INPUT]] string returns.
* Use [[VAL]] to convert string numbers and [[&O]](octal) or [[&H]](hexadecimal) prefixed entries into numerical values.
* Use [[_DEST]] [[_CONSOLE]] before LINE INPUT statements to be used in a [[$CONSOLE|console]] window.
* '''Note: QB64''' will NOT remove CHR$(0) from the end of LINE INPUT string return values like Qbasic did.
''Example:'' Preventing screen roll after an input entry on the bottom 2 screen rows.
@ -43,7 +44,7 @@ n$ = {{Cl|UCASE$}}(name$) ' convert search name to upper case
''See also:''
* [[INPUT (file mode)]], [[INPUT (file statement)|INPUT #]] [[LINE INPUT (file statement)|LINE INPUT #]], [[INPUT$]] {{text|(file input)}}
* [[INPUT (file mode)]], [[INPUT (file statement)|INPUT #]], [[LINE INPUT (file statement)|LINE INPUT #]]
* [[INPUT]], [[INPUT$]] {{text|(keyboard input)}}
* [[COLOR]], [[LOCATE]]
* [[INKEY$]]

View file

@ -3,16 +3,25 @@ The '''LINE INPUT #''' file statement reads an entire file line as one string va
{{PageSyntax}}
:: LINE INPUT #filenumber%, linereturn$
:: '''LINE INPUT''' '''#'''''filenumber&''''',''' ''textlinereturn$''
{{Parameters}}
* ''filenumber'' is the [[INTEGER]] number of the file previously opened [[AS]].
* Statement [[STRING]] variable returns ''text line'' of the file being read ending at [[ASCII#Control_Characters|CRLF]] characters.
* Reads a file using the filenumber [[OPEN]]ed in the [[INPUT (file mode)]] as one file string value.
* Returns [[STRING]] values so it must use one string variable.
''Description:''
* Reads a file using the filenumber [[OPEN]]ed in the [[INPUT (file mode)]] or GL [[BINARY]] file mode as one file line text string.
* Can be used with [[EOF]] to count the number of lines of data (records) in a file using a loop.
* Use the [[EOF]] function to avoid going past the end of a file and creating an error.
* LINE INPUT # can even retain the original quotation marks in text.
* '''NOTE: If QB64 or QB 4.5 give "Input past End of file" errors, check for CHR$(26) in the files being read!'''
* '''Note: QB64''' will NOT remove CHR$(0) from the end of LINE INPUT # string return values like Qbasic did.
* '''NOTE: [[LINE INPUT (file statement)|LINE INPUT]] will work faster in [[BINARY]] than [[INPUT (file mode)|INPUT]] mode in QB64 to stay compatible with QB.'''
{{PageErrors}}
* '''If QB64 or QB 4.5 give "Input past End of file" errors, check for CHR$(26) in the files being read!'''
* '''Warning! Files must exist to open them in INPUT mode! Use [[_FILEEXISTS]] to avoid program [[ERROR Codes|errors]]!'''
@ -34,6 +43,7 @@ The '''LINE INPUT #''' file statement reads an entire file line as one string va
''See also:''
* [[OPEN]], [[CLOSE]]
* [[INPUT (file mode)]], [[INPUT (file statement)|INPUT #]], [[INPUT$]] {{text|(file input)}}
* [[INPUT]], [[LINE INPUT]], [[INPUT$]] {{text|(keyboard input)}}
* [[_FILEEXISTS]], [[_DIREXISTS]]

View file

@ -6,13 +6,14 @@ The '''LOCATE''' statement locates the screen text row and column positions for
{{Parameters}}
* optional ''row'' [[INTEGER]] values are from 1 to the 25 in [[SCREEN]] 0 and most other graphic screen modes, except screens 11 and 12 which have 30.
* optional ''column'' [[INTEGER]] values are from 1 to the [[SCREEN]] mode text [[_WIDTH (function)|_WIDTH]] or [[WIDTH]] setting.
* optional text ''row'' [[INTEGER]] values are from 1 to the 25, 43 or 50 in [[SCREEN]] 0 and 25 in most other graphic screen modes, except screens 11 and 12 which can have 30 or 60.
* optional ''column'' [[INTEGER]] values are from 1 to 40 or 80 in [[SCREEN]] 0 and 80 in all other legacy screen modes.
* optional ''cursor'' value can be 0 to turn the cursor off or 1 to turn it on when using the [[INPUT$]] or [[INKEY$]] key entry functions only.
* optional ''cursorstart'' and ''cursorstop'' values define the shape of the cursor by setting the start and stop scanline (0-8 pixels) for the cursor character.
''Usage:''
* [[WIDTH]] statement can be used to determine the text width and height in [[SCREEN]] 0 and height of 30 or 60 in [[SCREEN]] 11 or 12.
* In [[_NEWIMAGE]] graphic screen text ''rows'' are calculated as [[_HEIGHT]] \ 16 except when a [[_FONT]] is used. Use [[_FONTHEIGHT]] to calculate font rows.
* [[_NEWIMAGE]] graphic screen text ''columns'' are calculated as [[_WIDTH (function)|_WIDTH]] \ 8 except when a [[_FONT]] is used. Use [[_PRINTWIDTH]] to measure a line of font text.
* The text ''row'' position is not required if the [[PRINT]] is going to be on the next row. The [[comma]] and a ''column'' value are required to set the column.
@ -47,6 +48,7 @@ LOOP '' ''
* [[CSRLIN]], [[POS]] {{text|(cursor position)}}
* [[SCREEN]], [[PRINT]], [[COLOR]]
* [[INPUT]], [[LINE INPUT]], [[INPUT$]] {{text|(keyboard input)}}
* [[WIDTH]], [[INPUT$]], [[INKEY$]]
{{PageNavigation}}

View file

@ -3,7 +3,7 @@ The '''LOF''' Function is used to find the length of an [[OPEN]] file in bytes.
{{PageSyntax}}
:: bytes% = LOF(filenumber%)
:: bytes = LOF(filenumber)
* LOF returns the number of bytes in an OPENed designated filenumber. File is empty if it returns 0.

View file

@ -22,7 +22,7 @@
* [[MKL$]], [[CVL]]
* [[INTEGER]], [[_INTEGER64]]
* [[SINGLE]], [[DOUBLE]]
* [[_UNSIGNED]]
* [[_DEFINE]], [[_UNSIGNED]]
* [[Variable Types]]

View file

@ -1,25 +1,26 @@
The {{KW|LPRINT}} statement sends string text or numerical values to a parallel port(<tt>LPT1</tt>) printer in Qbasic or a USB printer in '''QB64'''.
The {{KW|LPRINT}} statement sends string text or numerical values to a parallel port(LPT1) printer in Qbasic or a USB printer in '''QB64'''.
{{PageSyntax}}
:{{KW|LPRINT}} [{{Parameter|text$}}] [{;|,}]
:{{KW|LPRINT}} [{{Parameter|expression}}] [{;|,}]
{{PageDescription}}
* {{Parameter|expressionList}} is one or more expressions separated by a semi-colon (;) or comma (,).
* {{Parameter|expression}} is one or more text or numerical expressions separated by a semi-colon (;) or comma (,).
* Syntax is the same as [[PRINT]], but cannot use a port number.
* Program does not have to [[OPEN]] the LPT1: parallel port. In fact that is NOT recommended!
* Assumes a 80 character wide page unless a {{KW|WIDTH|WIDTH LPRINT}} statement is used.
* [[LPRINT USING]] can print formatted data to a page, similar to [[PRINT USING]].
* Assumes a 80 character wide page unless a [[WIDTH|WIDTH LPRINT]] statement is used. '''[[Keywords currently not supported by QB64|WIDTH LPRINT is currently NOT supported in QB64!]]'''
* [[LPRINT USING]] can print formatted text data to a page identically to how [[PRINT USING]] formats a program screen.
* [[COLOR]]ed text and images can be printed using [[_PRINTIMAGE]] which stretches them to fit the default printer's paper size.
* LPRINT will only print to the DEFAULT USB or LPT printer that works in Windows.
*'''[[Keywords currently not supported by QB64|WIDTH LPRINT is currently NOT supported in QB64!]]'''
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]
* LPRINT will only print to the DEFAULT USB or LPT printer that works in Windows. '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''
* Note: Printer Escape codes starting with [[CHR$]](27) will not work with LPRINT and may produce text printing errors.
{{PageSeeAlso}}
* {{KW|LPRINT USING}}, {{KW| _PRINTIMAGE}} {{text|(prints color images)}}
* {{KW|PRINT}}, {{KW|PRINT USING}}
* [[LPRINT USING]]
* [[_PRINTIMAGE]] {{text|(prints color images to page size)}}
* [[PRINT]], [[PRINT USING]]
* [[Windows Printer Settings]]
{{PageNavigation}}

View file

@ -16,27 +16,90 @@ The '''MID$''' function returns a portion of a [[STRING]]'s value from any posit
* Number of character ''bytes'' should be within the string's [[LEN|length]] from the start position, but will only return the string's remainder when exceeded.
* If the ''bytes'' value is 0 or the ''start position'' is 0 or greater than the [[LEN|length]] of the string, nothing is returned (no error).
* In QBasic the ''start position'' cannot be zero(0) or an [[ERROR Codes|Illegal function call error]] will occur.
* In '''QB64''' [[ASC]] string byte position reads are about '''5 times faster''' than MID$ when parsing strings. See ''Example 2'' below.
''Example:'' Getting the hour and minutes from [[TIME$]]
''Example 1:'' Getting the hour and minutes from [[TIME$]]
{{CodeStart}} '' ''
{{Cl|PRINT}} {{Cl|TIME$}}
hour$ = {{Cl|LEFT$}}({{Cl|TIME$}}, 2)
minutes$ = {{Cl|MID$}}({{Cl|TIME$}}, 4, 2) ' skip hours and the colon (3 characters)
minutes$ = {{Cl|MID$}}({{Cl|TIME$}}, 4, 2) ' skip hours and the colon (first 3 characters)
{{Cl|PRINT}} "hour = "; hour$; ": minutes = "; minutes$ '' ''
{{CodeEnd}}
{{OutputStart}}
11:23:30
{{OutputStart}}11:23:30
hour = 11: minutes = 23
{{OutputEnd}}
''Example 2:'' Comparing MID$, the '''QB64''' byte position version of [[ASC]] and [[_MEMGET]] speeds parsing string characters:
{{CodeStart}} '' ''
{{Cl|_TITLE}} "String Speed Test"
{{Cl|DEFLNG}} A-Z
'First let's build a string for testing.
Limit = 100000 'the size of the string
LoopCount = 1000 'the number of times we want to deconstruct it
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit
t$ = t$ + {{Cl|CHR$}}({{Cl|RND}} * 255)
{{Cl|NEXT}}
'now for some times
t1# = {{Cl|TIMER}}
{{Cl|FOR...NEXT|FOR}} j = 1 {{Cl|TO}} LoopCount
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit
m$ = {{Cl|MID$}}(t$, i, 1)
{{Cl|NEXT}}
{{Cl|NEXT}}
t2# = {{Cl|TIMER}}
{{Cl|FOR...NEXT|FOR}} j = 1 {{Cl|TO}} LoopCount
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit
m = {{Cl|ASC}}(t$, i)
{{Cl|NEXT}}
{{Cl|NEXT}}
t3# = {{Cl|TIMER}}
{{Cl|$CHECKING}}:OFF
{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}}, m1 {{Cl|AS}} {{Cl|STRING}} * 1, m2 {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}}
m = {{Cl|_MEMNEW}}(Limit) 'create new memory space for string
{{Cl|_MEMPUT}} m, m.OFFSET, t$ 'put string t$ into memory space
{{Cl|FOR...NEXT|FOR}} j = 1 {{Cl|TO}} LoopCount
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit
{{Cl|_MEMGET}} m, m.OFFSET + i - 1, m1
{{Cl|NEXT}}
{{Cl|NEXT}}
t4# = {{Cl|TIMER}}
{{Cl|FOR...NEXT|FOR}} j = 1 {{Cl|TO}} LoopCount
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} Limit
{{Cl|_MEMGET}} m, m.OFFSET + i - 1, m2
{{Cl|NEXT}}
{{Cl|NEXT}}
t5# = {{Cl|TIMER}}
'results
{{Cl|PRINT USING}} "##.###### seconds for MID$"; t2# - t1#
{{Cl|PRINT USING}} "##.###### seconds for ASC"; t3# - t2#
{{Cl|PRINT USING}} "##.###### seconds for _MEMGET String"; t4# - t3#
{{Cl|PRINT USING}} "##.###### seconds for _MEMGET Byte"; t5# - t4# '' ''
{{CodeEnd}} {{small|Code by Steve McNeill}}
{{OutputStart}}6.593750 seconds for MID$
1.044922 seconds for ASC
0.494141 seconds for _MEMGET String
0.494141 seconds for _MEMGET Byte
{{OutputEnd}}
: ''Note:'' [[_MEMGET]] can be used with [[$CHECKING]]:OFF to cut the parsing speed even more! [[STRING]] * 1 or [[_BYTE]] are similar speeds.
''See also:''
* [[MID$ (statement)]], [[LEFT$]], [[RIGHT$]]
* [[LTRIM$]], [[RTRIM$]], [[INSTR]], [[LEN]]
* [[MID$ (statement)]], [[ASC]]
* [[LEFT$]], [[RIGHT$]]
* [[LTRIM$]], [[RTRIM$]]
* [[INSTR]], [[LEN]]
* [[_MEMPUT]], [[_MEMGET]]
{{PageNavigation}}

View file

@ -18,6 +18,7 @@ The '''MKDIR''' statement creates a new directory at a specified path.
''See also:''
* [[SHELL]], [[CHDIR]], [[FILES]]
* [[NAME]], [[KILL]], [[RMDIR]]
* [[_DIREXISTS]]
* [[Windows_Libraries#File_Dialog_Boxes|Windows Open and Save Dialog Boxes]]

View file

@ -1,4 +1,4 @@
'''MOD''' is mathematical [[INTEGER]] remainder division. Also called Modulus, it can work with integer division when a remainder is necessary.
'''MOD''' is mathematical [[INTEGER]] remainder division. Also called Modulo or Modulus, it works as integer remainder division.
{{PageSyntax}}

View file

@ -0,0 +1,510 @@
{| align="center"
| __TOC__
|}
==Basic and QB64 Numerical Types==
<center>'''Qbasic Number Types'''</center>
* [[INTEGER]] ['''%''']: 2 Byte signed whole number values from -32768 to 32767. 0 to 65535 unsigned. (currently not checked in QB64)
* [[LONG]] ['''&''']: 4 byte signed whole number values from -2147483648 to 2147483647. 0 to 4294967295 unsigned.
* [[SINGLE]] ['''!''']: 4 byte signed floating decimal point values of up to 7 decimal place accuracy. '''Cannot be unsigned!'''
* [[DOUBLE]] [#]: 8 byte signed floating decimal point values of up to 15 decimal place accuracy. '''Cannot be unsigned!'''
* To get '''one byte''' values, can use an [[ASCII]] [[STRING]] character to represent values from 0 to 255 as in [[BINARY]] files.
<center>'''QB64 Number Types'''</center>
* [[_BIT]] ['''`''']: 1 bit signed whole number values of 0 or -1 signed or 0 or 1 unsigned. [[_BIT]] * 8 can hold a signed or unsigned [[_BYTE|byte]] value.
* [[_BYTE]] ['''%%''']: 1 byte signed whole number values from -128 to 127. Unsigned values from 0 to 255.
* [[_INTEGER64]] ['''&&''']: 8 byte signed whole number values from -9223372036854775808 to 9223372036854775807
* [[_FLOAT]] [##]: currently set as 10 byte signed floating decimal point values up to 1.1897E+4932. '''Cannot be unsigned!'''
* [[_OFFSET]] [%&]: undefined flexable length integer offset values used in [[DECLARE DYNAMIC LIBRARY]] declarations ONLY.
<center>'''Signed and Unsigned Integer Values'''</center>
Negative (signed) numerical values can affect calculations when using any of the BASIC operators. SQR cannot use negative values! There may be times that a calculation error is made using those negative values. The SGN function returns the sign of a value as -1 for negative, 0 for zero and 1 for unsigned positive values. ABS always returns an unsigned value.
::::* [[SGN]](n) returns the value's sign as -1 if negative, 0 if zero or 1 if positive.
::::* [[ABS]](n) changes negative values to the equivalent positive values.
::::* '''QB64:''' [[_UNSIGNED]] in a [[DIM]], [[AS]] or [[_DEFINE]] statement for only positive [[INTEGER]] values.
::[[_UNSIGNED]] integer, byte and bit variable values can use the tilde ~ suffix before the type suffix to define the type.
<center>[[#toc|Return to Top]]</center>
==Mathematical Operation Symbols==
Most of the BASIC math operators are ones that require no introduction. The addition, subtraction, multplication and division operators are ones commonly used as shown below:
{| align="center" border=1
! Symbol
! Procedure Type
! Example Usage
! Operation Order
|-
| align="center" |[[+]] ||  Addition || align="center" | c = a + b  || align="center" | Last
|-
| align="center" |[[-]] ||  Subtraction  || align="center" | c = a - b || align="center" | Last
|-
| align="center" |[[-]] ||  Negation  || align="center" | c = - a || align="center" | Last
|-
| align="center" |[[*]] ||  Multiplication || align="center" | c = a * b || align="center" | Second
|-
| align="center" |[[/]] ||  Division  || align="center" | c = a / b || align="center" | Second
|}
BASIC can also use two other operators for '''[[INTEGER]] division'''. Integer division returns only whole number values. [[MOD]] '''remainder division''' returns a value only if an integer division cannot divide a number exactly. Returns 0 if a value is exactly divisible.
{| align="center" border=1
!Symbol
!Procedure Type
!Example Usage
!Operation Order
|-
| align="center" |[[\]] ||  Integer division || align="center" | c = a \ b || align="center" | Second
|-
| align="center" |[[MOD]] ||  Remainder division  || align="center" | c = a MOD b || align="center" | Second
|}
<center>'''''It is an [[ERROR|error]] to divide by zero or to take the remainder modulo zero.'''''</center>
There is also an operator for '''exponential''' calculations. The exponential operator is used to raise a number's value to a designated exponent of itself. In QB the exponential return values are [[DOUBLE]] values. The [[SQR]] function can return a number's Square Root. For other '''exponential roots''' the operator can be used with fractions such as (1 / 3) designating the cube root of a number.
{| align="center" border=1
!Symbol
!Procedure
!Example Usage
!Operation Order
|-
| align="center" |[[^]] || Exponent || align="center" | c = a [[^]] (1 / 2) || align="center" | First
|-
| align="center" | [[SQR]] || Square Root || align="center" | c = [[SQR]](a [[^]] 2 + b [[^]] 2) || align="center" | First
|}
:'''''Note: Exponent fractions should be enclosed in () brackets in order to be treated as a root rather than as division!'''''
<center> '''Negative exponential values must be enclosed in () brackets with QB64 currently!'''</center>
<center>[[#toc|Return to Top]]</center>
==Basic's Order of Operations==
When a normal calculation is made, BASIC works from left to right, but it does certain calculations in the following order:
:::# Exponential and exponential Root calculations including [[SQR]].
:::# Negation (Note that this means that ''- 3 ^ 2'' is treated as ''-(3 ^ 2)'' and not as ''(-3) ^ 2.)''
:::# Multiplication, normal Division, [[INTEGER]] Division and Remainder([[MOD]]) Division calculations
:::# Addition and Subtraction calculations
<center>'''Using Parenthesis to Define the Operation Order'''</center>
Sometimes a calculation may need BASIC to do them in another order or the calculation will return bad results. BASIC allows the programmer to decide the order of operations by using [[parenthesis]] around parts of the equation. BASIC will do the calculations inside of the [[parenthesis]] brackets first and the others from left to right in the normal operation order.
==Basic's Mathematical Functions==
{| align=center border=1
! Function
! Description
|-
| [[ABS]](n) || returns the absolute (positive) value of n: ABS(-5) = 5
|-
| [[ATN]](angle*) || returns the arctangent of an angle in radians: π = 4 * ATN(1)
|-
| [[COS]](angle*) || returns the cosine of an angle in radians. (horizontal component)
|-
| [[EXP]](n) || returns e<sup>x</sup>, '''(n <= 88.02969)''': e = EXP(1) ' (e = 2.718281828459045)
|-
| [[LOG]](n) || returns the base e natural logarithm of n. '''(n > 0)'''
|-
| [[SGN]](n) || returns -1 if n < 0, 0 if n = 0, 1 if n > 0: SGN(-5) = -1
|-
| [[SIN]](angle*) || returns the sine of an angle in radians. (vertical component)
|-
| [[SQR]](n) || returns the square root of a number. '''(n >= 0)'''
|-
| [[TAN]](angle*) || returns the tangent of an angle in radians
|}
<center> '''* angles measured in radians'''</center>
{{TextStart}} '''Degree to Radian Conversion:'''
FUNCTION Radian (degrees)
Radian = degrees * (4 * {{Cb|ATN}}(1)) / 180
END FUNCTION '' ''
FUNCTION Degree (radians)
Degree = radians * 180 / (4 * {{Cb|ATN}}(1))
END FUNCTION
'''Logarithm to base n'''
FUNCTION LOGN (X, n)
IF n > 0 AND n <> 1 AND X > 0 THEN LOGN = {{Cb|LOG}}(X) / {{Cb|LOG}}(n) ELSE BEEP
END FUNCTION '' ''
FUNCTION LOG10 (X) 'base 10 logarithm
IF X > 0 THEN LOG10 = {{Cb|LOG}}(X) / {{Cb|LOG}}(10) ELSE BEEP
END FUNCTION '' ''
{{TextEnd}}
<center>'''The numerical value of n in the [[LOG]](n) evaluation MUST be a positive value!'''</center>
<center>'''The numerical value of n in the [[EXP]](n) evaluation MUST be LESS than or equal to 88.02969!'''</center>
<center>'''The numerical value of n in the [[SQR]](n) evaluation can NOT be a negative value!'''</center>
<center>[[#toc|Return to Top]]</center>
==Derived Mathematical Functions==
The following Trigonometric functions can be derived from the '''BASIC Mathematical Functions''' listed above. Each function checks that certain values can be used without error or a [[BEEP]] will notify the user that a value could not be returned. An error handling routine can be substituted if desired. '''Note:''' Functions requiring '''π''' use 4 * [[ATN]](1) for [[SINGLE]] accuracy. Use [[ATN]](1.#) for [[DOUBLE]] accuracy.
{{TextStart}}'' ''
FUNCTION SEC (x) 'Secant
IF COS(x) <> 0 THEN SEC = 1 / {{Cb|COS}}(x) ELSE BEEP
END FUNCTION
FUNCTION CSC (x) 'CoSecant
IF SIN(x) <> 0 THEN CSC = 1 / {{Cb|SIN}}(x) ELSE BEEP
END FUNCTION
FUNCTION COT (x) 'CoTangent
IF TAN(x) <> 0 THEN COT = 1 / {{Cb|TAN}}(x) ELSE BEEP
END FUNCTION
FUNCTION ARCSIN (x) 'Inverse Sine
IF x < 1 THEN ARCSIN = {{Cb|ATN}}(x / {{Cb|SQR}}(1 - (x * x))) ELSE BEEP
END FUNCTION
FUNCTION ARCCOS (x) ' Inverse Cosine
IF x < 1 THEN ARCCOS = (2 * ATN(1)) - {{Cb|ATN}}(x / {{Cb|SQR}}(1 - x * x)) ELSE BEEP
END FUNCTION
FUNCTION ARCSEC (x) ' Inverse Secant
IF x < 1 THEN ARCSEC = {{Cb|ATN}}(x / {{Cb|SQR}}(1 - x * x)) + ({{Cb|SGN}}(x) - 1) * (2 * ATN(1)) ELSE BEEP
END FUNCTION
FUNCTION ARCCSC (x) ' Inverse CoSecant
IF x < 1 THEN ARCCSC = ATN(1 / SQR(1 - x * x)) + (SGN(x)-1) * (2 * ATN(1)) ELSE BEEP
END FUNCTION
FUNCTION ARCCOT (x) ' Inverse CoTangent
ARCCOT = (2 * {{Cb|ATN}}(1)) - {{Cb|ATN}}(x)
END FUNCTION '' ''
FUNCTION SINH (x) ' Hyperbolic Sine
IF x <= 88.02969 THEN SINH = ({{Cb|EXP}}(x) - {{Cb|EXP}}(-x)) / 2 ELSE BEEP
END FUNCTION '' ''
FUNCTION COSH (x) ' Hyperbolic CoSine
IF x <= 88.02969 THEN COSH = (EXP(x) + EXP(-x)) / 2 ELSE BEEP
END FUNCTION '' ''
FUNCTION TANH (x) ' Hyperbolic Tangent or SINH(x) / COSH(x)
IF 2 * x <= 88.02969 AND EXP(2 * x) + 1 <> 0 THEN
TANH = ({{Cb|EXP}}(2 * x) - 1) / ({{Cb|EXP}}(2 * x) + 1)
ELSE BEEP
END IF
END FUNCTION '' ''
FUNCTION SECH (x) ' Hyperbolic Secant or (COSH(x)) ^ -1
IF x <= 88.02969 AND (EXP(x) + EXP(-x)) <> 0 THEN SECH = 2 / ({{Cb|EXP}}(x) + {{Cb|EXP}}(-x)) ELSE BEEP
END FUNCTION '' ''
FUNCTION CSCH (x) ' Hyperbolic CoSecant or (SINH(x)) ^ -1
IF x <= 88.02969 AND (EXP(x) - EXP(-x)) <> 0 THEN CSCH = 2 / ({{Cb|EXP}}(x) - {{Cb|EXP}}(-x)) ELSE BEEP
END FUNCTION '' ''
FUNCTION COTH (x) ' Hyperbolic CoTangent or COSH(x) / SINH(x)
IF 2 * x <= 88.02969 AND EXP(2 * x) - 1 <> 0 THEN
COTH = ({{Cb|EXP}}(2 * x) + 1) / ({{Cb|EXP}}(2 * x) - 1)
ELSE BEEP
END IF
END FUNCTION '' ''
FUNCTION ARCSINH (x) ' Inverse Hyperbolic Sine
IF (x * x) + 1 >= 0 AND x + SQR((x * x) + 1) > 0 THEN
ARCSINH = {{Cb|LOG}}(x + {{Cb|SQR}}(x * x + 1))
ELSE BEEP
END IF
END FUNCTION '' ''
FUNCTION ARCCOSH (x) ' Inverse Hyperbolic CoSine
IF x >= 1 AND x * x - 1 >= 0 AND x + SQR(x * x - 1) > 0 THEN
ARCCOSH = {{Cb|LOG}}(x + {{Cb|SQR}}(x * x - 1))
ELSE BEEP
END IF
END FUNCTION '' ''
FUNCTION ARCTANH (x) ' Inverse Hyperbolic Tangent
IF x < 1 THEN ARCTANH = {{Cb|LOG}}((1 + x) / (1 - x)) / 2 ELSE BEEP
END FUNCTION
FUNCTION ARCSECH (x) ' Inverse Hyperbolic Secant
IF x > 0 AND x <= 1 THEN ARCSECH = {{Cb|LOG}}(({{Cb|SGN}}(x) * {{Cb|SQR}}(1 - x * x) + 1) / x) ELSE BEEP
END FUNCTION '' ''
FUNCTION ARCCSCH (x) ' Inverse Hyperbolic CoSecant
IF x <> 0 AND x * x + 1 >= 0 AND (SGN(x) * SQR(x * x + 1) + 1) / x > 0 THEN
ARCCSCH = {{Cb|LOG}}(({{Cb|SGN}}(x) * {{Cb|SQR}}(x * x + 1) + 1) / x)
ELSE BEEP
END IF
END FUNCTION '' ''
FUNCTION ARCCOTH (x) ' Inverse Hyperbolic CoTangent
IF x > 1 THEN ARCCOTH = {{Cb|LOG}}((x + 1) / (x - 1)) / 2 ELSE BEEP
END FUNCTION '' ''
{{TextEnd}}
{{WhiteStart}}
'''Hyperbolic Function Relationships:'''
COSH(-x) = COSH(x)
SINH(-x) = -SINH(x)
SECH(-x) = SECH(x)
CSCH(-x) = -CSCH(x)
TANH(-x) = -TANH(x)
COTH(-x) = -COTH(x)
'''Inverse Hyperbolic Function Relatonships:'''
ARSECH(x) = ARCOSH(x) ^ -1
ARCSCH(x) = ARSINH(x) ^ -1
ARCOTH(x) = ARTANH(x) ^ -1
'''Hyperbolic sine and cosine satisfy the Pythagorean trig. identity:'''
(COSH(x) ^ 2) - (SINH(x) ^ 2) = 1
{{WhiteEnd}}
<center>[http://support.microsoft.com/kb/28249 Microsoft's Derived BASIC Functions (KB 28249)]</center>
<center>[[#toc|Return to Top]]</center>
==Mathematical Logical Operators==
: The following logical operators compare numerical values using bitwise operations. The two numbers are compared by the number's [[Binary]] bits on and the result of the operation determines the value returned in decimal form. [[NOT]] checks one value and returns the opposite. It returns 0 if a value is not 0 and -1 if it is 0. See [[Binary]] for more on bitwise operations.
<center>'''Truth table of the 6 BASIC Logical Operators'''</center>
{{Template:LogicalTruthTable}}
<center>BASIC can accept any + or - value that is not 0 to be True when used in an evaluation.</center>
<center>[[#toc|Return to Top]]</center>
==Relational Operators==
Relational Operations are used to compare values in a Conditional [[IF...THEN]], [[SELECT CASE]], [[UNTIL]] or [[WHILE]] statement.
{{Template:RelationalTable}}
<center>[[#toc|Return to Top]]</center>
==Basic's Rounding Functions==
: Rounding is used when the program needs a certain number value or type. There are 4 [[INTEGER]] or [[LONG]] Integer functions and one function each for closest [[SINGLE]] and closest [[DOUBLE]] numerical types. Closest functions use "bankers" rounding which rounds up if the decimal point value is over one half. Variable types should match the return value.
{| align=center border=1
! Name
! Description
|-
|[[INT]](n) || rounds down to lower Integer value whether positive or negative
|-
|[[FIX]](n) || rounds positive values lower and negative to a less negative Integer value
|-
|[[CINT]](n) ||rounds to closest Integer. Rounds up for decimal point values over one half.
|-
| [[CLNG]](n) || rounds Integer or Long values to closest value like CINT.(values over 32767)
|-
| [[CSNG]](n) || rounds Single values to closest last decimal point value.
|-
| [[CDBL]](n) || rounds Double values to closest last decimal point value.
|-
| [[_ROUND]] || rounds to closest numerical integer value in '''QB64''' only.
|}
::: '''Note: Each of the above functions define the value's type in addition to rounding the values.'''
<center>[[#toc|Return to Top]]</center>
==Base Number Systems==
{{TextStart}}
'''Comparing the [[INTEGER]] Base Number Systems'''
'''Decimal (base 10) Binary (base 2) Hexadecimal (base 16) Octal (base 8)'''
''' [[&B]] [[&H]] [[HEX$]](n) [[&O]] [[OCT$]](n)'''
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7 -- maxed
8 1000 8 10
maxed-- 9 1001 9 11
10 1010 A 12
11 1011 B 13
12 1100 C 14
13 1101 D 15
14 1110 E 16
15 ------------- 1111 <--- Match ---> F ---------------- 17 -- max 2
16 10000 10 20
When the Decimal value is 15, the other 2 base systems are all maxed out!
The Binary values can be compared to all of the HEX value digit values so
it is possible to convert between the two quite easily. To convert a HEX
value to Binary just add the 4 binary digits for each HEX digit place so:
F A C E
&HFACE = 1111 + 1010 + 1100 + 1101 = &B1111101011001101
To convert a Binary value to HEX you just need to divide the number into
sections of four digits starting from the right(LSB) end. If one has less
than 4 digits on the left end you could add the leading zeros like below:
&B101011100010001001 = 0010 1011 1000 1000 1001
hexadecimal = 2 + B + 8 + 8 + 9 = &H2B889
See the Decimal to Binary conversion function that uses '''[[HEX$]]''' on the '''[[&H]]''' page.
{{TextEnd}}
<center>'''[[VAL]] converts [[STRING|string]] numbers to Decimal values.'''</center>
:VAL reads the string from left to right and converts numerical string values, - and . to decimal values until it finds a character other than those 3 characters. Commas are NOT read either! However HEXadecimal and OCTal base values can be read with [[&H]] or [[&O]].
<center>'''The [[OCT$]] [[STRING|string]] function return can be converted to a decimal value using [[VAL]]("&O" + OCT$(n)).'''</center>
<center>'''The [[HEX$]] [[STRING|string]] function return can be converted to a decimal value using [[VAL]]("&H" + HEX$(n)).'''</center>
:[[STR$]] converts numerical values to string characters for [[PRINT]] or variable strings. It also removes the right number PRINT space.
<center>[[#toc|Return to Top]]</center>
==Bits and Bytes==
<center>'''[[_BIT|BITS]]'''</center>
* The '''MSB''' is the most significant(largest) bit value and '''LSB''' is the least significant bit of a binary or register memory address value. The order in which the bits are read determines the binary or decimal byte value. There are two common ways to read a byte:
:* '''"Big-endian"''': MSB is the first bit encountered, decreasing to the LSB as the last bit by position, memory address or time.
:* '''"Little-endian"''': LSB is the first bit encountered, increasing to the MSB as the last bit by position, memory address or time.
{{WhiteStart}}
'''Offset or Position: 0 1 2 3 4 5 6 7 Example: 11110000'''
---------------------------------- --------
'''Big-Endian Bit On Value:''' 128 64 32 16 8 4 2 1 240
'''Little-Endian Bit On Value:''' 1 2 4 8 16 32 64 128 15
{{WhiteEnd}}
::The big-endian method compares exponents of 2 <sup>7</sup> down to 2 <sup>0</sup> while the little-endian method does the opposite.
<center>'''[[_BYTE|BYTES]]'''</center>
* [[INTEGER]] values consist of 2 bytes called the '''HI''' and '''LO''' bytes. Anytime that the number of binary digits is a multiple of 16 (2bytes, 4 bytes, etc.) and the HI byte's MSB is on(1), the value returned will be negative. Even with [[SINGLE]] or [[DOUBLE]] values!
{{WhiteStart}} '''16 BIT INTEGER OR REGISTER'''
'''AH (High Byte Bits) AL (Low Byte Bits)'''
BIT: 15 14 13 12 11 10 9 8 | 7 6 5 4 3 2 1 0
---------------------------------------|--------------------------------------
HEX: 8000 4000 2000 1000 800 400 200 100 | 80 40 20 10 8 4 2 1
|
DEC: -32768 16384 8192 4096 2048 1024 512 256 | 128 64 32 16 8 4 2 1
{{WhiteEnd}}
::The HI byte's '''MSB''' is often called the '''sign''' bit! When the highest bit is on, the signed value returned will be negative.
''Example:'' Program displays the bits on for any integer value between -32768 and 32767 or &H80000 and &H7FFF.
{{CodeStart}} '' ''
{{Cl|DEFINT}} A-Z
{{Cl|SCREEN (statement)|SCREEN}} 12
{{Cl|COLOR}} 11: {{Cl|LOCATE}} 10, 2
{{Cl|PRINT}} " AH (High Register Byte Bits) AL (Low Register Byte Bits)"
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 11, 2
{{Cl|PRINT}} " 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0"
{{Cl|COLOR}} 13: {{Cl|LOCATE}} 14, 2
{{Cl|PRINT}} " {{Cl|&H}}8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 {{Cl|&H}}1"
{{Cl|COLOR}} 11: {{Cl|LOCATE}} 15, 2
{{Cl|PRINT}} "-32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1"
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 16
{{Cl|CIRCLE}} (640 - (37 * i), 189), 8, 9 'place bit circles
{{Cl|NEXT}}
{{Cl|LINE}} (324, 160)-(326, 207), 11, BF 'line splits bytes
{{Cl|DO}}
{{Cl|IF}} Num {{Cl|THEN}}
{{Cl|FOR...NEXT|FOR}} i = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1
{{Cl|IF}} (Num {{Cl|AND}} 2 ^ i) {{Cl|THEN}}
{{Cl|PAINT}} (640 - (37 * (i + 1)), 189), 12, 9
Bin$ = Bin$ + "1"
{{Cl|ELSE}}
{{Cl|PAINT}} (640 - (37 * (i + 1)), 189), 0, 9
Bin$ = Bin$ + "0"
{{Cl|END IF}}
{{Cl|NEXT}}
{{Cl|COLOR}} 10: {{Cl|LOCATE}} 16, 50: {{Cl|PRINT}} "Binary ="; {{Cl|VAL}}(Bin$)
{{Cl|COLOR}} 9: {{Cl|LOCATE}} 16, 10: {{Cl|PRINT}} "Decimal ="; Num;: {{Cl|COLOR}} 13: {{Cl|PRINT}} " Hex = "; Hexa$
Hexa$ = "": Bin$ = ""
{{Cl|END IF}}
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 17, 15: {{Cl|INPUT}} "Enter a decimal or HEX({{Cl|&H}}) value (0 Quits): ", frst$
first = {{Cl|VAL}}(frst$)
{{Cl|IF}} first {{Cl|THEN}}
{{Cl|LOCATE}} 17, 15: {{Cl|PRINT}} {{Cl|SPACE$}}(55)
{{Cl|COLOR}} 13: {{Cl|LOCATE}} 17, 15: {{Cl|INPUT}} "Enter a second value: ", secnd$
second = {{Cl|VAL}}(secnd$)
{{Cl|LOCATE}} 17, 10: {{Cl|PRINT}} {{Cl|SPACE$}}(69)
{{Cl|END IF}}
Num = first + second
Hexa$ = "{{Cl|&H}}" + {{Cl|HEX$}}(Num)
{{Cl|LOOP}} {{Cl|UNTIL}} first = 0 {{Cl|OR (boolean)|OR}} Num > 32767 {{Cl|OR (boolean)|OR}} Num < -32767
{{Cl|COLOR}} 11: {{Cl|LOCATE}} 28, 30: {{Cl|PRINT}} "Press any key to exit!";
{{Cl|SLEEP}}
{{Cl|SYSTEM}} '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
<center>[[#toc|Return to Top]]</center>
==OFFSET==
* [[_OFFSET (function)]] returns the memory offset position as a flexible sized value for a designated variable. See [[Using _OFFSET]].
<center>'''Warning: [[_OFFSET]] values cannot be reassigned to other variable [[TYPE|types]]!'''</center>
<center>'''[[_OFFSET]] values can currently only be used in conjunction with [[_MEM]]ory and [[DECLARE DYNAMIC LIBRARY]] procedures.'''</center>
==References==
''See also:''
* [[_OFFSET]], [[_MEM]]
* [[DIM]], [[_DEFINE]]
* [[TYPE]]
{{PageNavigation}}

View file

@ -6,11 +6,10 @@
::.
::. 'loop code
::.
::NEXT i
::'''NEXT''' [i]
:OR
:: RESUME NEXT
:: RESUME {'''NEXT'''|linenumber|linelabel}
* NEXT is required in a FOR loop or a [[ERROR Codes|"FOR without NEXT" error]] will occur.

View file

@ -8,6 +8,8 @@
* In Qbasic, True = -1 and False = 0 in boolean logic and evaluation statements.
* NOT evaluates ONE value and returns the opposite. Yes, NOT 0 = -1 in Basic.
* Often called a negative logic operator, it returns the opposite of a value as true or false.
* Values are changed by their bit values so that each bit is changed to the opposite of on or off. See example 3.
{{Template:RelationalTable}}
@ -16,8 +18,7 @@
''Example 1:'' Alternating between two conditions in a program loop.
{{CodeStart}}
{{Cl|DO}}
{{CodeStart}}{{Cl|DO}}
switch = {{Cl|NOT}} switch '{{Cl|NOT}} changes value from -1 to 0 and vice-versa
{{Cl|LOCATE}} 10, 38
{{Cl|IF}} switch {{Cl|THEN}} {{Cl|PRINT}} "True!" {{Cl|ELSE}} {{Cl|PRINT}} "False"
@ -28,19 +29,52 @@ k$ = {{Cl|INKEY$}}
''Example 2:'' Reading a file until it reaches the End Of File.
{{CodeStart}}
DO WHILE NOT EOF(1)
{{CodeStart}}DO WHILE NOT EOF(1)
INPUT #1, data1, data2, data3
LOOP '' ''
{{CodeEnd}}
:''Explanation:'' [[EOF]] will return 0 until a file ends. NOT converts 0 to -1 so that the loop continues to run. When EOF becomes -1, NOT converts it to 0 to end the loop.
''See also:''
*[[DO...LOOP]], [[WHILE...WEND]],
*[[IF...THEN]], [[AND]], [[XOR]]
*[[OR]], [[Binary]], [[Boolean]]
*[[Mathematical Operations]]
''Example 3:'' So why does '''NOT 5 = -6'''? Because NOT changes every bit of a value into the opposite:
{{CodeStart}}{{Cl|PRINT}} {{Cl|NOT}} 5
{{Cl|PRINT}}
ReadBits 5
ReadBits -6
{{Cl|SUB}} ReadBits (n {{Cl|AS}} {{Cl|INTEGER}}) 'change type value and i bit reads for other whole type values
{{Cl|FOR...NEXT|FOR}} i = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1 'see the 16 bit values
{{Cl|IF...THEN|IF}} n {{Cl|AND (boolean)|AND}} 2 ^ i {{Cl|THEN}} {{Cl|PRINT}} "1"; {{Cl|ELSE}} {{Cl|PRINT}} "0";
{{Cl|NEXT}}
{{Cl|PRINT}}
{{Cl|END SUB}} '' ''
{{CodeEnd}}
{{OutputStart}}-6
0000000000000101
1111111111111010
{{OutputEnd}}
:''Explanation:'' The bit values of an [[INTEGER]] are 2 [[_BYTE]]s and each bit is an exponent of 2 from 15 to 0 (16 bits). Thus comparing the numerical value with those exponents using [[AND]] reveals the bit values as "1" for bits on or "0" for bits off as text.
: QB64 can use [[&B]] to convert the above [[_BIT]] values back to [[INTEGER]] or [[_BYTE]] values as shown below:
{{CodeStart}}'16 bit INTEGER values from -32768 to 32767
a% = {{Cl|&B}}0000000000000101
{{Cl|PRINT}} a%
b% = {{Cl|&B}}1111111111111010
{{Cl|PRINT}} b%
'8 bit BYTE values from -128 to 127
a%% = {{Cl|&B}}00000101
{{Cl|PRINT}} a%%
b%% = {{Cl|&B}}11111010
{{Cl|PRINT}} b%%
{{CodeEnd}}
''See also:''
* [[_BIT]], [[&B]], [[_BYTE]]
* [[AND]], [[XOR]], [[OR]]
* [[Binary]], [[Boolean]]
* [[Mathematical Operations]]
{{PageNavigation}}

View file

@ -3,10 +3,10 @@
* OFF can be used to turn off the display of soft-key assignments at the bottom of the screen using [[KEY]].
* OFF can also be used to disable an event trapping in the following statements: [[KEY(n)]], [[ON COM (n)|COM(n)]], [[PEN]], [[PLAY]], [[STRIG(n)]], [[TIMER]], [[UEVENT]]. The trap can be turned back [[ON]], but does not retain any events since '''OFF''' was used.
* [[$CHECKING]]:'''OFF''' is used to disable c++ error trapping, make sure that your code is flawless before using this metacommand, '''can cause a General Protection Fault''' if there are errors in the code.
''See also:'' [[ON]], [[STOP]], [[KEY]], [[KEY(n)]]
''See also:'' [[ON]], [[STOP]], [[KEY]], [[KEY(n)]], [[$CHECKING]]

View file

@ -14,7 +14,7 @@ ON...GOTO is a control-flow statement that branches to a line number or label in
{{CodeStart}} '' ''
{{Cl|CLS}}
a = 2
{{Cl|ON GOTO|ON a GOTO}} hello, hereweare, 143
{{Cl|ON...GOTO|ON a GOTO}} hello, hereweare, 143
{{Cl|END}}
hello:
{{Cl|PRINT}} "you don't get to see this!"

View file

@ -62,7 +62,7 @@ hand:
''See also:''
* [[ERR]], [[ERL]], [[RESUME]]
* [[ON...GOTO]], [[_ERRORLINE]]
* [[ERROR]]
* [[ERROR]] {{text|(simulates an error)}}
* [[ERROR Codes]]

View file

@ -1,25 +1,43 @@
The '''OPEN''' statement is used to open a file or [[OPEN_COM|COM]] serial communications port.
The '''OPEN''' statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output.
''Qbasic:'' {{PageSyntax}}
::'''OPEN''' ''FileName$'' ['''FOR''' mode] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] '''AS''' [#]''FileNumber%'' [LEN = ''recordLEN'']
::'''OPEN''' ''FileName$'' ['''FOR''' mode] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] '''AS''' [#]''FileNumber&'' [LEN = ''recordLEN'']
* ''FileName$'' is a [[STRING]] variable or literal file name inside of quotes.
* '''QB64''' ''filenames'' can be up to 255(Windows) characters with no limit on extension length.
* ''File number'' can be any [[INTEGER]] value from 1 to 255 or an unused value determined by [[FREEFILE]].
* [[LEN]] = is optional. Sequencial files default to 512 and [[RANDOM]] to 128 bytes. Statement ignored in [[BINARY]] mode.
''GW Basic'' {{PageSyntax}}
::'''OPEN''' ''modeletter$'', [#]''filenumber'', ''filename$''[, ''recordLEN'']
''Parameters:''
* The ''fileName$'' is a [[STRING]] variable or literal file name (path optional) in quotes.
* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write), .
* GW Basic's ''modeletter'' is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above.
* ''File number'' can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* [[LEN]] = or ''recordLEN'' is optional to denote the RANDOM(128 default) file record byte lengths or sequential(512 default) load buffer.
{{PageDescription}}
* '''QB64''' can open as many files as your computer memory can handle. Qbasic could only open about 15 at a time.
* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.'''
* The ''mode'' defaults to RANDOM if the ''mode'' or FOR access statement is omitted. (see open modes described below)
* '''Only the ''filename'', ''file number'' and LEN = ''record length'' values can use variable values in the Qbasic OPEN syntax.'''
* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic.
* '''QB64''' ''filenames'' can be up to 255(Windows) characters with no limit on file name extension length.
* Once a file or port is opened, it can be used in any program procedure using the assigned file number.
* Illegal Qbasic filename characters are ''' " * / \ + | ? [ ] , ; : < > ''' and more than one dot(period).
* Illegal '''QB64''' filename characters are ''' " * / \ | ? : < > '''. Multiple dots(periods) are allowed, but only the first one will be used.
* Qbasic ''filenames'' must not exceed 12 characters(including dot) with a maximum of 3 file type extension characters using the DOS 8.3 naming convention limits.
* The '''"SCRN:"''' device is now supported in all new GL versions after April 15, 2015(see Example 3).
* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|currently NOT supported in QB64!]]'''.
: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system.
* [[OPEN COM]] can also be used for serial port access in '''QB64'''.
{{PageErrors}}
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots(periods) are allowed, but only the first one will be set.
* Illegal Qbasic Windows filename characters are ''' " * / \ + | ? [ ] , ; : < > ''' and more than one dot(period).
* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found".
* '''Devices such as "KYBD:", "SCRN:", "CONS:" and "LPTn:" are [[Keywords currently not supported by QB64|currently NOT supported in QB64!]]'''.
: '''Note:''' OPEN LPTn is not supported by QB64, but may be supported directly by your operating system.
* [[OPEN COM]] is implemented for serial port access!
::: An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name!
* Qbasic ''filenames'' must not exceed 12 characters(including dot) with a maximum of 3 file type extension characters using the DOS 8.3 naming convention limits. '''QB64''' does not have those file name limitations.
<center> ''' File ACCESS and LOCK Permissions'''</center>
@ -30,33 +48,35 @@ The '''OPEN''' statement is used to open a file or [[OPEN_COM|COM]] serial commu
* ''Note:'' '''Qbasic''' ACCESS and LOCK clauses required that the DOS '''SHARED.EXE''' program be run for networking access.
<center>'''Qbasic File Modes:''' Open can use 5 different access modes:</center>
<center>'''The 5 Qbasic File Access Modes:'''</center>
* [[OUTPUT]]: Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or the [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]].
* [[APPEND]]: Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or the [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.'''
* [[INPUT (file mode)|INPUT]] : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist!''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.'''
* [[BINARY]]: Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode only.
* [[RANDOM]]: Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes)
* [[OUTPUT]]: Sequencial mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or the [[PRINT (file statement)|PRINT #]] for text. OUTPUT clears files of all data and clears the receive buffer on other devices such as [[ON COM(n)|COM]].
* [[APPEND]]: Sequencial mode creates a new file if it doesn't exist or appends program output to an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or the [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. APPEND does not remove previous data.
* [[BINARY]]: Creates a new file when it doesn't exist or uses input and/or output from an existing file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write simultaneously. [[LEN]] = statements are ignored in this mode only.
* [[RANDOM]]: Creates a new file when it doesn't exist or uses input and/or output from an existing file. Use [[GET|GET #]] or [[PUT|PUT #]] the same as BINARY mode. A [[LEN]] = statement can define the byte size of a record(defaut = 128).
* [[INPUT (file mode)|INPUT]] : Sequencial mode only reads input from an existing file. [[ERROR Codes|File error]] if file does not exist! Use [[_FILEEXISTS]] and [[_DIREXISTS]] to avoid errors. Use [[INPUT (file statement)|INPUT #]] for numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data.
* The [[INPUT (file mode)|INPUT]], [[BINARY]] and [[RANDOM]] file modes allow a file to be concurrently opened in a different mode and number.
<center>'''GW Basic OPEN statements'''</center>
:''GW Basic'' {{PageSyntax}}
::'''OPEN''' ''modeletter$'', [#]''filenumber'', ''filename$''[, ''recordLEN'']
:* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following:
:::::::::* "O" denotes OUTPUT mode as defined above.
:::::::::* "A" denotes APPEND mode as defined above.
:::::::::* "B" denotes BINARY mode as defined above.
:::::::::* "R" denotes RANDOM mode as defined above.
:::::::::* "I" denotes INPUT mode as defined above.
::* "A" [[APPEND]] sequential mode allows data to be appended to an existing file using [[PRINT (file statement)|PRINT]] or [[WRITE (file statement)|WRITE]].
::* "B" [[BINARY]] byte mode allows data to be read or written using [[GET]] or [[PUT]]
::* "I" [[INPUT (file mode)|INPUT]] sequential mode allows data to be read using [[INPUT (file statement)|INPUT]] or [[LINE INPUT (file statement)|LINE INPUT]] in '''existing''' files only.
::* "O" [[OUTPUT]] sequential mode creates or clears a file to write new data using [[PRINT (file statement)|PRINT]] or [[WRITE (file statement)|WRITE]].
::* "R" [[RANDOM]] record mode allows [[TYPE]] or [[FIELD]] records to be read or written using [[GET]] or [[PUT]].
:* ''File number'' can be any variable or literal [[INTEGER]] value between 1 and 255 or a [[FREEFILE]] value.
:* ''File name'' can be a variable or literal [[STRING]] file name value.
:* ''Record LENgth'' can be a variable or literal [[INTEGER]] value used in "R" mode only. Use multiples of 128 only.
:* ''File name'' can be a variable or literal [[STRING]] file name value or port or device.
:* The '''"SCRN:"''' device is now supported in all new GL versions after April 15, 2015: {{text|'''OPEN "O", #1, "SCRN:"'''|green}}
:* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" as file names are [[Keywords currently not supported by QB64|currently NOT supported in QB64!]]'''.
:: '''Note:''' OPEN "O", #1, "LPTn" is not supported by QB64, but may be supported directly by your operating system.
:* ''RecordLEN'' can be a variable or literal [[INTEGER]] value used in "R" mode only.
:* This type of OPEN allows the statement to be made using program variables only. A holdover for compatibility with GW Basic.
:* '''Note:''' Does not support any file [[ACCESS]] or [[LOCK]] restrictions.
@ -76,31 +96,31 @@ The '''OPEN''' statement is used to open a file or [[OPEN_COM|COM]] serial commu
{{CodeStart}}
file$ = "Hello,~1.mp3" 'example call below
LOCATE 20, 30: errors% = CheckName%(file$): COLOR 14: PRINT " Total Errors ="; errors%
{{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors%
{{Cl|FUNCTION}} CheckName% (Filename$)
'NOTE: Function also displays filename errors so LOCATE on screen before call!
{{Cl|DIM}} L AS INTEGER, DP AS INTEGER, XL AS {{Cl|INTEGER}}
L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): IF DP THEN XL = L - DP 'extension
IF L = 0 OR L > 12 OR DP > 9 OR XL > 3 THEN
CheckName% = -1: COLOR 12: PRINT "Illegal format!"; : EXIT FUNCTION
END IF
FOR i% = 1 TO L 'check each filename character"
code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): COLOR 10 ' see {{Cl|ASCII}} codes
'{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call!
{{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}}
L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension
{{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}}
CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}}
{{Cl|END IF}}
{{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character"
code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes
{{Cl|SELECT CASE}} code% 'check for errors and highlight in red
CASE 34, 42 TO 44, 47, 58 TO 63, 91 TO 93, 124: E% = E% + 1: COLOR 12 ' Qbasic errors
'CASE 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: COLOR 12 ' '''QB64''' errors
CASE 46: dot% = dot% + 1: IF dot% > 1 THEN E% = E% + 1: COLOR 12
{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''Qbasic errors'''
'{{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors'''
{{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12
{{Cl|END SELECT}}
PRINT {{Cl|CHR$}}(code%); 'use LOCATE before FUNCTION call to place print
NEXT
{{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print
{{Cl|NEXT}}
CheckName% = E%
END FUNCTION
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
''Note: The QB64 character list is commented out. Comment out the Qbasic one if using QB64 list.
''Note: The QB64 character error list is commented out. Comment out the Qbasic one when using the QB64 list.
{{OutputStart}}
Hello,~1.mp3 Total Errors = 1
{{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}}<nowiki> = </nowiki>{{text|1|yellow}}
{{OutputEnd}}
:''Note:'' The screen output displays filename characters in green except for red comma Qbasic error.
@ -123,20 +143,35 @@ f% = {{Cl|FREEFILE}}
{{small|Code by Ted Weissgerber}}
''Example 3:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file:
{{CodeStart}} '' ''
f% = {{Cl|FREEFILE}} 'should always be 1 at program start
{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f%
g% = {{Cl|FREEFILE}} 'should always be 2 after 1
{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g%
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version"
NEXT '' ''
{{CodeEnd}}{{small|GL implementation by Steve McNeill April 15, 2015}}
: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name.
* '''QB64''' can use the [[_OPENCLIENT]], [[_OPENHOST]] or [[_OPENCONNECTION]] functions for TCP/IP internet connections.
''See also:''
* [[OPEN COM]]
* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]]
* [[PRINT (file statement)]], [[INPUT (file statement)]]
* [[GET]], [[PUT]], [[INPUT$]], [[SEEK (statement)]], [[SEEK]]
* [[LEN]], [[RESET]]
* [[GET]], [[PUT]], [[WRITE (file statement)]]
* [[INPUT$]], [[LINE INPUT (file statement)]]
* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]]
* [[SEEK (statement)]], [[SEEK]]
* [[OPEN COM]], [[LEN]], [[RESET]]
* [[FILEATTR]], [[FIELD]], [[TYPE]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}}
* [[_SNDOPEN]], [[_LOADIMAGE]]
* [[Port Access Libraries]] {{text|(COM or LPT registers)}}

View file

@ -3,16 +3,32 @@ The '''OPEN COM''' statement is used to access a computer's Serial port COM1 or
{{PageSyntax}}
: [[OPEN]] "COMn: ''Speed'', ''Parity'', ''Bits'', ''Stopbit'', ['''Options''']" [FOR mode] AS #''P'' [LEN = ''bytesize'']
: '''OPEN "COMn:''' ''Speed'', ''Parity'', ''Bits'', ''Stopbit'', [''Options'']" [FOR {[[RANDOM]]|[[BINARY]]|[[OUTPUT]]|[[INPUT (file mode)|INPUT]]}] AS #''P'' [LEN = ''bytesize'']
* '''QB64''' can open any [[COM(n)|COM''n'']] port number. Qbasic could only open COM1 or COM2, but 3 and 4 could be swapped.
* See Windows System '''Device Manager''' for COM port numbers and port addresses &H3F8, &H2F8, &H3E8 and &H2E8.
* Four commas are required after the Speed, Parity, Bits, and Stopbit, even if none of the Options are used.
* ''Speed''(baud rate): 50, 150, 300, 600, 1200, 1800, 2400, '''9600'''(QB max), 19200 or '''115200'''('''QB64''' max) maximum.
{{Parameters}}
* ''Speed'' (baud rate): 50, 150, 300, 600, 1200, 1800, 2400, '''9600''' (QB max), 19200 or '''115200''' ('''QB64''' max) maximum.
* ''Parity'': '''N''' (none), E (even), O (odd), S (space) or M (mark). Note: If 8 bits use parity N for numerical data!
* ''Bits'' = number of bits/byte: Valid numbers: 5, 6, 7 or '''8'''
* ''Stopbit'' = number of stop bits: Valid numbers: '''1''', 1.5 or 2
* Optional COM port ''Options'' (separated by commas):
::* ASC : [[ASCII]] byte mode. End of line = [[CHR$]](13). End of file = CHR$(26)
::* BIN : [[Binary]] byte mode. Default mode if ASC is not used(option not required).
:: ''Below ms is the timeout in milliseconds 1 to 65535. Zero ignores a timeout. Default without ms = 1000 :''
::* CD[ms] : Time until timeout of DCD (Carrier Detect) line in. CD0 ignores timeouts.
::* CS[ms] : Time until timeout of CTS (Clear to Send) line in. CS0 ignores timeouts.
::* DS[ms] : Time until timeout of DSR (Data Set Ready) line in. DS0 ignores timeouts.
::* OP[ms] : Time until data lines become active. If timeout then OPEN fails! OP0 ignores timeouts.
::* RB[b] : Size of receive buffer in bytes when used. Default when not used = 512 bytes
::* TB[b] : Size of transmit buffer in bytes when used. Default when not used = 512 bytes
::* RS : Supress detection of Request to Send (RTS) line.
{{PageDescription}}
* '''If any optional CD, CS, DS or OP timeouts occur the OPEN will fail or port access will stop! Try 0 to ignore.'''
* '''QB64''' can open any [[COM(n)|COM''n'']] port number. Qbasic could only open COM1 or COM2, but 3 and 4 could be swapped.
* See Windows System '''Device Manager''' for COM port numbers and port addresses &H3F8, &H2F8, &H3E8 and &H2E8.
* Four commas are required after the Speed, Parity, Bits, and Stopbit, even if none of the Options are used.
* Other [[OPEN]] ''options'' are optional and in any order separated by commas within the OPEN command [[STRING|string]].(See list below)
* The optional FOR access ''mode'' can be [[OUTPUT]], [[INPUT (file mode)|INPUT]] or [[RANDOM]] (default mode when no FOR statement is used).
* '''Currently, QB64 only supports [[OPEN]] FOR [[RANDOM]] access using the [[GET]]/[[PUT]] commands in [[BINARY|BIN]] mode!'''
@ -23,21 +39,6 @@ The '''OPEN COM''' statement is used to access a computer's Serial port COM1 or
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]
<center>'''Additional COM port Options (separated by commas)'''</center>
::* ASC : [[ASCII]] byte mode. End of line = [[CHR$]](13). End of file = CHR$(26)
::* BIN : [[Binary]] byte mode. Default mode if ASC is not used(option not required).
:: ''Below m is the timeout in milliseconds 1 to 65535. Zero ignores a timeout. Default m = 1000 :''
::* CD[m] : Time until timeout of DCD (Carrier Detect) line in. CD0 ignores timeouts.
::* CS[m] : Time until timeout of CTS (Clear to Send) line in. CS0 ignores timeouts.
::* DS[m] : Time until timeout of DSR (Data Set Ready) line in. DS0 ignores timeouts.
::* OP[m] : Time until data lines become active. If timeout then OPEN fails! OP0 ignores timeouts.
:::: '''If any timeouts occur the OPEN will fail or port access will stop!'''
::* RB[b] : Size of receive buffer in bytes when used. Default when not used = 512 bytes
::* TB[b] : Size of transmit buffer in bytes when used. Default when not used = 512 bytes
::* RS : Supress detection of Request to Send (RTS) line.
<center>'''Qbasic Description NOT Currently supported in QB64!'''</center>
*[[INPUT (file mode)|INPUT]] mode can use [[INPUT (file statement)|INPUT #]] or [[INPUT$]]. [[OUTPUT]] mode can use [[PRINT (file statement)|PRINT #]] or [[PRINT USING (file statement)|PRINT #, USING]].
*[[RANDOM]] or [[BINARY|BIN]] modes can use [[INPUT (file statement)|INPUT #]], [[INPUT$]], [[PRINT (file statement)|PRINT #]], [[GET]] or [[PUT]]. BIN cannot set a buffer size!
@ -91,11 +92,44 @@ errnum = {{Cl|ERR}}
{{CodeEnd}}
''See also:''
''Example 3:'' Sending string data from one COM port to another requires predefined length strings:
{{CodeStart}} '' ''
{{Cl|DIM}} {{Cl|SHARED}} ByteIn {{Cl|AS}} {{Cl|STRING}} * 1 'One byte transfers
{{Cl|DIM}} {{Cl|SHARED}} Byte4 {{Cl|AS}} {{Cl|STRING}} * 4 'Four byte transfers
Byte4 = {{Cl|CHR$}}(254) + {{Cl|CHR$}}(175) + {{Cl|CHR$}}(0) + {{Cl|CHR$}}(3) 'Command code to query all 4 banks of switch input board.
{{Cl|OPEN}} "COM1:115200,N,8,1,BIN,CS0,DS0" {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 'Open port used to send commands.
{{Cl|OPEN}} "COM2:115200,N,8,1,BIN,CS0,DS0" {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #2 'Open port used to receive commands.
{{Cl|PUT}} #1, , Byte4 'Send the 4 byte command.
Start# = {{Cl|TIMER}}
{{Cl|DO...LOOP|DO}} {{Cl|UNTIL}} {{Cl|LOC}}(2) <> 0 'Check if there is data received at com2
{{Cl|IF...THEN|IF}} {{Cl|TIMER}} - Start# > .5 {{Cl|THEN}} {{Cl|EXIT DO}} 'Exit loop if no data arrives within .5 seconds.
{{Cl|LOOP}}
{{Cl|IF...THEN|IF}} {{Cl|LOC}}(2) = 0 {{Cl|THEN}} 'If no data was received.....
{{Cl|PRINT}} "No data received from COM port."
{{Cl|END}}
{{Cl|END IF}}
{{Cl|PRINT}} "Received from COM2:";
{{Cl|DO...LOOP|DO}} {{Cl|UNTIL}} {{Cl|LOC}}(2) = 0 'Read data from COM2 until there is no more data.
{{Cl|GET}} #2, , ByteIn
{{Cl|PRINT}} {{Cl|ASC}}(ByteIn);
{{Cl|LOOP}}
{{Cl|END}} '' ''
{{CodeEnd}}{{small|Code courtesy of Hydrofoiler}}
''See also:''
* [[BINARY]], [[RANDOM]]
* [[INPUT$]], [[PRINT (file statement)|PRINT #]]
* [[LOC]], [[INKEY$]], [[OPEN]]
* [[GET|GET #]], [[PUT|PUT #]]
* [[Port Access Libraries]] {{text|(COM or LPT)}}
* [[Port Access Libraries]] {{text|(Includes full LPT and COM port descriptions with downloadable DLL library)}}
* [[Windows_Libraries#Windows_Ports|Enumerating Windows Ports]]

View file

@ -1,10 +1,15 @@
The '''OR''' coditional operator adds an alternative in a [[IF...THEN]] or [[Boolean]] statement.
{{PageSyntax}}
:: IF a = 1 '''OR''' a = 2 THEN a = 0
* OR adds an alternative to another conditional evaluation. IF True then the statement evaluation is True.
* Parenthesis may be used to clarify an evaluation.
* Can be confused with the [[OR]] numerical operator.
* Parenthesis may be used to clarify the order of comparisons in an evaluation.
* [[AND]] and '''OR''' cannot be used to combine command line operations.
* '''A double OR syntax error may be ignored and create a QB64 compiler error!'''
* Not to be confused with the [[AND]] and [[OR]] numerical operations.
{{Template:RelationalTable}}
@ -23,9 +28,9 @@ True
: ''Explanation:'' The first evaluation was False, but the OR evaluation made the statement true and the code was executed.
''See also:''
* [[AND (boolean)]]
* [[AND (boolean)]], [[XOR (boolean)]]
* [[IF...THEN]]
{{PageNavigation}}

View file

@ -1,26 +1,36 @@
'''OUT''' writes values to register or port hardware addresses. '''QB64 currently has limited access to registers!'''
'''OUT''' writes values to register and port hardware addresses. '''QB64 currently has limited access to registers!'''
{{PageSyntax}}
:: OUT address%, value%
:: '''OUT''' ''register_address%''''',''' ''value%''
* The ''address'' is an integer value expressed as decimal or Hexadecimal.
* '''WARNING!''' Be sure that the address is useable. OUT accesses directly unlike [[POKE]] and can cause permanent PC damage!
* Values sent are normally only 0 to 255 per one byte register(8 bits) address.
{{Parameters}}
* The ''register address'' is a value expressed as a decimal [[INTEGER]] or [[&H|Hexadecimal]].
* The [[INTEGER]] ''value'' sent is normally only 0 to 255 per one byte register(8 bit) address.
{{PageDescription}}
* OUT can be used to change color port and a limited number of other port settings in QB64.
* Some settings may be set in a specific order to gain access to settings and [[INP]] reads.
* [[SCREEN]] modes determine the number of available color palette attributes from 2 to 256 in SCREEN 13.
* Windows NT may block access to Parallel printer and Serial ports! See [[Port Access Libraries]] or other DLL's.
* '''WARNING!''' Be sure that the address is useable. OUT accesses directly unlike [[POKE]] and '''can cause PC damage!'''
* [[_PALETTECOLOR]] can also be used to set RGB intensity values using [[_RGB32|32 bit color]] values.
:::::::'''Color Port access using OUT'''
:::::::'''Color Port Palette access using OUT'''
:::::OUT &H3C7, attribute : Set port to read RGB settings
:::::OUT &H3C8, attribute : Set port to write RGB settings
:::::OUT &H3C9, color_intensity : Writes settings
:::::[[INP]] &H3C9, color_intensity : Reads settings
::::* Every 3 reads or writes, changes to next color attribute
::::* Color setting is Red, Green and Blue intensities in order
::::* Color attribute intensity values range from 0 to 63 only
:::::OUT &H3C7, attribute : Set port to read RGB settings for start attribute
:::::[[INP]] &H3C9, color_intensity : Reads RGB color intensity settings in order
:::::OUT &H3C8, attribute : Set port to write RGB settings for start attribute
:::::OUT &H3C9, color_intensity : Writes RGB color intensity settings in order
::::* Every 3 reads or writes, changes to next color attribute without a set
::::* Color setting is Red, Green and Blue attribute intensities in order.
::::* Color attribute intensity values range from 0 to 63 only. NOT 64!
::::* Some [[DAC]] color attribute intensities cannot be changed using OUT.
@ -40,7 +50,7 @@ PRINT red%, green%, blue% '' ''
''Example 2:'' Changing the color intensity settings of the [[SCREEN]] background [[COLOR]] 0 to bright white.
{{CodeStart}} '' ''
{{Cl|OUT}} &H3C8, 0
{{Cl|OUT}} &H3C8, 0 'attribute number. 0 for black screen background
{{Cl|OUT}} &H3C9, 63 'red
{{Cl|OUT}} &H3C9, 63 'green
{{Cl|OUT}} &H3C9, 63 'blue '' ''
@ -62,10 +72,12 @@ PRINT red%, green%, blue% '' ''
''See also:''
* [[INP]] {{text|(read register)}}, [[POKE]] {{text|(write to memory)}}
* [[PALETTE]], [[COLOR]], [[SCREEN]]
* [[PALETTE]], [[_PALETTECOLOR]]
* [[INP]] {{text|(read register)}}
* [[PEEK]] {{text|(read memory)}}
* [[POKE]] {{text|(write to memory)}}
* [[COLOR]], [[SCREEN]]
* [[BSAVE]], [[BLOAD]]
* [[_PALETTECOLOR]]
* [[Port Access Libraries]] {{text|(COM or LPT registers)}}
* [http://en.wikipedia.org/wiki/Input/output_base_address#Common_I.2FO_base_address_device_assignments_in_IBM_PC_compatible_computers PC I/O base address device assignments]

View file

@ -1,20 +1,22 @@
The '''PAINT''' statement is used to color enclosed graphic objects with a designated fill color and border {{KW|COLOR}}.
The '''PAINT''' statement is used to color enclosed graphic objects with a designated fill color up to a border [[COLOR]].
{{PageSyntax}}
: '''PAINT''' [{{KW|STEP}}] '''(''column%'', ''row%''), ''fillcolor%'''''[, ''bordercolor%''][,''background$'']
: '''PAINT''' [{{KW|STEP}}] '''(''column%'', ''row%''), ''fillcolor'''''[, ''bordercolor%''][,''background$'']
{{Parameters}}
* Can use the [[STEP]] keyword for relative coordinate placements. [[STEP]](0, 0) can be used after [[CIRCLE]] to fill it with color.
* Graphic ''column'' and ''row'' [[INTEGER]] pixel coordinates should be inside of a fully enclosed border.
* [[INTEGER]] or [[LONG]] 32 bit ''Fillcolor'' is the color to paint the inside of an object. Colors limited to SCREEN mode used.
* The ''fillcolor'' can be either a numerical or a [[STRING|string]] value:
:* [[INTEGER]] or [[LONG]] 32 bit ''Fillcolor'' is the color to paint the inside of an object. Colors limited to [[SCREEN]] mode used.
:* A [[STRING]] paint argument has PAINT do "tiling," a process that paints a pattern rather than a solid color.
* Optional [[INTEGER]] or [[LONG]] 32 bit ''border color'' is the color of the enclosed shape's border when different from the fill color.
* Optional ''background'' [[ASCII]] character sets the tiling style. Default = CHR$(0). Seldom used.
''Usage:''
* The enclosed border color must be one color value only. The object border must be fully enclosed!
* The enclosed border color must be one color value only. The object border should be fully enclosed!
* PAINT coordinates MUST be inside of a closed shape to be colored. Paint will not do anything when placed on the border color.
* If the border color does not enclose the area, PAINT may flood the screen or go beyond the border area.
* If the shape is not totally enclosed, every color except the border color may be painted over.
@ -77,7 +79,7 @@ drw$ = "C15S20R9D4R6U3R3D3R7U5H3U2R9D3G2D6F1D3F5L10D1G1L4H2L7G2L3H2L3U8L2U5
{{PageSeeAlso}}
* [[PSET]], [[PRESET]]
* [[CIRCLE]], [[LINE]], [[DRAW]]
* [[SCREEN (statement)]], [[CHR$]]
* [[SCREEN]], [[CHR$]]
{{PageNavigation}}

View file

@ -0,0 +1,31 @@
The '''PALETTE USING''' statement sets all RGB screen color intensities using values from an [[Arrays|array]].
{{PageSyntax}}
:: PALETTE USING Array%(''start_index%'')
* The [[Arrays|Array]] holds the RGB color value using the color value = red + 256 * green + 65536 * blue.
* The ''start_index'' indicates the index that the statement should start reading. The statement will read all color attributes available in that [[SCREEN (statement)|SCREEN]] mode. The '''number of values required''' in the array is listed below:
{{WhiteStart}}''' Screen mode Attributes Colors Values'''
0 0 - 15 0 - 63 16
1 0 - 3 0 - 3 4
2 0 - 1 0 - 1 2
7 0 - 15 0 - 15 16
8 0 - 15 0 - 15 16
9 0 - 15 0 - 63 16
10 0 - 3 0 - 8 4
11 0 - 1 0 - 1 2
12 0 - 15 0 - 262,143 16
13 0 - 15 0 - 263,143 256
{{WhiteEnd}}
* A color argument of -1 in the array leaves the attribute unchanged. Other negative numbers are invalid!
''See also:''
* [[PALETTE]], [[COLOR]]
* [[SCREEN (statement)]]
{{PageNavigation}}

View file

@ -31,8 +31,8 @@
''Usage:''
* MB will allow music to play while program code progresses. MF will wait for code to continue playing notes.
* Command string values are not case sensitive. Use upper or lower case as desired.
*'''NOTE: PLAY may NOT delay program progress! Use [[_DELAY]] and [[END]] to allow music completion.'''
* Command string values are not case sensitive and spacing is ignored. Use upper or lower case as desired.
*'''NOTE: In QB64, PLAY may NOT delay program progress! Use [[_DELAY]] and [[END]] to allow music completion.'''
''Example 1:'' Plays a sound with the volume and note varying from 0 to 50. Maximum note can only be 84.
@ -290,6 +290,41 @@ glocate gposyp + 1, 1 'gposyp = gposyp + 1
{{CodeEnd}}{{small|Code by Mennonite}}
''Example 5:'' This example uses [[PRINT]] to good effect as string spacing is ignored by PLAY:
{{CodeStart}} '' ''
{{Cl|WIDTH}} 59, 28
{{Cl|PRINT}} <nowiki>
x$ = x$ + " o3 l4 t 0120c ml<f1 ,a 1, "
x$ = x$ + " >c 1, mnf .e 8f am l< e1 ,g "
x$ = x$ + " 1, >c 1, mn g. f8 ga 8g 8m l< "
x$ = x$ + " f2.,a2., >c 2. ,m nf .f 8a ml<f "
x$ = x$ + " ,a,>c,mn >cd2.,<f2 .,d2 .,<b -2 "
x$ = x$ + " .m lb -,>d,f,mn>d ml <c 1, "
x$ = x$ + " <a 1, f1 ,m n> >c .< "
x$ = x$ + " a8 af ml c1 ,< e1 ,g "
x$ = x$ + " "
x$ = x$ + " 1,m n> g.f8ga8g8m l< f1 "
x$ = x$ + " ,d1, <b -1 ,m n> "
x$ = x$ + " >f .d 8d c< f2 ., "
x$ = x$ + " a2 ., c2 .,>f2. ml < b- "
x$ = x$ + " ,> d, f, mn>dml <c 1,< a1 "
x$ = x$ + " ,f 1, mn >> c. <a 8a fm "
x$ = x$ + " lc 2.,< e2 .,g2 .,mn "
x$ = x$ + " >g .f8 gml<b-,>d, f, mn "
x$ = x$ + " "
x$ = x$ + ">d ml <<f2.,a2., > c2.,m n> c."
x$ = x$ + " <a 8a ml <e, g, >c ,m n>"
x$ = x$ + " cm l< <b -2 ., >d 2. ,f 2."
x$ = x$ + " ,mn> d2.ml< <b -, >d ,f ,m n>"
x$ = x$ + " dm l<<f1, a1,>c1,mn >c.<a 8a fm"
x$ = x$ + " lc 1, <e1,g1,mn>g .f 8g a8 g8"
x$ = x$ + " ml << b- 1, >d 1, "
x$ = x$ + " f1 ,mn>f.d8dc l1 ml f, c, <a ,f"</nowiki>
{{Cl|PRINT}} x$;
{{Cl|PLAY}} x '' ''
{{CodeEnd}}{{small|Code by Johnny B}}
''See also:'''
* [[PLAY(n)]], [[ON PLAY(n)]]
* [[SOUND]], [[DRAW]]

View file

@ -1,31 +1,50 @@
The '''POINT''' function returns the pixel [[COLOR]] attribute at a specified graphics coordinate or the current graphic cursor position.
''Color'' {{PageSyntax}} color_attribute% = POINT (''column%'', ''row%'')
''Position'' {{PageSyntax}} pointer_coordinate% = POINT({0|1|2|3})
''Color'' {{PageSyntax}}
::::color_attribute% = '''POINT ('''''column%, row%''''')'''
:'''POINT in Qbasic Legacy SCREEN modes:'''
''Graphic cursor position'' {{PageSyntax}}
::::pointer_coordinate% = '''POINT('''{0|1|2|3}''')'''
{{Parameters}}
Graphic Color syntax:
* The [[INTEGER]] ''column'' and ''row'' coordinates designate the pixel position color on the screen to read.
* The return value is an [[INTEGER]] palette attribute value or an [[_UNSIGNED]] [[LONG]] [[_RGBA]] 32 bit value in QB64.
Graphic cursor position syntax:
* The [[INTEGER]] position number can be 0 to 3 depending on the cursor position desired:
** POINT(0) returns the current graphic cursor [[SCREEN]] column pixel coordinate.
** POINT(1) returns the current graphic cursor [[SCREEN]] row pixel coordinate.
** POINT(2) returns the current graphic cursor [[WINDOW]] column position.
** POINT(3) returns the current graphic cursor [[WINDOW]] row position.
* If a [[WINDOW]] view port has not been established, the coordinate returned will be the [[SCREEN]] cursor pixel position.
* The return value is the current graphic cursor ''column'' or ''row'' pixel position on the [[SCREEN]] or [[WINDOW]].
* Graphic cursor positions returned will be the last ones used in a graphic shape such as a [[CIRCLE]] center point.
''Usage:''
* Use '''[[_SOURCE]]''' first to set the image handle that POINT should read or QB64 will assume the current source image.
:: '''{{text|_SOURCE 0|green}}''' 'sets POINT to read the current SCREEN image after reading a previous source image
* '''POINT cannot be used in SCREEN 0!''' Use the [[SCREEN (function)|SCREEN]] function to point text character codes and colors in SCREEN 0.
<center>'''POINT in Qbasic Legacy Graphic SCREEN Modes:'''</center>
* The [[INTEGER]] color attributes returned are limited by the number of colors in the legacy SCREEN mode used.
* ''Column'' and ''row'' [[INTEGER]] parameters denote the graphic pixel coordinate to read.
* Use the [[SCREEN (function)|SCREEN]] function to point text character codes and colors in SCREEN 0.
* In Qbasic the coordinates MUST be on the screen or an [[ERROR Codes|Illegal Function Call error]] will occur.
* In '''QB64''' the offscreen or off image value returned is -1. Use IF POINT(x, y) <> -1 THEN...
* In Qbasic the coordinates MUST be on the screen or an [[ERROR Codes|Illegal Function Call error]] will occur.
:'''POINT Cursor Coordinate Position:'''
* When one [[INTEGER]] value parameter is used, the current graphic cursor position is returned.
** 0 returns the current graphic cursor [[SCREEN]] column coordinate.
** 1 returns the current graphic cursor [[SCREEN]] row coordinate.
** 2 returns the current graphic cursor [[WINDOW]] column position.
** 3 returns the current graphic cursor [[WINDOW]] row position.
* If a [[WINDOW]] view port has not been established, the coordinate returned will be the [[SCREEN]] position.
:'''POINT in QB64 32 Bit [[_NEWIMAGE]] SCREEN Modes:'''
<center>'''POINT in QB64 32 Bit Graphic [[_NEWIMAGE]] or [[_LOADIMAGE]] Modes:'''</center>
* Returns [[_UNSIGNED]] [[LONG]] 32 bit color values. Use [[_UNSIGNED]] values when you don't want negative values.
* '''[[LONG]] unsigned variables can be used when comparing POINT returns with [[_RGB]].(QB64 V .937 up)'''
* '''[[_UNSIGNED]] [[LONG]] variables should be used when comparing POINT returns with [[_RGB]] or [[_RGB32]] [[_ALPHA]] bit values'''
* Convert 32 bit color values to RGB intensities(0 to 255) using the [[_RED32]], [[_GREEN32]] and [[_BLUE32]] functions.
* To convert color intensities to OUT &H3C9 color port palette intensity values divide the values of 0 to 255 by 4.
* Use the [[_PALETTECOLOR (function)]] to convert color port palette intensities in 32 bit modes.
@ -56,29 +75,29 @@ _RGB OK
''Example 2:'' Using a POINT mouse routine to get the 32 bit color values of the QB64 Bee. [http://www.qb64.net/forum/index.php Download image from top of Forum].
{{CodeStart}} '' ''
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
{{Cl|_TITLE}} "Mouse POINTer 32"
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} xoffset&, {{Cl|BYVAL}} yoffset&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|_TITLE}} "Mouse {{Cl|POINT}}er 32"
'{{Cl|LINE INPUT}} "Enter an image file: ", image$ 'use quotes around file names with spaces
image$ = "QB64.png" 'up to 320 X 240 with current _PUTIMAGE settings
'{{Cl|LINE INPUT}} "Enter an image file: ", image$ 'use quotes around file names with spaces
image$ = "QB64bee.png" 'up to 320 X 240 with current {{Cl|_PUTIMAGE}} settings
i& = {{Cl|_LOADIMAGE}}(image$, 32)
{{Cl|IF...THEN|IF}} i& >= -1 {{Cl|THEN}} {{Cl|BEEP}}: {{Cl|PRINT}} "Could NOT load image!": {{Cl|END}}
{{Cl|IF...THEN|IF}} i& >= -1 {{Cl|THEN}} {{Cl|BEEP}}: {{Cl|PRINT}} "Could {{Cl|NOT}} load image!": {{Cl|END}}
w& = {{Cl|_WIDTH (function)|_WIDTH}}(i&): h& = {{Cl|_HEIGHT}}(i&)
{{Cl|PRINT}} "Make background transparent?(Y\N)";
BG$ = {{Cl|UCASE$}}({{Cl|INPUT$}}(1))
{{Cl|PRINT}} BG$
{{Cl|_DELAY}} 1
{{Cl|CLS}}
'{{Cl|CLS}} 'commented to keep background alpha 0
{{Cl|IF...THEN|IF}} BG$ = "Y" {{Cl|THEN}} {{Cl|_CLEARCOLOR}} {{Cl|_RGB32}}(255, 255, 255), i& 'make white Background transparent
{{Cl|_PUTIMAGE}} (320 - w&, 240 - h&)-((2 * w&) + (320 - w&), (2 * h&) + (240 - h&)), i&, 0
{{Cl|_FREEIMAGE}} i&
MouseMove 320, 240 'center mouse pointer on screen
{{Cl|_MOUSEMOVE}} 320, 240 'center mouse pointer on screen
DO: {{Cl|_LIMIT}} 100
{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 100
{{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}
mx = {{Cl|_MOUSEX}}
my = {{Cl|_MOUSEY}}
@ -86,24 +105,25 @@ DO: {{Cl|_LIMIT}} 100
r = {{Cl|_RED32}}(c&)
g = {{Cl|_GREEN32}}(c&)
b = {{Cl|_BLUE32}}(c&)
{{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} mx; my, "R:"; r, "G:"; g, "B:"; b
a = {{Cl|_ALPHA32}}(c&)
{{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} mx; my, "R:"; r, "G:"; g, "B:"; b, "A:"; a; " "
{{Cl|LOCATE}} 2, 2: {{Cl|PRINT}} "HTML Color: {{Cl|&H}}" + {{Cl|RIGHT$}}({{Cl|HEX$}}(c&), 6)
{{Cl|LOOP}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > ""
{{Cl|END}} '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' Use the mouse pointer routine to get the background RGB of the image to make it transparent with [[_CLEARCOLOR]].
:''Explanation:'' Use the mouse pointer to get the background RGB of the image to make it transparent with [[_CLEARCOLOR]].
''Example 3:'' Creating an image mask to PUT an image over other colored backgrounds.
{{CodeStart}}
''Snippet:'' Creating an image mask to PUT an image over other colored backgrounds. See: [[GET and PUT Demo]] to run code.
{{TextStart}}
FOR c = 0 TO 59 '60 X 60 area from 0 pixel
FOR r = 0 TO 59
IF {{Cl|POINT}}(c, r) = 0 THEN {{Cl|PSET}} (c, r), 15 ELSE PSET (c, r), 0
IF {{Cb|POINT}}(c, r) = 0 THEN {{Cb|PSET}} (c, r), 15 ELSE PSET (c, r), 0
NEXT r
NEXT c
{{Cl|GET (graphics statement)|GET}}(0, 0)-(60, 60), Image(1500) ' save mask in an array(indexed above original image).
{{Cb|GET (graphics statement)|GET}}(0, 0)-(60, 60), Image(1500) ' save mask in an array(indexed above original image).
{{CodeEnd}}
:''Explanation:'' In the procedure all black areas(background) are changed to white for a PUT using AND over other colored objects. The other image colors are changed to black for a PUT of the original image using XOR. The array images can be {{KW|BSAVE}}d for later use. '''QB64 can also''' [[PUT]]''' a full screen 12 image from an array directly into a''' [[BINARY]] '''file.'''
@ -111,19 +131,24 @@ DO: {{Cl|_LIMIT}} 100
''See Examples:''
*{{KW|SAVEIMAGE}} (QB64 Image to Bitmap SUB by Galleon)
* [[SAVEIMAGE]] (QB64 Image to Bitmap SUB by Galleon)
*{{KW|Program ScreenShots}} (Member program for legacy screen modes)
* [[Program ScreenShots]] (Member program for legacy screen modes)
* {{KW|ThirtyTwoBit SUB}} (QB64 Image area to bitmap)
* [[ThirtyTwoBit SUB]] (QB64 Image area to bitmap)
* [[ThirtyTwoBit MEM SUB]] (Fast image area to Bitmap using [[_MEM]])
''See also:''
* [[_NEWIMAGE]], [[_LOADIMAGE]] {{text|(see 32 bit modes)}}
* [[_MEMIMAGE]], [[_MEMGET]]
* [[PSET]], [[PRESET]]
* [[SCREEN]], [[SCREEN (function)]] {{text|(text pointer function)}}
* [[GET (graphics statement)]], [[PUT (graphics statement)]]
* [[Bitmaps]], [[Creating Sprite Masks]], [[Text Using Graphics]] (Demo)
* [http://www.qb64.net/forum/index.php?topic=11052.0 Reading pixel colors faster using _MEMIMAGE]
{{PageNavigation}}

View file

@ -5,11 +5,26 @@ The '''POS''' function returns the current print cursor text column position.
:: column% = POS(0)
* The value in parenthesis should be 0, but any value could be used with same results. Don't ask why...
* The value in parenthesis is normally 0, but any numerical value or variable could be used for compatibility with Basic.
* When a semicolon ends the previous PRINT statement the cursor column position will be after the last character printed.
* If [[TAB]] or a comma is used the column position will be immediately after the tabbed position.
* If [[TAB]] or a comma is used the column position will be immediately after the tabbed position normally 9 spaces after text
* If a [[PRINT]] statement does not use a semicolon or comma at the end, the return value will be 1 on the next row.
* Return can be saved to return later to a previous print position using [[LOCATE]].
* Column position returned can be saved to return to a previous print position later using [[LOCATE]].
''Example:'' Column positions after prints.
{{CodeStart}} '' ''
{{Cl|PRINT}} {{Cl|POS}}(0) 'column position always starts on 1 at top of new or after {{Cl|CLS}}
{{Cl|PRINT}} "hello"; 'column position is 6 on same row immediately after text
{{Cl|PRINT}} {{Cl|POS}}(0)
{{Cl|PRINT}} 'start new row
{{Cl|PRINT}} "hello", 'column position is 15 on same row (normally tabs 9 spaces)
{{Cl|PRINT}} {{Cl|POS}}(0)
{{Cl|PRINT}} 'start new row
{{Cl|PRINT}}
{{Cl|PRINT}} {{Cl|POS}}(0) ' column position is 1 on next row '' ''
{{CodeEnd}}
''Note:'' Column tab prints may not always move 9 spaces past the center of the screen. Some may move text to next row.
''See also:''

View file

@ -16,6 +16,7 @@ The '''PRESET''' graphic [[SCREEN]] statement turns a pixel at a coordinate to t
* Any color value other than 0 will be white in monochrome [[SCREEN]] modes 2 and 11 where the [[COLOR]] statement cannot be used.
* PRESET can invisibly locate other graphics objects like [[CIRCLE]]s and add color to subsequent graphic objects and [[DRAW]] when used.
* The PRESET action can be used in a graphics [[PUT (graphics statement)|PUT]] to produce a color inverted image on any background. See Example 2.
* The QB64 and QB graphic cursor is set to the center of the program window on program start.
* '''PRESET can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only!'''

View file

@ -1,12 +1,12 @@
The [[PRINT (file statement)|PRINT #]] statement prints numeric or string expressions to a file, port or device.
The [[PRINT (file statement)|PRINT #]] statement prints numeric or string expressions to a sequential file, IO port or device.
{{PageSyntax}}
::: '''PRINT #''fileNumber%''''', [ [{{Parameter|expression}}] [{;|,] ... ]
::: '''PRINT #''fileNumber&''''', [ [{{Parameter|expression}}] [{;|,] ... ]
{{Parameters}}
* {{Parameter|fileNumber%}} is the file number of a file or device opened for writing. See {{KW|OPEN}}.
* {{Parameter|fileNumber&}} is the file number of a file or device opened for writing. See {{KW|OPEN}}.
* {{Parameter|expression}} is a numeric or string expression to be written to the file. Quotes will be removed from strings.
* The print statement can be followed by a [[semicolon]] to stop the print cursor or a [[comma]] to tab the next print.
@ -27,6 +27,7 @@ The [[PRINT (file statement)|PRINT #]] statement prints numeric or string expres
** If a numeric literal is in scientific notation, the number is also written in scientific notation. [[PRINT USING (file statement)|PRINT #, USING]] can return actual rounded numerical values in string form.
** The numerical value is always followed by a space character unless [[STR$]] is used to convert it to a string value.
* Whenever [[PRINT (file statement)|PRINT #]] moves the file cursor to a new file row, a carriage return character ({{KW|CHR$|CHR$(13)}}) followed by a line feed character ({{KW|CHR$|CHR$(10)}}) is written. The combination are referred to as the "CRLF" character.
* '''Note: [[RANDOM]] and [[BINARY]] files are not affected by PRINT # statements to them and will create a syntax error in QB64!'''
''Example:'' Prints data to a text file sequentially and reads it back to the program screen as one line of text.

View file

@ -2,7 +2,7 @@ The '''PRINT USING''' statement is used to [[PRINT]] formatted data to the Scree
{{PageSyntax}}
:: '''PRINT''' [''text$''{;|,}] '''USING ''template$''; ''variable'''''[; ...][{;|,}]
:: '''PRINT''' [''text$''{;|,}] '''USING''' ''template$''; ''variable''[; ...][{;|,}]
{{Parameters}}
@ -10,7 +10,7 @@ The '''PRINT USING''' statement is used to [[PRINT]] formatted data to the Scree
* A [[semicolon]] or [[comma]] may follow the ''text'' to stop or tab the print cursor before the ''template'' [[PRINT]].
* The literal or variable [[STRING]] ''template'' should use the template symbols to display each variable [[type]] in the list following it.
* The list of data ''variables'' used in the ''template'' are '''separated by semicolons''' after the template string value.
* A [[semicolon]] or [[comma]] may follow the variable list to stop or tab the print cursor for pending prints.
* In '''QB64''' ONE [[semicolon]] or [[comma]] may follow the variable list to stop the print cursor for pending prints. QB only allowed a semicolon.
''Usage:''
@ -19,6 +19,7 @@ The '''PRINT USING''' statement is used to [[PRINT]] formatted data to the Scree
* No more than 25 # digit places are allowed in a template number or an [[ERROR Codes|error]] will occur.
* Can convert numerical exponential or [[scientific notation]] values to normal decimal point values using less digits.
* '''NOTE:''' If the numerical value exceeds the template's digit range a % symbol will appear in the leftmost digit area.
* '''WARNING: The numbers displayed are rounded so the actual values are never changed and are actually more accurate.'''
{{PrintUsing}}

View file

@ -1,4 +1,4 @@
The '''PRINT #, USING''' statement is used to [[PRINT]] formatted data to a file.
The '''PRINT #, USING''' statement is used to [[PRINT]] formatted text data to a file.
@ -12,7 +12,7 @@ The '''PRINT #, USING''' statement is used to [[PRINT]] formatted data to a file
* A [[semicolon]] or [[comma]] may follow the ''text'' to stop or tab the print cursor before the ''template'' [[PRINT]].
* The literal or variable [[STRING]] ''template'' should use the template symbols to display each variable [[type]] in the list following it.
* The list of data ''variables'' used in the ''template'' are '''separated by semicolons''' after the template string value.
* A [[semicolon]] or [[comma]] may follow the variable list to stop or tab the print cursor for pending prints.
* In '''QB64''' ONE [[semicolon]] or [[comma]] may follow the variable list to stop the print cursor for pending prints. QB only allowed a semicolon.
''Usage:''
@ -21,6 +21,7 @@ The '''PRINT #, USING''' statement is used to [[PRINT]] formatted data to a file
* The variables should be listed in the order that they are used in the template from left to right.
* Normal text is allowed in the template also (see example).
* '''NOTE:''' If the numerical value exceeds the template's integer digit range a % symbol will appear in the leftmost digit area.
* '''WARNING: The numbers displayed are rounded so the actual values are never changed and are actually more accurate.'''
{{PrintUsing}}

Some files were not shown because too many files have changed in this diff Show more