1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-01 09:10:37 +00:00

Updates help files [ci skip]

This commit is contained in:
FellippeHeitor 2019-04-14 22:15:33 -03:00
parent 729557fda2
commit a3a1047a8a
538 changed files with 4189 additions and 4072 deletions

View file

@ -9,11 +9,11 @@ The [[$CHECKING]] metacommand turns C++ event checking ON or OFF.
* The OFF action turns event checking off and should '''only be used when running stable, errorless code.'''
* The default [[$CHECKING]]:ON action is only required when checking has been turned OFF previously.
* When [[$CHECKING]]:OFF is used, all error code and the reporting code is removed from the EXE program.
* '''Warning: Turning OFF error checking could create a General Protection Fault.
* '''Warning: Turning OFF error checking could create a General Protection Fault (or segfault). Use only with 100% stable sections of code.'''
===Details===
* After every QB64 command is translated to C++, the compiler adds special code sections to check for [[ON TIMER (n)]] events and errors that may have occured in the last function call. Disabling error checking with the [[$CHECKING]]:OFF directive prevents the compiler from adding the extra code sections.
* Setting [[$CHECKING]]:OFF is only designed for 100% stable, error-less sections of code, where every CPU cycle saved counts, such as in a software 3D texture mapper, for example.
* Setting [[$CHECKING]]:OFF is only designed for 100% stable, errorless sections of code, where every CPU cycle saved counts, such as in a software 3D texture mapper, for example.
{{PageSeeAlso}}
@ -23,4 +23,4 @@ The [[$CHECKING]] metacommand turns C++ event checking ON or OFF.
* [[ERROR Codes]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -27,7 +27,7 @@ The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throu
{{Cl|_CONSOLE}} ON
{{Cl|_DEST}} {{Cl|_CONSOLE}}
{{Cl|PRINT}} "Close this console window or click main window and press a key!" '' ''
{{Cl|PRINT}} "Close this console window or click main window and press a key!" '' ''
{{CodeEnd}}
@ -38,17 +38,17 @@ The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throu
c&& = -1: d& = -1: e% = -1: f%% = -1
hx$ = {{Cl|HEX$}}(f%%)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(e%)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(d&)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(c&&)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(9223372036854775807)
{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
{{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
@ -57,7 +57,7 @@ Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1
Max _INTEGER64 value = 7FFFFFFFFFFFFFFF with 16 digits
Min _INTEGER64 value = 8000000000000000 with 16 digits
{{OutputEnd}}
: ''Console:'' Right click and select ''Edit'' > ''Select All'' (mouse highlight after) then hit Enter or select ''Edit'' > ''Copy'' to the [[_CLIPBOARD$ (function)|clipboard]].
: ''Console:'' Right click and select ''Edit'' > ''Select All'' (mouse highlight after) then hit Enter or select ''Edit'' > ''Copy'' to the [[_CLIPBOARD$ (function)|clipboard]].
{{TextStart}}Max hex _BYTE = FF with 2 digits = 255
Max hex INTEGER = FFFF with 4 digits = 65535
Max hex LONG = FFFFFFFF with 8 digits = 4294967295
@ -73,4 +73,4 @@ Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1
* [[C_Libraries#Console_Window|C Console Library]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -43,4 +43,4 @@ The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (cha
* [[Arrays]], [[Metacommand]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -1 +1 @@
#REDIRECT [[$IF]]
#REDIRECT [[$IF]]

View file

@ -1 +1 @@
#REDIRECT [[$IF]]
#REDIRECT [[$IF]]

View file

@ -1 +1 @@
#REDIRECT [[$IF]]
#REDIRECT [[$IF]]

View file

@ -34,7 +34,7 @@
{{Cl|$END IF}}
{{Cl|COLOR}} Red
{{Cl|PRINT}} "Hello World"
{{Cl|PRINT}} "Hello World"
{{CodeEnd}}
''Explanation:'' The same CONST is defined twice inside the program. Normally, defining a CONST more than once generates an error, but the $IF condition here is choosing which CONST will be inside the final program.
@ -47,12 +47,12 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
''Example 2:''
{{CodeStart}} '' ''
{{Cl|$IF}} WIN THEN
{{Cl|CONST}} Slash = "\"
{{Cl|CONST}} Slash = "\"
{{Cl|$ELSE}}
{{Cl|CONST}} Slash = "/"
{{Cl|CONST}} Slash = "/"
{{Cl|$END IF}}
{{Cl|PRINT}} "The proper slash for your operating system is "; Slash
{{Cl|PRINT}} "The proper slash for your operating system is "; Slash
{{CodeEnd}}
''Explanation:'' For the above, the CONST slash is defined by the automatic internal flags which returns what operating system is being used at compile time. On a Windows PC, the Slash will be the backslash; for any other OS it will be the forward slash.
@ -63,4 +63,4 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
* [[Metacommand]]s
{{PageNavigation}}
{{PageNavigation}}

View file

@ -39,4 +39,4 @@
* [[Metacommand]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -7,9 +7,9 @@
{{PageDescription}}
* Unlike [[LET]], [[$LET]] is not optional.
* $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.
* $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 valid, but [[$LET]] '''3.2 = ""TRUE""''' will error because of the double quotes.
* 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 valid, but [[$LET]] '''3.2 = ""TRUE""''' will error because of the double quotes.
{{PageExamples}}
@ -24,4 +24,4 @@
* [[Cavemen]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -82,10 +82,10 @@ DO
' *** Remove ({{Cl|TIMER (statement)|FREE}}) the original {{Cl|SCREEN}} image.
{{Cl|_FREEIMAGE}} CurrentScreen
' *** Create a new "original" {{Cl|SCREEN}} image.
' *** Create a new "original" {{Cl|SCREEN}} image.
CurrentScreen = {{Cl|_NEWIMAGE}}({{Cl|_RESIZEWIDTH}}, {{Cl|_RESIZEHEIGHT}}, 32)
' *** Set the {{Cl|SCREEN}} to the new "original" image, releasing the copied {{Cl|SCREEN}} image.
' *** Set the {{Cl|SCREEN}} to the new "original" image, releasing the copied {{Cl|SCREEN}} image.
{{Cl|SCREEN}} CurrentScreen
' {{Cl|DRAW}} PREVIOUS {{Cl|SCREEN}} ON THE NEW ONE
@ -111,4 +111,4 @@ DO
* [[_RESIZEWIDTH]], [[_RESIZEHEIGHT]] {{text|(functions return the requested dimensions)}}
{{PageNavigation}}
{{PageNavigation}}

View file

@ -14,16 +14,16 @@ The [[$SCREENHIDE]] [[Metacommand|metacommand]] can be used to hide the main pro
''Example:'' Hiding a program when displaying a message box in Windows.
{{CodeStart}} '' ''
{{Cl|$SCREENHIDE}}
{{Cl|DECLARE DYNAMIC LIBRARY}} "user32"
{{Cl|DECLARE DYNAMIC LIBRARY}} "user32"
{{Cl|FUNCTION}} MessageBoxA& ({{Cl|BYVAL}} hWnd%&, {{Cl|BYVAL}} lpText%&, {{Cl|BYVAL}} lpCaption%&, {{Cl|BYVAL}} uType~&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|DECLARE DYNAMIC LIBRARY}} "kernel32"
{{Cl|DECLARE DYNAMIC LIBRARY}} "kernel32"
{{Cl|SUB}} ExitProcess ({{Cl|BYVAL}} uExitCode~&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|DIM}} s0 {{Cl|AS}} {{Cl|STRING}}
{{Cl|DIM}} s1 {{Cl|AS}} {{Cl|STRING}}
s0 = "Text" + {{Cl|CHR$}}(0)
s1 = "Caption" + {{Cl|CHR$}}(0)
s0 = "Text" + {{Cl|CHR$}}(0)
s1 = "Caption" + {{Cl|CHR$}}(0)
ExitProcess MessageBoxA(0, {{Cl|_OFFSET (function)|_OFFSET}}(s0), {{Cl|_OFFSET(function)|_OFFSET}}(s1), 0)
{{CodeEnd}}{{small|Code by Michael Calkins}}
@ -34,4 +34,4 @@ ExitProcess MessageBoxA(0, {{Cl|_OFFSET (function)|_OFFSET}}(s0), {{Cl|_OFFSET(f
* [[_CONSOLE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -18,4 +18,4 @@ The [[$SCREENSHOW]] [[Metacommand|metacommand]] can be used to display the main
* [[_CONSOLE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -17,7 +17,7 @@ The '''$STATIC''' Metacommand allows the creation of STATIC(un-changeable) array
{{CodeStart}} '' ''
'{{Cl|$STATIC}}
{{Cl|INPUT}} "Enter array size: ", size
{{Cl|INPUT}} "Enter array size: ", size
{{Cl|DIM}} array(size) 'using an actual number instead of the variable will create an error!
{{Cl|REDIM}} array(2 * size)
@ -32,4 +32,4 @@ The '''$STATIC''' Metacommand allows the creation of STATIC(un-changeable) array
* [[Arrays]], [[Metacommand]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -1,5 +1,5 @@
{{DISPLAYTITLE:$VIRTUALKEYBOARD}}
The [[$VIRTUALKEYBOARD]] [[Metacommand|metacommand]] turns the virtual keyboard ON or OFF.
[DEPRACATED] The [[$VIRTUALKEYBOARD]] [[Metacommand|metacommand]] turns the virtual keyboard ON or OFF.
{{PageSyntax}}
@ -8,6 +8,7 @@ The [[$VIRTUALKEYBOARD]] [[Metacommand|metacommand]] turns the virtual keyboard
{{PageDescription}}
* Places a virtual keyboard on screen, which can be used in touch-enabled devices like Windows tablets.
* Depracated.
{{PageExamples}}
@ -22,4 +23,4 @@ The [[$VIRTUALKEYBOARD]] [[Metacommand|metacommand]] turns the virtual keyboard
* [[Metacommand]]s
{{PageNavigation}}
{{PageNavigation}}

View file

@ -7,28 +7,28 @@ The '''&B''' prefix denotes that an integer value is expressed in a binary b
* 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.
* Leading zero values '''can''' be omitted as they add nothing to the byte return value.
* Eight binary digits would represent a one byte value ranging from 0 to 255. Four digit values("nibbles") range from 0 to 15.
* Decimal values returned can be any '''signed''' [[INTEGER]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as:
* Eight binary digits would represent a one byte value ranging from 0 to 255. Four digit values("nibbles") range from 0 to 15.
* Decimal values returned can be any '''signed''' [[INTEGER]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as:
** [[INTEGER]]: 16 binary digits or a decimal value range from -32,768 to 32,767
** [[LONG]]: 32 binary digits or a decimal value range from -2,147,483,648 to 2,147,483,647
** [[_INTEGER64]]: 64 binary digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
* [[LONG]] values can be returned by appending the & or ~%([[_UNSIGNED]] [[INTEGER]]) symbols after the binary number.
* [[VAL]] can '''NOT''' be used to convert "&B" prefixed string values to decimal! You will have to make your own conversion function.
* [[VAL]] can be used to convert "&B" prefixed string values to decimal.
<center>'''[[_BIT|BITS]]'''</center>
<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.
:* '''"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.
::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>
<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)'''
@ -60,7 +60,7 @@ The '''&B''' prefix denotes that an integer value is expressed in a binary b
12 1100 C 14
13 1101 D 15
14 1110 E 16
15 ------------- 1111 <--- Match ---> F ---------------- 17 -- max 2
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!
@ -93,9 +93,9 @@ The '''&B''' prefix denotes that an integer value is expressed in a binary b
{{Cl|FUNCTION}} BIN$ (n%)
max% = 8 * {{Cl|LEN}}(n%) ': MSB% = 1 'uncomment for 16 (32 or 64) bit returns
{{Cl|FOR...NEXT|FOR}} i = max% - 1 {{Cl|TO}} 0 {{Cl|STEP}} -1 'read as big-endian MSB to LSB
{{Cl|IF...THEN|IF}} (n% {{Cl|AND (boolean)|AND}} 2 ^ i) {{Cl|THEN}} MSB% = 1: B$ = B$ + "1" {{Cl|ELSE}} {{Cl|IF...THEN|IF}} MSB% {{Cl|THEN}} B$ = B$ + "0"
{{Cl|IF...THEN|IF}} (n% {{Cl|AND (boolean)|AND}} 2 ^ i) {{Cl|THEN}} MSB% = 1: B$ = B$ + "1" {{Cl|ELSE}} {{Cl|IF...THEN|IF}} MSB% {{Cl|THEN}} B$ = B$ + "0"
{{Cl|NEXT}}
{{Cl|IF...THEN|IF}} B$ = "" {{Cl|THEN}} BIN$ = "0" {{Cl|ELSE}} BIN$ = B$ 'check for empty string
{{Cl|IF...THEN|IF}} B$ = "" {{Cl|THEN}} BIN$ = "0" {{Cl|ELSE}} BIN$ = B$ 'check for empty string
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
@ -105,7 +105,7 @@ The '''&B''' prefix denotes that an integer value is expressed in a binary b
1000000000000000
1111111111111111
{{OutputEnd}}
''Note:'' The The MSB% flag allows zeroes to be added. Uncomment the MSB% = 1 statement for returns with leading zero's.
''Note:'' The The MSB% flag allows zeroes to be added. Uncomment the MSB% = 1 statement for returns with leading zeroes.
''Example 2:'' QB64 converts the binary values from the example above to [[INTEGER]] decimal values automatically.
@ -128,10 +128,11 @@ d = &B1111111111111111 '& 'or ~%
: ''Note:'' The [[LONG]] values returned are the same as the values you can get using [[_UNSIGNED]] [[INTEGER]] (~%).
''See also:''
{{PageSeeAlso}}
* [[_BIT]], [[_BYTE]]
* [[_SHL]], [[_SHR]]
* [[OCT$]], [[&O]] {{text|(octal)}}
* [[HEX$]], [[&H]] {{text|(hexadecimal)}}
{{PageNavigation}}
{{PageNavigation}}

View file

@ -7,7 +7,7 @@ The '''&H''' prefix denotes that an integer value is expressed in a Hexadeci
* The base 16 numbering system uses hexadecimal digit values of 0 to F. A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
* Leading zero values can be omitted just like in decimal values as they add nothing to the return value.
* Decimal values returned can be any '''signed''' [[INTEGER]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as:
* Decimal values returned can be any '''signed''' [[INTEGER]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as:
::* [[_BYTE]]: 2 hex digits or a decimal value range from -128 to 127. [[_UNSIGNED]]: 0 to 255.
::* [[INTEGER]]: 4 hex digits or a decimal value range from -32,768 to 32,767. [[_UNSIGNED]]: 0 to 65535.
::* [[LONG]]: 8 hex digits or a decimal value range from -2,147,483,648 to 2,147,483,647. [[_UNSIGNED]]: 0 to 4294967295.
@ -18,24 +18,24 @@ 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$).
* 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:
{{CodeStart}} '' ''
c&& = -1: d& = -1: e% = -1: f%% = -1
hx$ = {{Cl|HEX$}}(f%%)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(e%)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(d&)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(c&&)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(9223372036854775807)
{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
{{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
@ -52,30 +52,30 @@ FUNCTION BIN$ (n&)
h$ = {{Cl|HEX$}}(n&) 'get hexadecimal string value
FOR i = 1 TO {{Cl|LEN}}(h$) 'scan the HEX$ digits
SELECT CASE {{Cl|MID$}}(h$, i, 1) 'read each HEX$ digit
CASE "0": b$ = b$ + "0000"
CASE "1": b$ = b$ + "0001"
CASE "2": b$ = b$ + "0010"
CASE "3": b$ = b$ + "0011"
CASE "4": b$ = b$ + "0100"
CASE "5": b$ = b$ + "0101"
CASE "6": b$ = b$ + "0110"
CASE "7": b$ = b$ + "0111"
CASE "8": b$ = b$ + "1000"
CASE "9": b$ = b$ + "1001"
CASE "A": b$ = b$ + "1010"
CASE "B": b$ = b$ + "1011"
CASE "C": b$ = b$ + "1100"
CASE "D": b$ = b$ + "1101"
CASE "E": b$ = b$ + "1110"
CASE "F": b$ = b$ + "1111"
CASE "0": b$ = b$ + "0000"
CASE "1": b$ = b$ + "0001"
CASE "2": b$ = b$ + "0010"
CASE "3": b$ = b$ + "0011"
CASE "4": b$ = b$ + "0100"
CASE "5": b$ = b$ + "0101"
CASE "6": b$ = b$ + "0110"
CASE "7": b$ = b$ + "0111"
CASE "8": b$ = b$ + "1000"
CASE "9": b$ = b$ + "1001"
CASE "A": b$ = b$ + "1010"
CASE "B": b$ = b$ + "1011"
CASE "C": b$ = b$ + "1100"
CASE "D": b$ = b$ + "1101"
CASE "E": b$ = b$ + "1110"
CASE "F": b$ = b$ + "1111"
END SELECT
NEXT i
b$ = {{Cl|RIGHT$}}(b$, LEN(b$) - {{Cl|INSTR}}(b$, "1") + 1) 'eliminate leading zeroes
IF {{Cl|VAL}}(b$) THEN BIN$ = b$ ELSE BIN$ = "0" 'return zero if n& = 0
b$ = {{Cl|RIGHT$}}(b$, LEN(b$) - {{Cl|INSTR}}(b$, "1") + 1) 'eliminate leading zeroes
IF {{Cl|VAL}}(b$) THEN BIN$ = b$ ELSE BIN$ = "0" 'return zero if n& = 0
END FUNCTION '' ''
{{CodeEnd}}
{{small|Code by CodeGuy}}
:''Explanation:'' Hexadecimal digits can be any value up to 15 which also corresponds to all four bits on in binary. The function above just adds every four bit binary string value together to return the binary value. After they are concatenated, the leading bit on is found by [[INSTR]] and everything from that point is kept removing the leading "0"'s.
:''Explanation:'' Hexadecimal digits can be any value up to 15 which also corresponds to all four bits on in binary. The function above just adds every four bit binary string value together to return the binary value. After they are concatenated, the leading bit on is found by [[INSTR]] and everything from that point is kept removing the leading "0"'s.
''See also:''
@ -84,4 +84,4 @@ END FUNCTION '' ''
* [[Base Comparisons]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -6,7 +6,7 @@ The '''&O''' prefix denotes that a integer value is expressed in an Octal ba
* The base eight numbering system only uses octal digit values of 0 to 7.
* Leading zero values '''can''' be omitted as they add nothing to the return value.
* Decimal values returned can be any '''signed''' [[INTEGER]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above. The program [[ERROR Codes|"overflow"]] error limits are listed as:
* Decimal values returned can be any '''signed''' [[INTEGER]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above. The program [[ERROR Codes|"overflow"]] error limits are listed as:
:: * [[INTEGER]]: 6 octal digits or a decimal value range from -32,768 to 32,767
:: * [[LONG]]: 11 octal digits or a decimal value range from -2,147,483,648 to 2,147,483,647
:: * [[_INTEGER64]]: 22 octal digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
@ -17,13 +17,13 @@ The '''&O''' prefix denotes that a integer value is expressed in an Octal ba
{{CodeStart}}
c&& = -1: d& = -1: e% = -1: f%% = -1
oc$ = {{Cl|OCT$}}(f%%)
{{Cl|PRINT}} "Max octal {{Cl|_BYTE}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
{{Cl|PRINT}} "Max octal {{Cl|_BYTE}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(e%)
{{Cl|PRINT}} "Max octal {{Cl|INTEGER}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
{{Cl|PRINT}} "Max octal {{Cl|INTEGER}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(d&)
{{Cl|PRINT}} "Max octal {{Cl|LONG}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
{{Cl|PRINT}} "Max octal {{Cl|LONG}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(c&&)
{{Cl|PRINT}} "Max octal {{Cl|_INTEGER64}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$) '' ''
{{Cl|PRINT}} "Max octal {{Cl|_INTEGER64}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$) '' ''
{{CodeEnd}}
{{OutputStart}}Max octal _BYTE = 377 with 3 digits = 255
Max octal INTEGER = 177777 with 6 digits = 65535
@ -38,4 +38,4 @@ Max octal _INTEGER64 = 1777777777777777777777 with 22 digits =-1
* [[Base Comparisons]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -10,7 +10,7 @@ The '''/''' mathematical operator performs decimal point division on a numerical
{{PageDescription}}
* Number value can be any literal or variable numerical type.
* '''Divisor (second value) must not be a value of 0 to .5'''. This will create a [[ERROR Codes|"Division by zero" error!]] due to [[CINT]] rounding.
* '''Divisor (second value) must not be a value of 0 to .5'''. This will create a [[ERROR Codes|"Division by zero" error!]] due to [[CINT]] rounding.
* Return values can be any literal or variable numerical type, but [[SINGLE]] or [[DOUBLE]] type decimal point returns are likely.
* Values returned may be expressed using exponential or [[scientific notation]] using '''E''' for SINGLE or '''D''' for DOUBLE precision.
* Use the [[\|\ integer division]] operator to guarantee [[INTEGER]] or [[LONG]] return values.
@ -24,4 +24,4 @@ The '''/''' mathematical operator performs decimal point division on a numerical
* [[Mathematical Operations]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -24,4 +24,4 @@ The '''-''' mathematical operator performs subtraction on two numerical values o
{{PageNavigation}}
{{PageNavigation}}

View file

@ -34,4 +34,4 @@ c = {{Cl|ABS}}(c)
* [[Mathematical Operations]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -4,7 +4,7 @@ The [[ACCESS]] clause is used in an [[OPEN]] statement when working over a netwo
{{PageSyntax}}
:OPEN "file.dat" FOR APPEND ['''ACCESS {READ|WRITE}'''] AS #1
:OPEN "file.dat" FOR APPEND ['''ACCESS {READ|WRITE}'''] AS #1
{{PageDescription}}
* Valid Options:
@ -15,7 +15,7 @@ The [[ACCESS]] clause is used in an [[OPEN]] statement when working over a netwo
===Limitations===
*If another process already has access to a specified file, program access is denied for that file OPEN access. A "Permission Denied" error 70 will be returned. A network program must be able to handle a denial of access error.
*If another process already has access to a specified file, program access is denied for that file OPEN access. A "Permission Denied" error 70 will be returned. A network program must be able to handle a denial of access error.
{{PageSeeAlso}}
@ -24,4 +24,4 @@ The [[ACCESS]] clause is used in an [[OPEN]] statement when working over a netwo
* [[ON ERROR]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -31,7 +31,7 @@ The [[ALIAS]] clause in a [[DECLARE LIBRARY]] statement block tells the program
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|DO}} {{Cl|UNTIL}} {{Cl|_SCREENEXISTS}}: {{Cl|LOOP}}
{{Cl|PRINT}} "Hit a key..."
{{Cl|PRINT}} "Hit a key..."
{{Cl|SLEEP}}
MouseMove 1, 1
@ -46,4 +46,4 @@ MouseMove 1, 1
* [[DECLARE (non-BASIC statement)]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -50,12 +50,12 @@ The logical [[AND]] numerical operator compares two values in respect of their b
{{CodeStart}}
DO
{{Cl|INPUT}} "Enter Integer value from -32768 to 32767 (Enter quits): ", INTvalue&
IF INTvalue& < -32768 OR INTvalue& > 32767 OR INTval& = 0 THEN {{Cl|EXIT DO}}
{{Cl|INPUT}} "Enter Integer value from -32768 to 32767 (Enter quits): ", INTvalue&
IF INTvalue& < -32768 OR INTvalue& > 32767 OR INTval& = 0 THEN {{Cl|EXIT DO}}
{{Cl|FOR...NEXT|FOR}} exponent = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1
{{Cl|IF...THEN|IF}} (INTvalue& {{Cl|AND}} 2 ^ exponent) {{Cl|THEN}} {{Cl|PRINT}} "1"; {{Cl|ELSE}} {{Cl|PRINT}} "0";
{{Cl|IF...THEN|IF}} (INTvalue& {{Cl|AND}} 2 ^ exponent) {{Cl|THEN}} {{Cl|PRINT}} "1"; {{Cl|ELSE}} {{Cl|PRINT}} "0";
{{Cl|NEXT}}
PRINT " "
PRINT " "
LOOP UNTIL INTvalue& = 0 'zero entry quits
{{CodeEnd}}
@ -73,4 +73,4 @@ The logical [[AND]] numerical operator compares two values in respect of their b
* [[Binary]], [[Boolean]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -25,7 +25,7 @@ The [[AND (boolean)|AND]] conditonal operator is used to include another evaluat
a% = 100
b% = 50
{{Cl|IF...THEN|IF}} a% > b% {{Cl|AND (boolean)|AND}} a% < 200 {{Cl|THEN}} {{Cl|PRINT}} "True"
{{Cl|IF...THEN|IF}} a% > b% {{Cl|AND (boolean)|AND}} a% < 200 {{Cl|THEN}} {{Cl|PRINT}} "True"
{{CodeEnd}}
{{OutputStart}}
@ -42,10 +42,10 @@ c% = 25
d% = 50
e% = 100
{{Cl|IF...THEN|IF}} (a% > b% {{Cl|AND (boolean)|AND}} b% > c%) {{Cl|AND (boolean)|AND}} (c% < d% {{Cl|AND (boolean)|AND}} d% < e%) {{Cl|THEN}}
{{Cl|PRINT}} "True"
{{Cl|IF...THEN|IF}} (a% > b% {{Cl|AND (boolean)|AND}} b% > c%) {{Cl|AND (boolean)|AND}} (c% < d% {{Cl|AND (boolean)|AND}} d% < e%) {{Cl|THEN}}
{{Cl|PRINT}} "True"
{{Cl|ELSE}}
{{Cl|PRINT}} "False"
{{Cl|PRINT}} "False"
{{Cl|END IF}} '' ''
{{CodeEnd}}
{{OutputStart}}
@ -60,4 +60,4 @@ True
* [[IF...THEN]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -22,4 +22,4 @@ ANY disables type checking for a variable used in a [[SUB]] or [[FUNCTION]] decl
* [[DECLARE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -17,4 +17,4 @@
[[OUTPUT]], [[RANDOM]], [[INPUT (file mode)]], [[BINARY]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -30,4 +30,4 @@ The [[AS]] keyword defines a variable data [[type]].
* [[Variable Types]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -10,7 +10,7 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
* If the optional {{Parameter|position%}} parameter is omitted, ASC will return the [[ASCII]] code of the first [[STRING]] character.
* [[ASCII]] code [[INTEGER]] or [[_UNSIGNED]] [[_BYTE]] values returned range from 0 to 255.
* ASC returns 0 when reading [[ASCII]] 2 byte codes returned by [[INKEY$]] when the arrow, function, Home/Page keys are used.
** Use QB64's {{Parameter|position%}} parameter to read the second byte if necessary. {{Text|IF ASC(key$) <nowiki>=</nowiki> 0 THEN byte2 <nowiki>=</nowiki> ASC(key$, 2)|green}}
** Use QB64's {{Parameter|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''.
@ -29,10 +29,10 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
'''' Tab Q W E R T Y U I O P [{ ]} \| Del End PDn 7Hme 8/▲ 9PU + '''
' 9 81 87 69 82 84 89 85 73 79 80 123 125 124 +83 +79 +81 +71 +72 +73 43
''' 113 119 101 114 116 121 117 105 111 112 91 93 92 55 56 57 ''
'''' CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-►
'''' CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-►
' - 65 83 68 70 71 72 74 75 76 58 34 13 +75 +76 +77 '''E'''
''' 97 115 100 102 103 104 106 107 108 59 39 52 53 54 '' '''n'''
'''' Shift Z X C V B N M ,< .> /? Shift ▲ 1End 2/▼ 3PD t'''
'''' Shift Z X C V B N M ,< .> /? Shift ▲ 1End 2/▼ 3PD t'''
' * 90 88 67 86 66 78 77 60 62 63 * +72 +79 +80 +81 '''e'''
''' 122 120 99 118 98 110 109 44 46 47 49 50 51 '' '''r'''
'''' Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0Ins .Del '''
@ -44,56 +44,56 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
{{WhiteEnd}}
<center>'''[[ASCII#Two_Byte_Codes|Two Byte Ctrl, Alt and Shift + Function key combinations]]'''</center>
<center>'''[[ASCII#Two_Byte_Codes|Two Byte Ctrl, Alt and Shift + Function key combinations]]'''</center>
{{WhiteStart}} '''Two Byte Characters    Key                 CHR$(0) + "?" '''
{{WhiteStart}} '''Two Byte Characters    Key                 CHR$(0) + "?" '''
CHR$(0) + CHR$(16-50) [Alt] + letter
CHR$(0) + CHR$(59) [F1] ";"
CHR$(0) + CHR$(60) [F2] "<"
CHR$(0) + CHR$(61) [F3] "="
CHR$(0) + CHR$(62) [F4] ">"
CHR$(0) + CHR$(63) [F5] "?"
CHR$(0) + CHR$(64) [F6] "@"
CHR$(0) + CHR$(65) [F7] "A"
CHR$(0) + CHR$(66) [F8] "B"
CHR$(0) + CHR$(67) [F9] "C"
CHR$(0) + CHR$(68) [F10] "D"
CHR$(0) + CHR$(71) [Home] "G"
CHR$(0) + CHR$(72) [↑] Arrow "H"
CHR$(0) + CHR$(73) [Page Up] "I"
CHR$(0) + CHR$(75) [←] Arrow "K"
CHR$(0) + CHR$(76) [5 NumberPad] "L" (NumLock off in QB64)
CHR$(0) + CHR$(77) [→] Arrow "M"
CHR$(0) + CHR$(79) [End] "O"
CHR$(0) + CHR$(80) [↓] Arrow "P"
CHR$(0) + CHR$(81) [Page Down] "Q"
CHR$(0) + CHR$(82) [Insert] "R"
CHR$(0) + CHR$(83) [Delete] "S"
CHR$(0) + CHR$(59) [F1] ";"
CHR$(0) + CHR$(60) [F2] "<"
CHR$(0) + CHR$(61) [F3] "="
CHR$(0) + CHR$(62) [F4] ">"
CHR$(0) + CHR$(63) [F5] "?"
CHR$(0) + CHR$(64) [F6] "@"
CHR$(0) + CHR$(65) [F7] "A"
CHR$(0) + CHR$(66) [F8] "B"
CHR$(0) + CHR$(67) [F9] "C"
CHR$(0) + CHR$(68) [F10] "D"
CHR$(0) + CHR$(71) [Home] "G"
CHR$(0) + CHR$(72) [↑] Arrow "H"
CHR$(0) + CHR$(73) [Page Up] "I"
CHR$(0) + CHR$(75) [←] Arrow "K"
CHR$(0) + CHR$(76) [5 NumberPad] "L" (NumLock off in QB64)
CHR$(0) + CHR$(77) [→] Arrow "M"
CHR$(0) + CHR$(79) [End] "O"
CHR$(0) + CHR$(80) [↓] Arrow "P"
CHR$(0) + CHR$(81) [Page Down] "Q"
CHR$(0) + CHR$(82) [Insert] "R"
CHR$(0) + CHR$(83) [Delete] "S"
CHR$(0) + CHR$(84-93) [Shift] + F1-10
CHR$(0) + CHR$(94-103) [Ctrl] + F1-10
CHR$(0) + CHR$(104-113) [Alt] + F1-10
CHR$(0) + CHR$(114-119) [Ctrl] + keypad
CHR$(0) + CHR$(120-129) [Alt] + number
CHR$(0) + CHR$(130 or 131) [Alt] + _/- or +/= "é" or "â"
CHR$(0) + CHR$(133) [F11] "à"
CHR$(0) + CHR$(134) [F12] "å"
CHR$(0) + CHR$(135) [Shift] + [F11] "ç"
CHR$(0) + CHR$(136) [Shift] + [F12] "ê"
CHR$(0) + CHR$(137) [Ctrl] + [F11] "ë"
CHR$(0) + CHR$(138) [Ctrl] + [F12] "è"
CHR$(0) + CHR$(139) [Alt] + [F11] "ï"
CHR$(0) + CHR$(140) [Alt] + [F12] "î"
CHR$(0) + CHR$(130 or 131) [Alt] + _/- or +/= "é" or "â"
CHR$(0) + CHR$(133) [F11] "à"
CHR$(0) + CHR$(134) [F12] "å"
CHR$(0) + CHR$(135) [Shift] + [F11] "ç"
CHR$(0) + CHR$(136) [Shift] + [F12] "ê"
CHR$(0) + CHR$(137) [Ctrl] + [F11] "ë"
CHR$(0) + CHR$(138) [Ctrl] + [F12] "è"
CHR$(0) + CHR$(139) [Alt] + [F11] "ï"
CHR$(0) + CHR$(140) [Alt] + [F12] "î"
{{WhiteEnd}}
:In '''QB64''', [[CVI]] can be used to get the [[_KEYDOWN]] 2-byte code value. Example: IF _KEYDOWN([[CVI]]([[CHR$]](0) + "P")) THEN
:In '''QB64''', [[CVI]] can be used to get the [[_KEYDOWN]] 2-byte code value. Example: IF _KEYDOWN([[CVI]]([[CHR$]](0) + "P")) THEN
{{PageExamples}}
''Example 1:'' How ASC can be used to find any ASCII code in a string of characters using QB64.
{{CodeStart}} '' ''
{{Cl|PRINT}} ASC("A")
{{Cl|PRINT}} ASC("Be a rockstar")
{{Cl|PRINT}} ASC("QB64 is not only COMPATIBLE, it can find any part of the string!", 18) '' ''
{{Cl|PRINT}} ASC("A")
{{Cl|PRINT}} ASC("Be a rockstar")
{{Cl|PRINT}} ASC("QB64 is not only COMPATIBLE, it can find any part of the string!", 18) '' ''
{{CodeEnd}}
''Returns:''
@ -103,26 +103,26 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
67
{{OutputEnd}}
''Explanation:'' The ASCII code for "A" is 65 and the ASCII code for "B" is 66, ASCII code for "C" is 67 and the "C" is at position 18 in the string.
''Explanation:'' The ASCII code for "A" is 65 and the ASCII code for "B" is 66, ASCII code for "C" is 67 and the "C" is at position 18 in the string.
::''Note:'' The ASCII code for "A" and "a" are different by the value of 32, "A" + 32 is "a", 65("A") + 32 = 97("a").
::''Note:'' The ASCII code for "A" and "a" are different by the value of 32, "A" + 32 is "a", 65("A") + 32 = 97("a").
''Example 2:'' Reading the ASCII and two byte code combinations with ASC in '''QB64'''.
{{CodeStart}} '' ''
Q$ = {{Cl|CHR$}}(34) ' quote character
{{Cl|COLOR}} 10: {{Cl|LOCATE}} 5, 22: {{Cl|PRINT}} "Press some keys or combinations!"
{{Cl|COLOR}} 13: {{Cl|LOCATE}} 23, 30: {{Cl|PRINT}} "Escape key Quits"
{{Cl|COLOR}} 10: {{Cl|LOCATE}} 5, 22: {{Cl|PRINT}} "Press some keys or combinations!"
{{Cl|COLOR}} 13: {{Cl|LOCATE}} 23, 30: {{Cl|PRINT}} "Escape key Quits"
DO
DO: {{Cl|SLEEP}}: key$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} key$ <> "" ' prevent ASC empty string read error
DO: {{Cl|SLEEP}}: key$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} key$ <> "" ' prevent ASC empty string read error
code% = {{Cl|ASC}}(key$): {{Cl|COLOR}} 11: {{Cl|LOCATE}} 10, 10
{{Cl|IF...THEN|IF}} code% {{Cl|THEN}} ' ASC returns any value greater than 0
{{Cl|PRINT}} "{{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}(code%)) + ")" + {{Cl|SPACE$}}(13):
{{Cl|IF...THEN|IF}} code% > 8 {{Cl|AND (boolean)|AND}} code% < 14 {{Cl|THEN}} code% = 32 ' unprintable control codes
{{Cl|PRINT}} "{{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}(code%)) + ")" + {{Cl|SPACE$}}(13):
{{Cl|IF...THEN|IF}} code% > 8 {{Cl|AND (boolean)|AND}} code% < 14 {{Cl|THEN}} code% = 32 ' unprintable control codes
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 50: {{Cl|PRINT}} {{Cl|CHR$}}(code%) + {{Cl|SPACE$}}(13)
{{Cl|ELSE}}: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + {{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}({{Cl|ASC}}(key$, 2))) + ")"
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 50: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + " + Q$ + {{Cl|CHR$}}({{Cl|ASC}}(key$, 2)) + Q$
{{Cl|ELSE}}: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + {{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}({{Cl|ASC}}(key$, 2))) + ")"
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 50: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + " + Q$ + {{Cl|CHR$}}({{Cl|ASC}}(key$, 2)) + Q$
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} code% = 27 '' '
@ -136,12 +136,12 @@ DO
DO: {{Cl|SLEEP}} ' requires a keypress to run loop once
K$ = {{Cl|{{Cl|INKEY$}}}}
code = {{Cl|ASC}}(K$)
{{Cl|IF...THEN|IF}} code >= 48 {{Cl|AND (boolean)|AND}} code <= 57 {{Cl|THEN}} entry$ = entry$ + {{Cl|{{Cl|CHR$}}}}(code) ' numbers only
{{Cl|IF...THEN|IF}} code >= 48 {{Cl|AND (boolean)|AND}} code <= 57 {{Cl|THEN}} entry$ = entry$ + {{Cl|{{Cl|CHR$}}}}(code) ' numbers only
{{Cl|IF...THEN|IF}} code = 46 {{Cl|AND (boolean)|AND}} flag = 0 {{Cl|THEN}}
entry$ = entry$ + K$: flag = 1: mark = {{Cl|LEN}}(entry$) ' decimal point
{{Cl|END IF}}
L = {{Cl|{{Cl|LEN}}}}(entry$) ' check entry length for possible backspace
{{Cl|IF...THEN|IF}} code = 8 {{Cl|AND (boolean)|AND}} L > 0 {{Cl|THEN}} ' backspace pressed and entry has a length
{{Cl|IF...THEN|IF}} code = 8 {{Cl|AND (boolean)|AND}} L > 0 {{Cl|THEN}} ' backspace pressed and entry has a length
entry$ = {{Cl|{{Cl|MID$}}}}(entry$, 1, L - 1) ' remove one character from entry$
{{Cl|IF...THEN|IF}} L - 1 < mark {{Cl|THEN}} flag = 0 ' allow another decimal point if removed.
{{Cl|LOCATE}} 10, {{Cl|POS}}(0) - 1: {{Cl|PRINT}} {{Cl|{{Cl|SPACE$}}}}(1); ' remove character from screen
@ -163,4 +163,4 @@ DO
* [[Scancodes]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -6,7 +6,7 @@ The [[ASC (statement)|ASC]] statement allows a '''QB64''' program to change a ch
{{PageDescription}}
* The {{Parameter|stringExpression$}} variable's value must have been previously defined and cannot be an empty string ("").
* The {{Parameter|stringExpression$}} variable's value must have been previously defined and cannot be an empty string ("").
* {{Parameter|position%}} is optional. If no position is used, the leftmost character at position 1 is assumed.
* {{Parameter|position%}} cannot be zero or greater than the string's [[LEN|length]] or an [[ERROR Codes|Illegal function error]] will occur.
* The [[ASCII]] replacement {{Parameter|code%}} value can be any [[INTEGER]] value from 0 to 255.
@ -16,15 +16,15 @@ The [[ASC (statement)|ASC]] statement allows a '''QB64''' program to change a ch
{{PageExamples}}
''Example:'' Demonstrates how to change existing text characters one letter at a time.
{{CodeStart}}
a$ = "YZC"
{{Cl|ASC (statement)|ASC}}(a$) = 65 ' CHR$(65) = "A"
{{Cl|ASC (statement)|ASC}}(a$, 2) = 66 ' CHR$(66) = "B"
a$ = "YZC"
{{Cl|ASC (statement)|ASC}}(a$) = 65 ' CHR$(65) = "A"
{{Cl|ASC (statement)|ASC}}(a$, 2) = 66 ' CHR$(66) = "B"
{{Cl|PRINT}} a$ 'ABC
{{Cl|ASC (statement)|ASC}}(a$, 2) = 0 ' CHR$(0) = " "
{{Cl|ASC (statement)|ASC}}(a$, 2) = 0 ' CHR$(0) = " "
{{Cl|PRINT}} a$
{{Cl|ASC (statement)|ASC}}(a$, 2) = {{Cl|ASC}}("S") ' get code value from ASC function
{{Cl|ASC (statement)|ASC}}(a$, 2) = {{Cl|ASC}}("S") ' get code value from ASC function
{{Cl|PRINT}} a$
{{CodeEnd}}
@ -42,4 +42,4 @@ The [[ASC (statement)|ASC]] statement allows a '''QB64''' program to change a ch
* [[INKEY$]], [[ASCII]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -7,12 +7,12 @@ The [[ATN]] or arctangent function returns the angle in radians of a numerical [
{{Parameters}}
* The return is the {{Parameter|tangent!}}'s angle in '''radians'''.
* {{Parameter|tangent!}} [[SINGLE]] or [[DOUBLE]] values are used by the function. EX:'''{{text|Pi <nowiki>=</nowiki> 4 * ATN(1)|green}}'''
* {{Parameter|tangent!}} [[SINGLE]] or [[DOUBLE]] values are used by the function. EX:'''{{text|Pi <nowiki>=</nowiki> 4 * ATN(1)|green}}'''
{{PageDescription}}
* 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 ''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.
@ -51,21 +51,21 @@ DO
{{Cl|_DISPLAY}}
{{Cl|_LIMIT}} 200
{{Cl|CLS}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> ""
{{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|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|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}}
{{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
@ -85,4 +85,4 @@ DO
* [[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -2,14 +2,14 @@ The '''apostrophe''' is used to tell the compiler to ignore a statement or progr
{{PageDescription}}
* Allows programmer comments or temporary code removal.
* [[REM]] can also be used to "comment out" a line.
* [[REM]] can also be used to "comment out" a line.
* QBasic [[Metacommand|metacommand]]s must be commented either with an apostrophe or [[REM]].
* [[$INCLUDE]] requires an apostrophe before and after the included file name.
{{PageExamples}}
{{CodeStart}}
COLOR 11: PRINT "Print this...." ' PRINT "Don't print this program comment!"
COLOR 11: PRINT "Print this...." ' PRINT "Don't print this program comment!"
{{CodeEnd}}
{{OutputStart}}
@ -22,4 +22,4 @@ COLOR 11: PRINT "Print this...." ' PRINT "Don't print this progra
* [[REM]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -7,7 +7,7 @@ The [[BEEP]] statement produces a beep sound through the sound card.
{{PageDescription}}
* [[BEEP]] can be placed anywhere to alert the user that there is something to do or an error has occurred.
* '''QB64''' produces the actual "beep" sound through the PC's sound card, to emulate QBasic's beeping through the [https://en.wikipedia.org/wiki/PC_speaker PC speaker].
* '''QB64''' produces the actual "beep" sound through the PC's sound card, to emulate QBasic's beeping through the [https://en.wikipedia.org/wiki/PC_speaker PC speaker].
==QBasic/QuickBASIC==
@ -21,4 +21,4 @@ The [[BEEP]] statement produces a beep sound through the sound card.
* [[_SNDRAW]] {{text|(play frequency waves)}}
{{PageNavigation}}
{{PageNavigation}}

View file

@ -26,16 +26,16 @@
int64 = 12345678
{{Cl|PRINT}} int64
{{Cl|OPEN}} "temp64.tmp" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1
{{Cl|OPEN}} "temp64.tmp" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1
{{Cl|PUT}} #1, , int64 'the file size will be 8 bytes
{{Cl|CLOSE}}
{{Cl|PRINT}} "Press a key to read the file!"
{{Cl|PRINT}} "Press a key to read the file!"
K$ = {{Cl|INPUT$}}(1)
{{Cl|OPEN}} "temp64.tmp" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1
{{Cl|OPEN}} "temp64.tmp" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1
{{Cl|GET}} #1, , byte8 'GET the value as a string
{{Cl|PRINT}} "text string: "; byte8 'show that string is in {{Cl|_MK$}} format
{{Cl|PRINT}} "text string: "; byte8 'show that string is in {{Cl|_MK$}} format
{{Cl|PRINT}} {{Cl|_CV}}({{Cl|_INTEGER64}}, byte8) 'convert to numerical value
{{Cl|CLOSE}} '' ''
@ -48,11 +48,11 @@ K$ = {{Cl|INPUT$}}(1)
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(1000, 600, 256)
{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}}
{{Cl|DIM}} value AS {{Cl|INTEGER}} 'value type can be changed
{{Cl|LINE INPUT}} ; "Enter a {{Cl|BINARY}} filename to open: ", file$
{{Cl|PRINT}} " Press S to restart!"
{{Cl|LINE INPUT}} ; "Enter a {{Cl|BINARY}} filename to open: ", file$
{{Cl|PRINT}} " Press S to restart!"
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(file$) {{Cl|THEN}} {{Cl|OPEN}} file$ {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 {{Cl|ELSE}} {{Cl|END}}
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(1) = 0 {{Cl|THEN}} {{Cl|PRINT}} "Empty file!": {{Cl|END}}
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(1) = 0 {{Cl|THEN}} {{Cl|PRINT}} "Empty file!": {{Cl|END}}
DO
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 16
x = x + 1
@ -60,13 +60,13 @@ DO
{{Cl|IF...THEN|IF}} {{Cl|EOF}}(1) {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|PRINT}} value;
{{Cl|NEXT}}
{{Cl|PRINT}} {{Cl|CHR$}}(27); x; "@"; row
{{Cl|PRINT}} {{Cl|CHR$}}(27); x; "@"; row
K$ = {{Cl|INPUT$}}(1)
{{Cl|IF...THEN|IF}} {{Cl|UCASE$}}(K$) = "S" {{Cl|THEN}} {{Cl|CLS}}: x = 0: row = 0: {{Cl|PRINT}} "Restarted!": {{Cl|SEEK}} 1, 1
{{Cl|IF...THEN|IF}} {{Cl|UCASE$}}(K$) = "S" {{Cl|THEN}} {{Cl|CLS}}: x = 0: row = 0: {{Cl|PRINT}} "Restarted!": {{Cl|SEEK}} 1, 1
{{Cl|IF...THEN|IF}} x = 256 {{Cl|THEN}} x = 0: row = row + 1: {{Cl|PRINT}}
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27)
{{Cl|CLOSE}} #1
{{Cl|PRINT}} "Press Escape to exit!"
{{Cl|PRINT}} "Press Escape to exit!"
DO: {{Cl|_LIMIT}} 100
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27)
{{Cl|SYSTEM}} '' ''
@ -81,4 +81,4 @@ DO: {{Cl|_LIMIT}} 100
* [[Bitmaps]], [[Binary]] (numbers)
{{PageNavigation}}
{{PageNavigation}}

View file

@ -52,4 +52,4 @@
* [[Text Using Graphics]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -55,7 +55,7 @@
''Example 3:'' Using [[PUT]] and [[GET]] to write and read array data from a file without using BSAVE or [[BLOAD]]:
{{CodeStart}}
{{Cl|KILL}} "example2.BIN" 'removes old image file!
{{Cl|KILL}} "example2.BIN" 'removes old image file!
{{Cl|SCREEN}} 13
{{Cl|OPTION BASE}} 0
@ -65,16 +65,16 @@
{{Cl|GET (graphics statement)|GET}}(0, 0)-{{Cl|STEP}}(10, 10), Graphic%() 'get image to array
{{Cl|FOR...NEXT|FOR}} i% = 1000 {{Cl|TO}} 0 {{Cl|STEP}} -1 'reverse read array for size needed
{{Cl|IF...THEN|IF}} Graphic%(i%) <> 0 {{Cl|THEN}} {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} 'find image color not black
{{Cl|IF...THEN|IF}} Graphic%(i%) <> 0 {{Cl|THEN}} {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} 'find image color not black
{{Cl|NEXT}}
size% = i% + 4 'size plus 2 integers(4 bytes) for dimensions
{{Cl|REDIM}} {{Cl|_PRESERVE}} Graphic%(size%) 'resize existing array in QB64 only!
{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 ' {{Cl|PUT}} to a file
{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 ' {{Cl|PUT}} to a file
{{Cl|PUT}} #1, , Graphic%()
{{Cl|CLOSE}}
{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2 'GET array and {{Cl|PUT}} to screen
{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2 'GET array and {{Cl|PUT}} to screen
{{Cl|DIM}} CopyBin%({{Cl|LOF}}(2) \ 2) 'create new array sized by half of file size
{{Cl|GET}} #2, , CopyBin%()
{{Cl|PUT (graphics statement)|PUT}}(100, 100), CopyBin%(), {{Cl|PSET}}
@ -85,11 +85,11 @@ K$ = {{Cl|INPUT$}}(1) 'Press any key
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 20 'read all 3 arrays
{{Cl|PRINT}} Graphic%(i); CopyBin%(i)
{{Cl|NEXT}}
{{Cl|PRINT}} "Array:"; size%, "File:"; fsize%
{{Cl|PRINT}} "Array:"; size%, "File:"; fsize%
{{CodeEnd}}{{small|Code by Ted Weissgerber}}
: ''Explanation:'' A 10 by 10 pixel box is saved to an array using the [[GET (graphics statement)]] and written to a BINARY file using [[PUT]] #1. Then [[GET]] #1 places the file contents into another INTEGER array and places it on the screen with the [[PUT (graphics statement)]].
: The array contents: 88 is the width in the GET array for [[SCREEN]] 13 which needs divided by 8 in that mode only. The area is actually 11 X 11. The array size needed can be found by looping backwards through the array until a color value is found. '''{{text|IF array(i) <> 0 THEN EXIT FOR|green}}''' (66 integers) or by dividing the created BINARY file size in half (134 bytes) when known to be array sized already.
: The array contents: 88 is the width in the GET array for [[SCREEN]] 13 which needs divided by 8 in that mode only. The area is actually 11 X 11. The array size needed can be found by looping backwards through the array until a color value is found. '''{{text|IF array(i) <> 0 THEN EXIT FOR|green}}''' (66 integers) or by dividing the created BINARY file size in half (134 bytes) when known to be array sized already.
{{PageSeeAlso}}
@ -101,4 +101,4 @@ K$ = {{Cl|INPUT$}}(1) 'Press any key
* [[Text Using Graphics]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -26,24 +26,24 @@ The [[BYVAL]] statement is used to pass a numerical parameter's value with proce
{{PageExamples}}
''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|DECLARE LIBRARY}} "SDL"
{{Cl|DECLARE LIBRARY}} "SDL"
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} xoffset&, {{Cl|BYVAL}} yoffset&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{CodeEnd}}
: ''Note:'' The DLL call above uses the SDL library, which was included with QB64 up to version 0.954. Won't work with '''version 1.000 and up'''.
''Example 2:'' Passing parameters "by value" using [[parenthesis|brackets]] when calling a [[SUB]] or [[FUNCTION]] in QBasic or QB64.
''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}} "After procedures: "; 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
{{Cl|PRINT}} "Inside procedure: "; a%, b%, c%
{{Cl|PRINT}} "Inside procedure: "; a%, b%, c%
{{Cl|END SUB}} '' ''
{{CodeEnd}}
{{OutputStart}}
@ -62,4 +62,4 @@ After procedures: 2 1 0
* [[Libraries#C++_Variable_Types|C++ Variable Types]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -35,7 +35,7 @@ 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}} "Hello World!"
{{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
@ -61,4 +61,4 @@ Hello World!
* [[DECLARE]], [[DECLARE (non-BASIC statement)]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -21,4 +21,4 @@
*[[CALL]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -23,4 +23,4 @@
* [[_MOUSEINPUT]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -16,7 +16,7 @@
** [[CASE]] value
** [[CASE]] value1 [[TO]] value2
** [[CASE]] value1, value2, value3
** [[CASE IS]] value1 > value2
** [[CASE IS]] value1 > value2
** [[CASE ELSE]]
* The first time a [[CASE]] value matches the compared variable's value, that [[CASE]] code is executed and [[SELECT CASE]] is exited, unless '''EVERYCASE''' is used.
@ -24,14 +24,14 @@
{{CodeStart}}
a = 100
{{Cl|SELECT CASE}} a
{{Cl|CASE}} 1, 3, 5, 7, 9: {{Cl|PRINT}} "Odd values under 10 will be shown."
{{Cl|CASE}} 10: {{Cl|PRINT}} "10 will be shown."
{{Cl|CASE}} 50: {{Cl|PRINT}} "50 will be shown."
{{Cl|CASE}} 100: {{Cl|PRINT}} "This will be shown. (a is 100)"
{{Cl|PRINT}} "(and this)"
{{Cl|CASE}} 150: {{Cl|PRINT}} "150 will be shown."
{{Cl|CASE IS}} < 150: {{Cl|PRINT}} "Less than 150 will be shown. (a which is 100 is under 150)"
{{Cl|CASE}} 50 {{Cl|TO}} 150: {{Cl|PRINT}} "50 to 150 will be shown. (a which is 100 is between 50 TO 150)"
{{Cl|CASE}} 1, 3, 5, 7, 9: {{Cl|PRINT}} "Odd values under 10 will be shown."
{{Cl|CASE}} 10: {{Cl|PRINT}} "10 will be shown."
{{Cl|CASE}} 50: {{Cl|PRINT}} "50 will be shown."
{{Cl|CASE}} 100: {{Cl|PRINT}} "This will be shown. (a is 100)"
{{Cl|PRINT}} "(and this)"
{{Cl|CASE}} 150: {{Cl|PRINT}} "150 will be shown."
{{Cl|CASE IS}} < 150: {{Cl|PRINT}} "Less than 150 will be shown. (a which is 100 is under 150)"
{{Cl|CASE}} 50 {{Cl|TO}} 150: {{Cl|PRINT}} "50 to 150 will be shown. (a which is 100 is between 50 TO 150)"
{{Cl|END SELECT}}
{{CodeEnd}}
@ -50,10 +50,10 @@ a = 100
:* A [[CASE]] can list several values separated by commas for the same program option to be executed.
:* [[CASE IS]] is used when we need to compare the value to a conditional expression range such as a value is "=" equal to, "<" less than, ">" greater than, "<>" not equal to or [[NOT]] a value.
:* [[CASE IS]] is used when we need to compare the value to a conditional expression range such as a value is "=" equal to, "<" less than, ">" greater than, "<>" not equal to or [[NOT]] a value.
:* A [[CASE]] range can be specified (in the example; 50 [[TO]] 150) if needed.
<center>''Note:'' A [[SELECT CASE]] block has to end with [[END SELECT]].</center>
<center>''Note:'' A [[SELECT CASE]] block has to end with [[END SELECT]].</center>
{{PageSeeAlso}}
@ -62,4 +62,4 @@ a = 100
* [[IF...THEN]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -5,7 +5,7 @@
{{PageDescription}}
* [[CASE ELSE]] should be listed at the bottom of the case list as it will supersede any case statements after it.
* Use it as a "safety net" or as an alternative for all values not covered in the [[CASE]] statements.
* Use it as a "safety net" or as an alternative for all values not covered in the [[CASE]] statements.
{{PageExamples}}
@ -14,11 +14,11 @@
a = 100
{{Cl|SELECT CASE}} a
{{Cl|CASE}} {{Cl|IS}} < 99: {{Cl|PRINT}} "a is < 99"
{{Cl|CASE}} 99: {{Cl|PRINT}} "a is 99"
{{Cl|CASE}} {{Cl|IS}} > 100: {{Cl|PRINT}} "a is > 100"
{{Cl|CASE}} {{Cl|IS}} < 99: {{Cl|PRINT}} "a is < 99"
{{Cl|CASE}} 99: {{Cl|PRINT}} "a is 99"
{{Cl|CASE}} {{Cl|IS}} > 100: {{Cl|PRINT}} "a is > 100"
{{Cl|CASE ELSE}}
{{Cl|PRINT}} "a is 100"
{{Cl|PRINT}} "a is 100"
{{Cl|END SELECT}}
{{CodeEnd}}
@ -35,10 +35,10 @@ a is 100
a = 100
{{Cl|SELECT CASE}} a
{{Cl|CASE}} 10: {{Cl|PRINT}} "a is 10"
{{Cl|CASE}} 20: {{Cl|PRINT}} "a is 20"
{{Cl|CASE}} 30: {{Cl|PRINT}} "a is 30"
{{Cl|CASE ELSE}}: {{Cl|PRINT}} "a is something other than 10, 20 and 30"
{{Cl|CASE}} 10: {{Cl|PRINT}} "a is 10"
{{Cl|CASE}} 20: {{Cl|PRINT}} "a is 20"
{{Cl|CASE}} 30: {{Cl|PRINT}} "a is 30"
{{Cl|CASE ELSE}}: {{Cl|PRINT}} "a is something other than 10, 20 and 30"
{{Cl|END SELECT}}
{{CodeEnd}}
@ -59,4 +59,4 @@ a is something other than 10, 20 and 30
*[[IF...THEN]], [[ELSE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -4,16 +4,16 @@
{{PageSyntax}}
: [[CASE IS]] '''{=|<|>|<=|>=|<>|[[NOT]]} {{Parameter|expression}}'''
: [[CASE IS]] '''{=|<|>|<=|>=|<>|[[NOT]]} {{Parameter|expression}}'''
{{PageDescription}}
* [[AND (boolean)|AND]] can be used to add extra conditions to a [[CASE IS]] statement evaluation.
* [[OR (boolean)|OR]] can be used to add alternate conditions to a [[CASE IS]] statement evaluation.
* Parenthesis are allowed in [[CASE IS]] statements to clarify an evaluation.
* [[CASE IS]] > 100 uses the greater than expression.
* [[CASE IS]] > 100 uses the greater than expression.
* [[CASE IS]] <= 100 uses the less than or equal to expression.
* [[CASE IS]] <> 100 uses the not equal to expression(same as [[NOT]] 100).
* [[CASE IS]] <> 100 uses the not equal to expression(same as [[NOT]] 100).
{{Template:RelationalTable}}
@ -24,4 +24,4 @@
* [[SELECT CASE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -31,4 +31,4 @@
* [[CSNG]], [[_ROUND]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -8,7 +8,7 @@
{{PageSyntax}}
: [[DECLARE]] {[[SUB]]|[[FUNCTION]]} name ['''CDECL'''] [ [[ALIAS]] "aliasname"] [([parameterlist])]
: [[DECLARE]] {[[SUB]]|[[FUNCTION]]} name ['''CDECL'''] [ [[ALIAS]] "aliasname"] [([parameterlist])]
*'''[[Keywords currently not supported by QB64|Not supported in QB64.]]'''
@ -20,4 +20,4 @@
*[[DECLARE (non-BASIC statement)]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -30,10 +30,10 @@
{{PageExamples}}
''Example:'' CHAIN looks for same file type extension as program module (BAS or EXE).
{{CodeStart}} '' ''
{{Cl|CHAIN}} "Level1" '' ''
{{Cl|CHAIN}} "Level1" '' ''
{{CodeEnd}}
''Explanation:'' The file referred to is "Level1.BAS" if the program module using the call is a BAS file. If the program was compiled, it would look for "Level1.EXE".
''Explanation:'' The file referred to is "Level1.BAS" if the program module using the call is a BAS file. If the program was compiled, it would look for "Level1.EXE".
{{PageSeeAlso}}
@ -43,4 +43,4 @@
* [[LINKed or Merged Modules]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -8,23 +8,23 @@ The [[CHDIR]] statement changes the program's location from one working director
{{PageDescription}}
* {{Parameter|path$}} is the new directory path the program will work in.
* {{Parameter|path$}} can be an absolute path (starting from the root folder) or relative path (starting from the current program location).
* If {{Parameter|path$}} specifies a non-existing path, a [[ERROR Codes|"Path not found"]] error will occur.
* '''A QB64 [[SHELL]] statement cannot use "CD " or "CHDIR " + path$ to change directories.'''
* If {{Parameter|path$}} specifies a non-existing path, a [[ERROR Codes|"Path not found"]] error will occur.
* '''A QB64 [[SHELL]] statement cannot use "CD " or "CHDIR " + path$ to change directories.'''
{{PageExamples}}
''Example 1:'' The following code is Windows-specific:
{{CodeStart}} '' ''
{{Cl|CHDIR}} "C:\" 'change to the root drive C (absolute path)
{{Cl|CHDIR}} "DOCUME~1" 'change to "C:\Documents and Settings" from root drive (relative path)
{{Cl|CHDIR}} "..\" 'change back to previous folder one up '' ''
{{Cl|CHDIR}} "C:\" 'change to the root drive C (absolute path)
{{Cl|CHDIR}} "DOCUME~1" 'change to "C:\Documents and Settings" from root drive (relative path)
{{Cl|CHDIR}} "..\" 'change back to previous folder one up '' ''
{{CodeEnd}}
:''Details:'' '''QB64''' can use long or short (8.3 notation) file and path names.
''Example 2:'' Using the Windows API to find the current program's name and root path. The PATH$ is a shared function value.
{{CodeStart}} '' ''
{{Cl|_TITLE}} "My program"
{{Cl|_TITLE}} "My program"
{{Cl|PRINT}} TITLE$
{{Cl|PRINT}} PATH$
@ -40,13 +40,13 @@ Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) '0 designates
PATH$ = {{Cl|LEFT$}}(FileName$, Result)
start = 1
DO
posit = {{Cl|INSTR}}(start, PATH$, "\")
posit = {{Cl|INSTR}}(start, PATH$, "\")
{{Cl|IF...THEN|IF}} posit {{Cl|THEN}} last = posit
start = posit + 1
{{Cl|LOOP}} {{Cl|UNTIL}} posit = 0
TITLE$ = {{Cl|MID$}}(PATH$, last + 1)
PATH$ = {{Cl|LEFT$}}(PATH$, last)
{{Cl|ELSE}} TITLE$ = "": PATH$ = ""
{{Cl|ELSE}} TITLE$ = "": PATH$ = ""
{{Cl|END IF}}
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
@ -60,4 +60,4 @@ Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) '0 designates
* [[$CONSOLE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -19,7 +19,7 @@ The [[CHR$]] function returns the character associated with a certain [[ASCII|ch
{{OutputStart}}Aa
Bb
{{OutputEnd}}
:Explanation: 65 is the ASCII code for "A" and 65 + 32 is the ASCII code for "a". 66 is the ASCII code for "B" and 66 + 32 is the ASCII code for "b"
:Explanation: 65 is the ASCII code for "A" and 65 + 32 is the ASCII code for "a". 66 is the ASCII code for "B" and 66 + 32 is the ASCII code for "b"
''Example 2:'' To cut down on typing CHR$(???) all day, define often used characters as variables such as Q$ = CHR$(34) as shown.
@ -28,11 +28,11 @@ Bb
{{Cl|DIM}} Q AS {{Cl|STRING}} * 1 'define as one byte string(get rid of $ type suffix too)
Q = {{Cl|CHR$}}(34) 'Q will now represent the elusive quotation mark in a string
PRINT "This text uses "; Q; "quotation marks"; Q; " that could have caused a syntax error!"
PRINT "This text uses "; Q; "quotation marks"; Q; " that could have caused a syntax error!"
{{CodeEnd}}
{{OutputStart}}
This text uses "quotation marks" that could have caused a syntax error!
This text uses "quotation marks" that could have caused a syntax error!
{{OutputEnd}}
@ -40,11 +40,11 @@ This text uses "quotation marks" that could have caused a syntax error
{{CodeStart}}{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 ' FileName to be encrypted
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(1) <= 32000 {{Cl|THEN}} Text$ = {{Cl|INPUT$}}({{Cl|LOF}}(1), 1) ' get Text as one string
{{Cl|CLOSE}} #1
Send$ = "" ' clear value
Send$ = "" ' clear value
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(Text$)
Letter$ = {{Cl|MID$}}(Text$, i, 1) ' get each character in the text
Code = {{Cl|ASC}}(Letter$)
{{Cl|IF...THEN|IF}} (Code > 64 {{Cl|AND (boolean)|AND}} Code < 91) {{Cl|OR (boolean)|OR}} (Code > 96 {{Cl|AND (boolean)|AND}} Code < 123) {{Cl|THEN}}
{{Cl|IF...THEN|IF}} (Code > 64 {{Cl|AND (boolean)|AND}} Code < 91) {{Cl|OR (boolean)|OR}} (Code > 96 {{Cl|AND (boolean)|AND}} Code < 123) {{Cl|THEN}}
Letter$ = {{Cl|CHR$}}(Code + 130) ' change letter's ASCII character by 130
{{Cl|END IF}}
Send$ = Send$ + Letter$ ' reassemble string with just letters encrypted
@ -60,11 +60,11 @@ Send$ = "" ' clear value
{{CodeStart}}{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 ' FileName to be decrypted
Text$ = {{Cl|INPUT$}}({{Cl|LOF}}(1), 1) ' open Text as one string
{{Cl|CLOSE}} #1
Send$ = ""
Send$ = ""
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(Text$)
Letter$ = {{Cl|MID$}}(Text$, i, 1)
Code = {{Cl|ASC}}(Letter$)
{{Cl|IF...THEN|IF}} (Code > 194 {{Cl|AND (boolean)|AND}} Code < 221) {{Cl|OR (boolean)|OR}} (Code > 226 {{Cl|AND (boolean)|AND}} Code < 253) {{Cl|THEN}}
{{Cl|IF...THEN|IF}} (Code > 194 {{Cl|AND (boolean)|AND}} Code < 221) {{Cl|OR (boolean)|OR}} (Code > 226 {{Cl|AND (boolean)|AND}} Code < 253) {{Cl|THEN}}
Letter$ = {{Cl|CHR$}}(Code - 130) ' change back to a Letter character
{{Cl|END IF}}
Send$ = Send$ + Letter$ ' reassemble string as normal letters
@ -83,4 +83,4 @@ Send$ = ""
* [[ASCII|ASCII character codes]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -17,7 +17,7 @@ The [[CINT]] function rounds decimal point numbers up or down to the nearest [[I
{{PageExamples}}
''Example:'' Shows how CINT rounds values up or down as in "bankers' rounding".
''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 '' ''
@ -32,4 +32,4 @@ a% = {{Cl|CINT}}(1.49): b% = {{Cl|CINT}}(1.50): c = 11.5
* [[INT]], [[FIX]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -37,7 +37,7 @@ DO
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|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.
@ -65,10 +65,10 @@ clockcount% = 15 'A counter to keep track of the radians
{{Cl|CLS}}
{{Cl|LOCATE}} 1, 1
{{Cl|COLOR}} 14, 0
{{Cl|PRINT}} "Ritchie's Clock"
{{Cl|PRINT}} "Ritchie's Clock"
{{Cl|COLOR}} 9, 0
{{Cl|PRINT}} "Uses {{Cl|CIRCLE}} to"
{{Cl|PRINT}} "draw hands!"
{{Cl|PRINT}} "Uses {{Cl|CIRCLE}} to"
{{Cl|PRINT}} "draw hands!"
{{Cl|COLOR}} 8, 0
{{Cl|CIRCLE}} (160, 100), 110, 8 'circle with radius of 110 and dark gray
{{Cl|CIRCLE}} (160, 100), 102, 8 'circle with radius of 102 and dark gray
@ -88,14 +88,14 @@ minutes% = {{Cl|INT}}({{Cl|VAL}}({{Cl|MID$}}({{Cl|TIME$}}, 4, 2))) 'extract minu
{{Cl|IF...THEN|IF}} minutes% = 0 {{Cl|THEN}} minutes% = 60 'array counts 1 to 60 not 0 to 59
previousminute% = minutes% 'hold current minute for later use
hours% = {{Cl|INT}}({{Cl|VAL}}({{Cl|LEFT$}}({{Cl|TIME$}}, 2))) 'extract hour from {{Cl|TIME$}}
{{Cl|IF...THEN|IF}} hours% >= 12 {{Cl|THEN}} hours% = hours% - 12 'convert from military time
{{Cl|IF...THEN|IF}} hours% >= 12 {{Cl|THEN}} hours% = hours% - 12 'convert from military time
{{Cl|IF...THEN|IF}} hours% = 0 {{Cl|THEN}} hours% = 12 'count from 1 to 12 not 0 to 11
previoushour% = hours% 'hold current hour for later use
'*
'* Start of main program loop
'*
{{Cl|DO}}
{{Cl|IF...THEN|IF}} seconds% <> previoussecond% {{Cl|THEN}} 'has a second elapsed?
{{Cl|IF...THEN|IF}} seconds% <> previoussecond% {{Cl|THEN}} 'has a second elapsed?
{{Cl|LOCATE}} 22, 17 'print the time on the screen at
{{Cl|PRINT}} {{Cl|TIME$}}; 'position 22, 17
'* Since a second has elapsed we need to erase the old second hand
@ -104,7 +104,7 @@ previoushour% = hours% 'hold current hour for later use
{{Cl|CIRCLE}} (160, 100), 100, 0, -clock(previoussecond%), clock(previoussecond%)
{{Cl|CIRCLE}} (160, 100), 100, 15, -clock(seconds%), clock(seconds%)
previoussecond% = seconds% 'hold current second for later use
{{Cl|IF...THEN|IF}} minutes% <> previousminute% {{Cl|THEN}} 'has a minute elapsed?
{{Cl|IF...THEN|IF}} minutes% <> previousminute% {{Cl|THEN}} 'has a minute elapsed?
'* Since a minute has elapsed we need to erase the old hour hand position
{{Cl|CIRCLE}} (160, 100), 90, 0, -clock(previousminute%), clock(previousminute%)
previousminute% = minutes% 'hold current minute for later use
@ -113,7 +113,7 @@ previoushour% = hours% 'hold current hour for later use
'* Draw the current minute hand position
'*
{{Cl|CIRCLE}} (160, 100), 90, 14, -clock(minutes%), clock(minutes%)
{{Cl|IF...THEN|IF}} hours% <> previoushour% {{Cl|THEN}} 'has an hour elapsed?
{{Cl|IF...THEN|IF}} hours% <> previoushour% {{Cl|THEN}} 'has an hour elapsed?
'* Since an hour has elapsed we need to erase the old hour hand position
{{Cl|CIRCLE}} (160, 100), 75, 0, -clock(previoushour% * 5), clock(previoushour% * 5)
previoushour% = hours% 'hold current hour for later use
@ -128,9 +128,9 @@ previoushour% = hours% 'hold current hour for later use
minutes% = {{Cl|VAL}}({{Cl|MID$}}({{Cl|TIME$}}, 4, 2))
{{Cl|IF...THEN|IF}} minutes% = 0 {{Cl|THEN}} minutes% = 60
hours% = {{Cl|VAL}}({{Cl|LEFT$}}({{Cl|TIME$}}, 2))
{{Cl|IF...THEN|IF}} hours% >= 12 {{Cl|THEN}} hours% = hours% - 12
{{Cl|IF...THEN|IF}} hours% >= 12 {{Cl|THEN}} hours% = hours% - 12
{{Cl|IF...THEN|IF}} hours% = 0 {{Cl|THEN}} hours% = 12
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'stop program if user presses a key '' ''
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'stop program if user presses a key '' ''
{{CodeEnd}}
{{small|code by Terry Ritchie}}
@ -142,4 +142,4 @@ previoushour% = hours% 'hold current hour for later use
* [[SCREEN]], [[SCREEN (function)]]
* [[Alternative circle routine]] {{text|(member-contributed program)}}
{{PageNavigation}}
{{PageNavigation}}

View file

@ -7,7 +7,7 @@ The [[CLEAR]] statement clears all variable and array element values in a progra
{{PageDescription}}
* All parameters are optional and ignored by '''QB64'''.
* Normally used to clear all program variable and [[Arrays|array]] values where numerical values become zero and string values become empty ("").
* Normally used to clear all program variable and [[Arrays|array]] values where numerical values become zero and string values become empty ("").
* It does not clear [[CONST|constant]] values.
* Closes all opened files.
* [[$DYNAMIC]] or [[REDIM]] arrays will need to be [[REDIM|redimensioned]] or an [[ERROR Codes|error]] will occur when referenced because they are removed.
@ -26,7 +26,7 @@ array(5) = 23
{{Cl|PRINT}} array(5) '' ''
{{CodeEnd}}
:''Note:'' If you change DIM to REDIM a "Subscript out of range" error will occur because a [[$DYNAMIC]] array is removed by CLEAR.
:''Note:'' If you change DIM to REDIM a "Subscript out of range" error will occur because a [[$DYNAMIC]] array is removed by CLEAR.
{{PageSeeAlso}}
@ -35,4 +35,4 @@ array(5) = 23
* [[Arrays]], [[&B|_BIT arrays]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -33,4 +33,4 @@ The [[CLNG]] function rounds decimal point numbers up or down to the nearest [[L
* [[_ROUND]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -26,4 +26,4 @@
* [[_SNDCLOSE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -30,7 +30,7 @@ The [[CLS]] statement clears the [[_DEST|current write page]].
{{Cl|SCREEN}} 12
{{Cl|CLS}} , 15
{{Cl|_PRINTMODE }} _KEEPBACKGROUND 'keeps the text background visible
{{Cl|COLOR}} 0: {{Cl|PRINT}} "This is black text on a white background!"
{{Cl|COLOR}} 0: {{Cl|PRINT}} "This is black text on a white background!"
K$ = {{Cl|INPUT$}}(1
{{CodeEnd}}
:''Explanation:'' [[_PRINTMODE]] can be used with [[PRINT]] or [[_PRINTSTRING]] to make the text or the text background transparent.
@ -40,7 +40,7 @@ K$ = {{Cl|INPUT$}}(1
{{CodeStart}} '' ''
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
{{Cl|CLS}} , {{Cl|_RGB}}(0, 255, 0)
i = {{Cl|_LOADIMAGE}}('''"qb64_trans.png"''') 'see note below examples to get the image
i = {{Cl|_LOADIMAGE}}('''"qb64_trans.png"''') 'see note below examples to get the image
{{Cl|_PUTIMAGE}} (0, 0), i 'places image at upper left corner of window w/o stretching it
'' ''
{{CodeEnd}} '' ''
@ -56,4 +56,4 @@ i = {{Cl|_LOADIMAGE}}('''"qb64_trans.png"''') 'see note below examples
* [[_CLEARCOLOR]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -36,15 +36,15 @@ The [[COLOR]] statement is used to change the foreground and background colors f
* Colors can be mixed by using [[_BLEND]] (default) in 32-bit screen modes. [[_DONTBLEND]] disables blending.
* '''NOTE: Default 32-bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.'''
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
<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
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}} "Attribute = Hex value Red Green Blue "
{{Cl|PRINT}}
{{Cl|COLOR}} 7
{{Cl|FOR...NEXT|FOR}} attribute = 0 {{Cl|TO}} 15
@ -52,35 +52,35 @@ alpha$ = "FF" 'solid alpha colors only
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|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|PRINT}} "{{Cl|COLOR}}" + {{Cl|STR$}}(attribute) + " = " + hex32$, red$, grn$, blu$ 'returns closest attribute
{{Cl|NEXT}} '' ''
{{CodeEnd}}
{{OutputStart}}Attribute Hex value Red Green Blue
{{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}}
{{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}}
:''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.
:''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.
:'''Note:''' Black has a blue hex value of 50 due to the [[OUT]] background color setting which makes it dark blue.
@ -89,7 +89,7 @@ alpha$ = "FF" 'solid alpha colors only
* The same can be achieved using [[_PALETTECOLOR]] ('''recommended practice''').
:'''{{text|OUT &H3C7, attribute|green}}''' 'Set port to read RGB settings with:
:'''{{text|color_intensity <nowiki>=</nowiki> INP(&H3C9)|green}}''' 'reads present intensity setting
:'''{{text|color_intensity <nowiki>=</nowiki> INP(&H3C9)|green}}''' 'reads present intensity setting
:'''{{text|OUT &H3C8, attribute|green}}''' 'Set port to write RGB settings with:
:'''{{text|OUT &H3C9, color_intensity|green}}''' 'writes new intensity setting
@ -98,7 +98,7 @@ alpha$ = "FF" 'solid alpha colors only
* 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) in QBasic's legacy 4 and 8 bit screen modes.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
{{PageExamples}}
@ -134,7 +134,7 @@ alpha$ = "FF" 'solid alpha colors only
''Example 3:'' Printing in fullscreen SCREEN 0 mode with a color background under the text only.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 0: {{Cl|_FULLSCREEN}} ' used for fullscreen instead of window
{{Cl|COLOR}} 30, 6: {{Cl|LOCATE}} 12, 4: {{Cl|PRINT}} "Hello!" '' ''
{{Cl|COLOR}} 30, 6: {{Cl|LOCATE}} 12, 4: {{Cl|PRINT}} "Hello!" '' ''
{{CodeEnd}}
:''Result:'' Hello! is printed in flashing high intensity yellow with brown background behind text only when in Qbasic [[_FULLSCREEN|fullscreen]].
@ -143,7 +143,7 @@ alpha$ = "FF" 'solid alpha colors only
{{CodeStart}} '' ''
{{Cl|SCREEN}} 0: {{Cl|_FULLSCREEN}}
{{Cl|COLOR}} , 7: {{Cl|CLS}}
{{Cl|COLOR}} 9: {{Cl|PRINT}} "Hello" '' ''
{{Cl|COLOR}} 9: {{Cl|PRINT}} "Hello" '' ''
{{CodeEnd}}
{{TextStart}}{{text|Hello|blue}}{{TextEnd}}
:''Result:'' The blue word Hello is printed to a totally grey background in [[_FULLSCREEN|fullscreen]].
@ -152,16 +152,16 @@ alpha$ = "FF" 'solid alpha colors only
''Example 5:'' Using a different foreground color for each letter:
{{CodeStart}} '' ''
{{Cl|SCREEN}} 0
{{Cl|COLOR}} 1: {{Cl|PRINT}} "H";
{{Cl|COLOR}} 3: {{Cl|PRINT}} "E";
{{Cl|COLOR}} 4: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 5: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 6: {{Cl|PRINT}} "O"
{{Cl|COLOR}} 9: {{Cl|PRINT}} "W";
{{Cl|COLOR}} 11: {{Cl|PRINT}} "O";
{{Cl|COLOR}} 12: {{Cl|PRINT}} "R";
{{Cl|COLOR}} 13: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 14: {{Cl|PRINT}} "D" '' ''
{{Cl|COLOR}} 1: {{Cl|PRINT}} "H";
{{Cl|COLOR}} 3: {{Cl|PRINT}} "E";
{{Cl|COLOR}} 4: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 5: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 6: {{Cl|PRINT}} "O"
{{Cl|COLOR}} 9: {{Cl|PRINT}} "W";
{{Cl|COLOR}} 11: {{Cl|PRINT}} "O";
{{Cl|COLOR}} 12: {{Cl|PRINT}} "R";
{{Cl|COLOR}} 13: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 14: {{Cl|PRINT}} "D" '' ''
{{CodeEnd}}
{{OutputStart}}
@ -173,10 +173,10 @@ alpha$ = "FF" 'solid alpha colors only
''Example 6:'' Doing the same as Example 5 but in only a few lines:
{{CodeStart}} '' ''
{{Cl|SCREEN (statement)|SCREEN}} 0
text$ = "HelloWorld"
text$ = "HelloWorld"
{{Cl|FOR...NEXT|FOR}} textpos = 1 {{Cl|TO}} {{Cl|LEN}}(text$)
{{Cl|COLOR}} textpos
{{Cl|IF...THEN|IF}} textpos <> 5 {{Cl|THEN}} {{Cl|PRINT}} {{Cl|MID$}}(text$, textpos, 1);
{{Cl|IF...THEN|IF}} textpos <> 5 {{Cl|THEN}} {{Cl|PRINT}} {{Cl|MID$}}(text$, textpos, 1);
{{Cl|IF...THEN|IF}} textpos = 5 {{Cl|THEN}} {{Cl|PRINT}} {{Cl|MID$}}(text$, textpos, 1) 'start print on next row
{{Cl|NEXT}}
@ -193,7 +193,7 @@ text$ = "HelloWorld"
{{Cl|_PALETTECOLOR}} 0, _RGB32(255, 255, 255) 'change color 0 intensity
{{Cl|_PALETTECOLOR}} 8, _RGB32(0, 0, 0) 'change color 8 intensity
{{Cl|COLOR}} 8: {{Cl|PRINT}} "Black on bright white!" '' ''
{{Cl|COLOR}} 8: {{Cl|PRINT}} "Black on bright white!" '' ''
{{CodeEnd}}
{{WhiteStart}}'''{{text|Black on bright white!|#000000}}'''
{{WhiteEnd}}
@ -202,19 +202,21 @@ text$ = "HelloWorld"
''Example 8:'' Changing light gray text in [[SCREEN]] 0 to a 32 bit custom color using a [[LONG]] HTML hexadecimal value:
{{CodeStart}} '' ''
{{CodeStart
2b54
}} '' ''
{{Cl|COLOR}} 7
{{Cl|PRINT}} "Color 7 is gray"
{{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! '' ''
{{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.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
{{PageSeeAlso}}
@ -233,4 +235,4 @@ K$ = {{Cl|INPUT$}}(1)
* [http://www.w3schools.com/html/html_colornames.asp Hexadecimal Color Values]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -15,20 +15,20 @@ The '''COMMAND$''' function returns the command line argument(s) passed when a p
{{PageExamples}}
''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}} 12, 36: {{Cl|PRINT}} "ProgramA"
{{Cl|LOCATE}} 23, 25: {{Cl|PRINT}} "Press any key to run ProgramB"
{{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 or QB4.5
{{Cl|RUN}} "ProgramB FS" 'pass FS parameter to ProgramB in QB64 or QB4.5
{{Cl|SYSTEM}}
{{CodeEnd}}
: ''ProgramB'' checks for fullscreen parameter pass in QB64 and goes full screen.
{{CodeStart}} '' ''
{{Cl|LOCATE}} 17, 36: {{Cl|PRINT}} "ProgramB"
{{Cl|LOCATE}} 17, 36: {{Cl|PRINT}} "ProgramB"
parameter$ = {{Cl|UCASE$}}({{Cl|COMMAND$}}) 'UCASE$ is needed in 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|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}}
@ -50,14 +50,14 @@ parameter$ = {{Cl|UCASE$}}({{Cl|COMMAND$}}) 'UCASE$ is needed in QB64 only, as Q
{{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.
: ''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 syntax, you can also just read the array to see how many commands were sent (or simply check [[_COMMANDCOUNT]]):
{{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|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
@ -70,4 +70,4 @@ count = count - 1 'save the number of parameters sent to this program when run
* [[_COMMANDCOUNT]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -22,4 +22,4 @@
* [[DIM]], [[REDIM]], [[SHARED]]
* [[DEFSTR]], [[DEFLNG]], [[DEFINT]], [[DEFSNG]], [[DEFDBL]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -29,11 +29,11 @@ The [[CONST]] statement globally defines one or more named numeric or string val
{{Cl|CONST}} PI = 3.141593
' Declare some string constants:
{{Cl|CONST}} circumferenceText = "The circumference of the circle is"
{{Cl|CONST}} areaText = "The area of the circle is"
{{Cl|CONST}} circumferenceText = "The circumference of the circle is"
{{Cl|CONST}} areaText = "The area of the circle is"
{{Cl|DO...LOOP|DO}}
{{Cl|INPUT}} "Enter the radius of a circle or zero to quit"; radius
{{Cl|INPUT}} "Enter the radius of a circle or zero to quit"; radius
{{Cl|IF...THEN|IF}} radius = 0 {{Cl|IF...THEN|THEN}} {{Cl|END}}
{{Cl|PRINT}} circumferenceText; 2 * PI * radius
{{Cl|PRINT}} areaText; PI * radius * radius ' radius squared
@ -58,7 +58,7 @@ Enter the radius of a circle or zero to quit? ''0''
{{Cl|CONST}} Red = _RGB32(255,0,0)
{{Cl|COLOR}} Red
{{Cl|PRINT}} "Hello World"
{{Cl|PRINT}} "Hello World"
{{CodeEnd}}
{{PageSeeAlso}}
@ -68,4 +68,4 @@ Enter the radius of a circle or zero to quit? ''0''
* [http://doc.pcsoft.fr/en-US/?6510001 Windows 32 API constant values]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -21,20 +21,20 @@ The [[COS]] function returns the horizontal component or the cosine of an angle
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
PI = 4 * {{Cl|ATN}}(1)
{{Cl|PRINT}} "PI = 4 * {{Cl|ATN}}(1) ="; PI
{{Cl|PRINT}} "COS(PI) = "; {{Cl|COS}}(PI)
{{Cl|PRINT}} "SIN(PI) = "; {{Cl|SIN}}(PI)
{{Cl|PRINT}} "PI = 4 * {{Cl|ATN}}(1) ="; PI
{{Cl|PRINT}} "COS(PI) = "; {{Cl|COS}}(PI)
{{Cl|PRINT}} "SIN(PI) = "; {{Cl|SIN}}(PI)
{{Cl|DO...LOOP|DO}}
{{Cl|PRINT}}
{{Cl|INPUT}} "Enter the degree angle (0 quits): ", DEGREES%
{{Cl|INPUT}} "Enter the degree angle (0 quits): ", DEGREES%
RADIANS = DEGREES% * PI / 180
{{Cl|PRINT}} "RADIANS = DEGREES% * PI / 180 = "; RADIANS
{{Cl|PRINT}} "X = COS(RADIANS) = "; {{Cl|COS}}(RADIANS)
{{Cl|PRINT}} "Y = SIN(RADIANS) = "; {{Cl|SIN}}(RADIANS)
{{Cl|PRINT}} "RADIANS = DEGREES% * PI / 180 = "; RADIANS
{{Cl|PRINT}} "X = COS(RADIANS) = "; {{Cl|COS}}(RADIANS)
{{Cl|PRINT}} "Y = SIN(RADIANS) = "; {{Cl|SIN}}(RADIANS)
{{Cl|CIRCLE}} (400, 240), 2, 12
{{Cl|LINE}} (400, 240)-(400 + (50 * {{Cl|SIN}}(RADIANS)), 240 + (50 * {{Cl|COS}}(RADIANS))), 11
DEGREES% = RADIANS * 180 / PI
{{Cl|PRINT}} "DEGREES% = RADIANS * 180 / PI ="; DEGREES%
{{Cl|PRINT}} "DEGREES% = RADIANS * 180 / PI ="; DEGREES%
{{Cl|LOOP}} {{Cl|UNTIL}} DEGREES% = 0 '' ''
{{CodeEnd}}
{{OutputStart}}
@ -103,4 +103,4 @@ DEGREES% = RADIANS * 180 / PI = 45
*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -29,4 +29,4 @@
* [[_ROUND]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -17,12 +17,12 @@ The [[CSRLIN]] function returns the current text row position of the [[PRINT]] c
{{PageExamples}}
''Example:'' A semicolon stops the print cursor immediately after the print.
{{CodeStart}} '' ''
LOCATE 5, 5: PRINT "HELLO ";
LOCATE 5, 5: PRINT "HELLO ";
Y = {{Cl|CSRLIN}} 'save the row
X = {{Cl|POS}}(0) 'save the column
LOCATE 10, 10: PRINT "WORLD"
LOCATE 10, 10: PRINT "WORLD"
LOCATE Y, X 'restore saved position
PRINT "GOODBYE" '' ''
PRINT "GOODBYE" '' ''
{{CodeEnd}}
{{OutputStart}}
@ -39,7 +39,7 @@ The [[CSRLIN]] function returns the current text row position of the [[PRINT]] c
{{OutputEnd}}
:''Explanation:'' "HELLO " is printed and the semicolon stops the cursor immediately after the text. The [[CSRLIN]] variable records the current print cursor's text row in Y. The [[POS]] function records the current print cursor's text column in X. The second [[PRINT]] statement displays the comment "WORLD" on the 10th line of the screen. The last [[LOCATE]] statement restores the position of the cursor to the original line and column immediately after the first print.
:''Explanation:'' "HELLO " is printed and the semicolon stops the cursor immediately after the text. The [[CSRLIN]] variable records the current print cursor's text row in Y. The [[POS]] function records the current print cursor's text column in X. The second [[PRINT]] statement displays the comment "WORLD" on the 10th line of the screen. The last [[LOCATE]] statement restores the position of the cursor to the original line and column immediately after the first print.
{{PageSeeAlso}}
@ -47,4 +47,4 @@ The [[CSRLIN]] function returns the current text row position of the [[PRINT]] c
* [[_PRINTSTRING]] (graphic print)
{{PageNavigation}}
{{PageNavigation}}

View file

@ -25,10 +25,10 @@ Y# = {{Cl|CVD}}(N$) '' ''
''Example 2:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a# = 77000.24523213
{{Cl|PRINT}} "Value of a#:"; a#
{{Cl|PRINT}} "Value of a#:"; a#
b$ = {{Cl|MKD$}}(a#)
{{Cl|PRINT}} "Value of a# encoded using MKD$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVD:"; {{Cl|CVD}}(b$)
{{Cl|PRINT}} "Value of a# encoded using MKD$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVD:"; {{Cl|CVD}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a#: 77000.24523213
@ -47,4 +47,4 @@ The string above, decoded using CVD: 77000.24523213
* [[_CV]], [[_MK$]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -15,10 +15,10 @@ The [[CVDMBF]] function decodes an 8-byte [[STRING]] generated by [[MKDMBF$]] (o
''Example 1:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a# = 77000.24523213
{{Cl|PRINT}} "Value of a#:"; a#
{{Cl|PRINT}} "Value of a#:"; a#
b$ = {{Cl|MKDMBF$}}(a#)
{{Cl|PRINT}} "Value of a# encoded using MKDMBF$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVDMBF:"; {{Cl|CVDMBF}}(b$)
{{Cl|PRINT}} "Value of a# encoded using MKDMBF$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVDMBF:"; {{Cl|CVDMBF}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a#: 77000.24523213
@ -36,4 +36,4 @@ The string above, decoded using CVDMBF: 77000.24523213
* [[_CV]], [[_MK$]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -29,31 +29,31 @@ Y = {{Cl|CVI}}(N$) '' ''
{{Cl|DIM}} Q {{Cl|AS}} {{Cl|STRING}} * 1
Q = {{Cl|CHR$}}(34)
' create Print using templates to align the values returned
tmp1$ = "1st character code = ### * 1 = ### "
tmp2$ = "2nd character code = ### * 256 = ##### "
tmp3$ = " & "
tmp4$ = " CVI Total = ##### "
tmp1$ = "1st character code = ### * 1 = ### "
tmp2$ = "2nd character code = ### * 256 = ##### "
tmp3$ = " & "
tmp4$ = " CVI Total = ##### "
{{Cl|DO...LOOP|DO}}
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 13, 20: {{Cl|INPUT}} "Enter an Integer from 1 to 32767(0 quits): ", number%
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 13, 20: {{Cl|INPUT}} "Enter an Integer from 1 to 32767(0 quits): ", number%
{{Cl|IF...THEN|IF}} number% < 1 {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|CLS}}
ASCII$ = {{Cl|MKI$}}(number%) ' create the 2 byte character string
{{Cl|COLOR}} 11
{{Cl|_PRINTSTRING}} (152, 240), "{{Cl|MKI$}} creates 2 byte ASCII string: " + Q + ASCII$ + Q ' displays character(s)
{{Cl|_PRINTSTRING}} (152, 240), "{{Cl|MKI$}} creates 2 byte ASCII string: " + Q + ASCII$ + Q ' displays character(s)
asc1% = {{Cl|ASC}}(ASCII$) ' find the ASCII code values of each character
asc2% = {{Cl|ASC}}(ASCII$, 2) ' '''QB64''' allows ASC to read specific characters in a string
{{Cl|LOCATE}} 18, 20: {{Cl|PRINT USING}} tmp1$; asc1%; asc1%
{{Cl|LOCATE}} 19, 20: {{Cl|PRINT USING}} tmp2$; asc2%; asc2% * 256
{{Cl|LOCATE}} 20, 20: {{Cl|PRINT USING}} tmp3$; "-----"
{{Cl|LOCATE}} 20, 20: {{Cl|PRINT USING}} tmp3$; "-----"
{{Cl|LOCATE}} 21, 20: {{Cl|PRINT USING}} tmp4$; asc1% + (256 * asc2%)
{{Cl|LOOP}}
{{Cl|SYSTEM}} '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' All [[ASCII]] characters can be displayed using [[_PRINTSTRING]] . The routine gets the [[ASCII]] code, which is the actual value needed by [[CVI]]. The first byte code is always between 0 and 255. The second byte can return 0 thru 127 and CVI multiplies that value by 256. This proves that you cannot just feed a string number value to [[CVI]] and get the result desired. ("90" gets decoded to 12345).
:''Explanation:'' All [[ASCII]] characters can be displayed using [[_PRINTSTRING]] . The routine gets the [[ASCII]] code, which is the actual value needed by [[CVI]]. The first byte code is always between 0 and 255. The second byte can return 0 thru 127 and CVI multiplies that value by 256. This proves that you cannot just feed a string number value to [[CVI]] and get the result desired. ("90" gets decoded to 12345).
{{PageSeeAlso}}
@ -62,4 +62,4 @@ tmp4$ = " CVI Total = ##### "
* [[_CV]], [[_MK$]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -39,4 +39,4 @@ Y& = {{Cl|CVL}}(N$) '' ''
* [[_CV]], [[_MK$]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -15,10 +15,10 @@ The [[CVS]] function decodes a 4-byte [[STRING]] generated by [[MKS$]] (or read
''Example 1:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a! = 700.2213
{{Cl|PRINT}} "Value of a!:"; a!
{{Cl|PRINT}} "Value of a!:"; a!
b$ = {{Cl|MKDMBF$}}(a!)
{{Cl|PRINT}} "Value of a# encoded using MKS$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVS:"; {{Cl|CVS}}(b$)
{{Cl|PRINT}} "Value of a# encoded using MKS$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVS:"; {{Cl|CVS}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a!: 700.2213
@ -34,4 +34,4 @@ The string above, decoded using CVS: 700.2213
* [[_CV]], [[_MK$]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -15,10 +15,10 @@ The [[CVDMBF]] function decodes a 4-byte [[STRING]] generated by [[MKSMBF$]] (or
''Example 1:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a! = 700.2213
{{Cl|PRINT}} "Value of a!:"; a!
{{Cl|PRINT}} "Value of a!:"; a!
b$ = {{Cl|MKSMBF$}}(a!)
{{Cl|PRINT}} "Value of a! encoded using MKSMBF$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVSMBF:"; {{Cl|CVDMBF}}(b$)
{{Cl|PRINT}} "Value of a! encoded using MKSMBF$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVSMBF:"; {{Cl|CVDMBF}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a!: 700.2213
@ -34,4 +34,4 @@ The string above, decoded using CVSMBF: 700.2213
* [[_CV]], [[_MK$]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -1,7 +1,7 @@
A '''colon''' can be used to separate two unrelated procedure statements on the same line.
''Usage:'' COLOR 10: PRINT "Hello "; : COLOR 12: PRINT "World"
''Usage:'' COLOR 10: PRINT "Hello "; : COLOR 12: PRINT "World"
{{OutputStart}}
{{text|Hello |limegreen}}{{text|World|red}}
@ -19,4 +19,4 @@ A '''colon''' can be used to separate two unrelated procedure statements on the
* [[Comma]], [[Semicolon]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -17,7 +17,7 @@ The [[DATA]] statement creates a line of fixed program information separated by
* [[STRING]] DATA values with end spaces, QBasic keywords and values that include the comma character must be enclosed in 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.
* If a [[READ]] statement attempts to read past the last data value, an [[ERROR Codes|"Out of Data" error]] will occur. Use end of data markers when necessary.
* If a [[READ]] statement attempts to read past the last data value, an [[ERROR Codes|"Out of Data" error]] will occur. Use end of data markers when necessary.
* '''[[DATA]] fields can be placed after [[SUB]] or [[FUNCTION]] procedures, but line labels are not allowed.'''
@ -41,7 +41,7 @@ Database1:
{{Cl|DATA}} 2, 0, 0, 2, 2, 0, 2, 2, 2 : ' DATA line comments require a colon
Database2:
{{Cl|DATA}} "Hello, ", "world! ", Goodbye, work! '' ''
{{Cl|DATA}} "Hello, ", "world! ", Goodbye, work! '' ''
{{CodeEnd}}
{{OutputStart}}Hello world! Goodbyework!
1 0 0 1 1 0 1 1 1 2 0 0 2 2 0 2 2 2
@ -78,4 +78,4 @@ mydata2:
* [[SUB]], [[FUNCTION]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -1,4 +1,4 @@
The [[DATE$]] function returns the current computer date as a string in the format "mm-dd-yyyy".
The [[DATE$]] function returns the current computer date as a string in the format "mm-dd-yyyy".
{{PageSyntax}}
@ -6,7 +6,7 @@ The [[DATE$]] function returns the current computer date as a string in the form
{{PageDescription}}
* Returns the current computer date in the format "mm-dd-yyyy" (e.g., "12-25-2009").
* Returns the current computer date in the format "mm-dd-yyyy" (e.g., "12-25-2009").
{{PageExamples}}
@ -18,20 +18,20 @@ day$ = {{Cl|MID$}}({{Cl|DATE$}}, 4, 2): D = {{Cl|VAL}}(day$)
day$ = {{Cl|STR$}}(D) ' eliminate any leading zeros
year$ = {{Cl|RIGHT$}}({{Cl|DATE$}}, 4): Y = {{Cl|VAL}}(year$)
{{Cl|SELECT CASE}} M
{{Cl|CASE}} 1: Moon$ = "January"
{{Cl|CASE}} 2: Moon$ = "February"
{{Cl|CASE}} 3: Moon$ = "March"
{{Cl|CASE}} 4: Moon$ = "April"
{{Cl|CASE}} 5: Moon$ = "May"
{{Cl|CASE}} 6: Moon$ = "June"
{{Cl|CASE}} 7: Moon$ = "July"
{{Cl|CASE}} 8: Moon$ = "August"
{{Cl|CASE}} 9: Moon$ = "September"
{{Cl|CASE}} 10: Moon$ = "October"
{{Cl|CASE}} 11: Moon$ = "November"
{{Cl|CASE}} 12: Moon$ = "December"
{{Cl|CASE}} 1: Moon$ = "January"
{{Cl|CASE}} 2: Moon$ = "February"
{{Cl|CASE}} 3: Moon$ = "March"
{{Cl|CASE}} 4: Moon$ = "April"
{{Cl|CASE}} 5: Moon$ = "May"
{{Cl|CASE}} 6: Moon$ = "June"
{{Cl|CASE}} 7: Moon$ = "July"
{{Cl|CASE}} 8: Moon$ = "August"
{{Cl|CASE}} 9: Moon$ = "September"
{{Cl|CASE}} 10: Moon$ = "October"
{{Cl|CASE}} 11: Moon$ = "November"
{{Cl|CASE}} 12: Moon$ = "December"
{{Cl|END SELECT}}
{{Cl|PRINT}} "Today is " + WeekDay$(M, D, Y) + ", " + Moon$ + day$ + ", " + year$ + {{Cl|SPACE$}}(10)
{{Cl|PRINT}} "Today is " + WeekDay$(M, D, Y) + ", " + Moon$ + day$ + ", " + year$ + {{Cl|SPACE$}}(10)
{{Cl|DEFINT}} A-Z
{{Cl|FUNCTION}} WeekDay$ (M, D, Y)
@ -43,13 +43,13 @@ S3 = 26 * (M + 1) \ 10 'days in months
WkDay = (S1 + S2 + S3 + D) {{Cl|MOD}} 7 'weekday total remainder
{{Cl|IF}} WkDay < 0 {{Cl|THEN}} WkDay = WkDay + 7 'Adjust negative results to 0 to 6
{{Cl|SELECT CASE}} WkDay
{{Cl|CASE}} 0: day$ = "Sunday"
{{Cl|CASE}} 1: day$ = "Monday"
{{Cl|CASE}} 2: day$ = "Tuesday"
{{Cl|CASE}} 3: day$ = "Wednesday"
{{Cl|CASE}} 4: day$ = "Thursday"
{{Cl|CASE}} 5: day$ = "Friday"
{{Cl|CASE}} 6: day$ = "Saturday"
{{Cl|CASE}} 0: day$ = "Sunday"
{{Cl|CASE}} 1: day$ = "Monday"
{{Cl|CASE}} 2: day$ = "Tuesday"
{{Cl|CASE}} 3: day$ = "Wednesday"
{{Cl|CASE}} 4: day$ = "Thursday"
{{Cl|CASE}} 5: day$ = "Friday"
{{Cl|CASE}} 6: day$ = "Saturday"
{{Cl|END SELECT}}
WeekDay$ = day$
{{Cl|END FUNCTION}} '' ''
@ -67,4 +67,4 @@ Today is Wednesday, June 2, 2010
{{PageNavigation}}
{{PageNavigation}}

View file

@ -14,7 +14,7 @@ The [[DATE$]] statement sets the current computer date to another [[STRING]] val
::::mm/dd/yyyy
* String expression or variable must contain the month, day and 4 digit year to be changed (10 valid characters).
* If value is not a valid formatted string, a "Type Mismatch" error results. The previous DATE$ value will be retained.
* If value is not a valid formatted string, a "Type Mismatch" error results. The previous DATE$ value will be retained.
* The current date (as assigned when the operating system was initialized) can be saved to restore later with the [[DATE$]] function.
*The DATE$ function returns a 10-character string in the form ''mm-dd-yyyy''. ''mm'' is the month (01 to 12), ''dd'' is the day (01 to 31), and ''yyyy'' is the four digit year.
* '''Note: Some systems may not allow the DATE to be reset or require Administrator privileges.''' Try a batch file or [[SHELL]].
@ -26,9 +26,9 @@ The [[DATE$]] statement sets the current computer date to another [[STRING]] val
{{CodeStart}}
today$ = {{Cl|DATE$}} ' function saves current computer date value
PRINT today$ ' verify actual date
{{Cl|DATE$ (statement)|DATE$}} = "12-25-2000" ' literal statement changes date
{{Cl|DATE$ (statement)|DATE$}} = "12-25-2000" ' literal statement changes date
PRINT {{Cl|DATE$}} ' verify new date setting
{{Cl|SHELL}} "CMD /C " + programfile$ 'run old program
{{Cl|SHELL}} "CMD /C " + programfile$ 'run old program
K$ = {{Cl|INPUT$}}(1) ' press a key
DATE$ = today$ ' statement resets computer to original date later in program
PRINT {{Cl|DATE$}} ' verify present setting
@ -46,4 +46,4 @@ The [[DATE$]] statement sets the current computer date to another [[STRING]] val
[[DATE$]], [[TIME$]], [[TIME$ (statement)]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -28,4 +28,4 @@ The '''DECLARE''' statement is used to tell Qbasic that a [[SUB]] or [[FUNCTION]
* [[DECLARE LIBRARY]] (QB64 ONLY)
{{PageNavigation}}
{{PageNavigation}}

View file

@ -8,7 +8,7 @@ Declares calling sequences for external procedures written in other languages.
{{PageSyntax}}
: [[DECLARE]] {[[SUB]]|[[FUNCTION]]} name [ [[CDECL]] ] [ [[ALIAS]] "aliasname"] [([parameterlist, ...])]
: [[DECLARE]] {[[SUB]]|[[FUNCTION]]} name [ [[CDECL]] ] [ [[ALIAS]] "aliasname"] [([parameterlist, ...])]
* [[CDECL]] indicates that the procedure uses the C language argument order.
@ -25,4 +25,4 @@ Declares calling sequences for external procedures written in other languages.
{{PageNavigation}}
{{PageNavigation}}

View file

@ -2,7 +2,7 @@
{{PageSyntax}}
: DECLARE [DYNAMIC|CUSTOMTYPE|STATIC] LIBRARY [''"DLL_Library_file"'', "other_library..."]
: DECLARE [DYNAMIC|CUSTOMTYPE|STATIC] LIBRARY [''"DLL_Library_file"'', "other_library..."]
: {SUB|FUNCTION} [''procedure_name'' ALIAS] ''library_procedure'' (BYVAL ''parameter(s)'',...)
::.
::. 'other Library sub-procedures for named ''DLL''
@ -35,10 +35,10 @@
{{PageExamples}}
''Example 1:'' This example plays Midi files using the ''playmidi32.dll'' documented here: [http://libertybasicuniversity.com/lbnews/nl110/midi3.htm Liberty Basic University].                         Download the following DLL file to your main QB64 folder: [http://www.qb64.net/playmidi32.dll PlayMidi32.dll]
{{CodeStart}} '' ''
{{Cl|DECLARE DYNAMIC LIBRARY}} "playmidi32"
{{Cl|DECLARE DYNAMIC LIBRARY}} "playmidi32"
{{Cl|FUNCTION}} PlayMIDI& (filename {{Cl|AS}} {{Cl|STRING}})
{{Cl|DECLARE LIBRARY|END DECLARE}}
result = PlayMIDI(".\samples\qb64\original\ps2battl.mid" + {{Cl|CHR$}}(0))
result = PlayMIDI(".\samples\qb64\original\ps2battl.mid" + {{Cl|CHR$}}(0))
{{Cl|PRINT}} result
{{CodeEnd}}
: '''Note:''' Filename needs to be [[CHR$]](0) terminated. QB64 [[STRING]]s are passed to external libraries as pointers to first character.
@ -57,14 +57,14 @@ result = PlayMIDI(".\samples\qb64\original\ps2battl.mid" + {{Cl|CHR$}}
FileName$ = {{Cl|SPACE$}}(512)
Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$))
{{Cl|IF...THEN|IF}} Result {{Cl|THEN}} {{Cl|PRINT}} "CURRENT PROGRAM (ASCII): "; {{Cl|LEFT$}}(FileName$, Result)
{{Cl|IF...THEN|IF}} Result {{Cl|THEN}} {{Cl|PRINT}} "CURRENT PROGRAM (ASCII): "; {{Cl|LEFT$}}(FileName$, Result)
'load a unicode font
f = {{Cl|_LOADFONT}}("cyberbit.ttf", 24, "UNICODE")
f = {{Cl|_LOADFONT}}("cyberbit.ttf", 24, "UNICODE")
{{Cl|_FONT}} f
Result = GetModuleFileNameW(0, FileName$, {{Cl|LEN}}(FileName$) \ 2)
{{Cl|LOCATE}} 2, 1
{{Cl|PRINT}} QuickCP437toUTF32$("CURRENT PROGRAM (UTF): ") + QuickUTF16toUTF32$({{Cl|LEFT$}}(FileName$, Result * 2))
{{Cl|PRINT}} QuickCP437toUTF32$("CURRENT PROGRAM (UTF): ") + QuickUTF16toUTF32$({{Cl|LEFT$}}(FileName$, Result * 2))
{{Cl|_FONT}} 16 'restore CP437 font
{{Cl|FUNCTION}} QuickCP437toUTF32$ (a$)
@ -85,11 +85,11 @@ QuickUTF16toUTF32$ = b$
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{small|Code by Galleon}}
: '''Note:''' SUB procedures using CUSTOMTYPE LIBRARY API procedures inside may error. Try DYNAMIC with "KERNEL32".
: '''Note:''' SUB procedures using CUSTOMTYPE LIBRARY API procedures inside may error. Try DYNAMIC with "KERNEL32".
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''
@ -101,4 +101,4 @@ QuickUTF16toUTF32$ = b$
* [[Port Access Libraries]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -2,7 +2,7 @@ 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
@ -60,7 +60,7 @@ SDL_WarpMouse x, y 'call SDL library procedure
{{small|Code by Galleon}}
:''Explanation:'' The SDL Library is included and loaded with QB64 versions prior to 1.000, so these procedures are directly available for use.
<center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''</center>
<center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''</center>
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|DECLARE LIBRARY}}
@ -77,18 +77,18 @@ MouseMove 200, 200 '' ''
''Example 2:'' Don't know if a C function is defined by C++ or QB64? Try using empty quotes.
{{CodeStart}} '' ''
{{Cl|DECLARE LIBRARY}} ""
{{Cl|DECLARE LIBRARY}} ""
{{Cl|FUNCTION}} addone& ({{Cl|BYVAL}} value&)
{{Cl|END}} DECLARE '' ''
{{CodeEnd}}
:''Explanation:'' The C function 'addone' exists in a library QB64 already links to, but it hasn't been defined as a C function or a QB64 function. By using "" we are telling QB64 the function exists in a library which is already linked to and that it must define the C function before calling it, as well as allowing QB64 code to call it. Trying the above code without the "" will fail.
:''Explanation:'' The C function 'addone' exists in a library QB64 already links to, but it hasn't been defined as a C function or a QB64 function. By using "" we are telling QB64 the function exists in a library which is already linked to and that it must define the C function before calling it, as well as allowing QB64 code to call it. Trying the above code without the "" will fail.
: '''Note: What libraries are or aren't automatically used in the linking process is not formally defined, nor is it guaranteed to stay that way in future versions of QB64.'''
''Example 3:'' For this next example, download the file 'add.lib' and place it in you QB64 folder: http://www.qb64.net/add.lib
{{CodeStart}} '' ''
{{Cl|DECLARE LIBRARY}} "add"
{{Cl|DECLARE LIBRARY}} "add"
{{Cl|FUNCTION}} addtwo& ({{Cl|BYVAL}} value&)
{{Cl|END}} DECLARE
PRINT addtwo(1) '' ''
@ -99,26 +99,26 @@ PRINT addtwo(1) '' ''
''Example 4:'' NTport is a commercial library hosted at http://www.zealsoftstudio.com/ntport/, but it does provide an evaluation version (it has a 3 second wait pop-up window) which we will use here. You don't need to download NTport, just download the following 3 files and put them in your QB64 folder:
<center>[http://www.qb64.net/ntport/ntport.lib NTport.lib]            [http://www.qb64.net/ntport/ntport.h NTport.h]               [http://www.qb64.net/ntport/ntport.dll Ntport.dll]</center>
<center>[http://www.qb64.net/ntport/ntport.lib NTport.lib]            [http://www.qb64.net/ntport/ntport.h NTport.h]               [http://www.qb64.net/ntport/ntport.dll Ntport.dll]</center>
:'''IMPORTANT:''' The DLL is loaded automatically by the static library, we are not linking directly to the DLL, we are '''static linking''' (NOT directly or dynamically linking). This is an important concept to understand!
{{CodeStart}}
DECLARE LIBRARY "ntport"
DECLARE LIBRARY "ntport"
FUNCTION GetLPTPortAddress% (BYVAL PortNo%)
END DECLARE
PRINT "&H" + HEX$(GetLPTPortAddress%(1))
PRINT "&H" + HEX$(GetLPTPortAddress%(1))
{{CodeEnd}}
:''Explanation:'' DECLARE LIBRARY also searches for C header files with a '''.h''' extension. So in this case it is using the header '''ntport.h''' and linking with '''ntport.lib''' just by specifying "NTPORT". The C function definitions are stored in '''ntport.h''' so even if our QB64 functions don't exactly match (eg. LONG instead of INTEGER) it will still work.
:''Explanation:'' DECLARE LIBRARY also searches for C header files with a '''.h''' extension. So in this case it is using the header '''ntport.h''' and linking with '''ntport.lib''' just by specifying "NTPORT". The C function definitions are stored in '''ntport.h''' so even if our QB64 functions don't exactly match (eg. LONG instead of INTEGER) it will still work.
:If you look inside ''''ntport.h'''' you'll find the following line containing the C function definition of the command we used:
{{TextStart}} WORD WINAPI GetLPTPortAddress(WORD PortNo);
{{TextEnd}}
<center>Galleon's '''OpenGL''' Library with demo program download: http://www.qb64.net/gl_package.zip</center>
<center>Galleon's '''OpenGL''' Library with demo program download: http://www.qb64.net/gl_package.zip</center>
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''
@ -133,4 +133,4 @@ PRINT "&H" + HEX$(GetLPTPortAddress%(1))
* [http://www.qb64.net/forum/index.php?topic=11810.msg102081#msg102081 DECLARE LIBRARY and C++ Variable Types]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -19,7 +19,7 @@ The [[DEFDBL]] statement defines all variables with names starting with the spec
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
{{PageExamples}}
@ -37,4 +37,4 @@ The [[DEFDBL]] statement defines all variables with names starting with the spec
* [[_DEFINE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -20,7 +20,7 @@ The [[DEFINT]] statement defines all variables with names starting with the spec
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
{{PageExamples}}
@ -38,4 +38,4 @@ The [[DEFINT]] statement defines all variables with names starting with the spec
* [[_DEFINE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -20,7 +20,7 @@ The [[DEFLNG]] statement defines all variables with names starting with the spec
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
{{PageExamples}}
@ -38,4 +38,4 @@ The [[DEFLNG]] statement defines all variables with names starting with the spec
* [[_DEFINE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -20,7 +20,7 @@ The [[DEFSNG]] statement defines all variables with names starting with the spec
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
{{PageExamples}}
@ -38,4 +38,4 @@ The [[DEFSNG]] statement defines all variables with names starting with the spec
* [[_DEFINE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -19,7 +19,7 @@ The [[DEFSTR]] statement defines all variables with names starting with the spec
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) 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 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.
{{PageExamples}}
@ -37,4 +37,4 @@ The [[DEFSTR]] statement defines all variables with names starting with the spec
* [[_DEFINE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -81,4 +81,4 @@ The '''DEF FN''' statement defines a non-recursive function in the main module t
* [[_DEFINE]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -21,7 +21,7 @@
{{PageExamples}}
''Example:'' In a Qbasic(ONLY) file delete, '''SEG''' forces the parameter to be passed as a far pointer.
{{CodeStart}} '' ''
{{Cl|CONST}} file = "trashme.tmp" 'example temporary file name to delete
{{Cl|CONST}} file = "trashme.tmp" 'example temporary file name to delete
{{Cl|DEFINT}} A-Z
{{Cl|DIM}} filename {{Cl|AS}} {{Cl|STRING}}
{{Cl|DIM}} result {{Cl|AS}} {{Cl|LONG}}
@ -32,19 +32,19 @@
{{Cl|CLS}}
t = "5589E51E8B560C8EDA8B5E0A8B5702B441CD218B56088EDA8B5E06720B6631C0"
t = t + "6689071F5DCA0800660D0000FFFFEBF0"
t = "5589E51E8B560C8EDA8B5E0A8B5702B441CD218B56088EDA8B5E06720B6631C0"
t = t + "6689071F5DCA0800660D0000FFFFEBF0"
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} codelen - 1
{{Cl|MID$}}(code, i + 1, 1) = {{Cl|CHR$}}({{Cl|VAL}}("&h" + {{Cl|MID$}}(t, i + i + 1, 2)))
{{Cl|MID$}}(code, i + 1, 1) = {{Cl|CHR$}}({{Cl|VAL}}("&h" + {{Cl|MID$}}(t, i + i + 1, 2)))
{{Cl|NEXT}}
{{Cl|OPEN}} file {{Cl|FOR...NEXT|FOR}} {{Cl|APPEND}} {{Cl|AS}} 1 'create temporary file
{{Cl|PRINT (file statement)|PRINT}} #1, "I am doomed! :-("
{{Cl|PRINT (file statement)|PRINT}} #1, "I am doomed! :-("
{{Cl|CLOSE}}
{{Cl|PRINT}} "now you see it:"
{{Cl|SHELL}} "dir " + file
{{Cl|PRINT}} "now you see it:"
{{Cl|SHELL}} "dir " + file
K$ = {{Cl|INPUT$}}(1)
filename = file + {{Cl|CHR$}}(0) 'create zero string name for DOS
@ -52,15 +52,15 @@ filename = file + {{Cl|CHR$}}(0) 'create zero string name for DOS
{{Cl|CALL}} absolute('''SEG''' filename, '''SEG''' result, {{Cl|VARPTR}}(code))
{{Cl|IF...THEN|IF}} result {{Cl|THEN}} 'check results
{{Cl|PRINT}} "oops. error: 0x"; {{Cl|HEX$}}(result {{Cl|AND (boolean)|AND}} {{Cl|&H}}FFFF&)
{{Cl|PRINT}} "oops. error: 0x"; {{Cl|HEX$}}(result {{Cl|AND (boolean)|AND}} {{Cl|&H}}FFFF&)
{{Cl|ELSE}}
{{Cl|PRINT}} "now you don't:"
{{Cl|PRINT}} "now you don't:"
{{Cl|END IF}}
{{Cl|SHELL}} "dir " + file
{{Cl|SHELL}} "dir " + file
{{Cl|END}} '' ''
{{CodeEnd}}
{{small|Code by Michael Calkins as Public Domain(2011)}}
-->
-->
''See also:''
* [[DEF SEG = 0]]
@ -69,4 +69,4 @@ filename = file + {{Cl|CHR$}}(0) 'create zero string name for DOS
* [[BSAVE]], [[BLOAD]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -34,7 +34,7 @@ The [[DIM]] statement is used to declare a variable or a list of variables as a
* [[$DYNAMIC|Dynamic]] arrays MUST be [[REDIM]]ensioned if [[ERASE]] or [[CLEAR]] are used, as the arrays are completely removed.
* All numerical variable types '''except''' {{KW|SINGLE}}, {{KW|DOUBLE}} and {{KW|_FLOAT}} can be dimensioned as [[_UNSIGNED]] (suffix ~) or positive only.
* '''NOTE:''' Many QBasic keyword variable names can be used with a [[STRING]] suffix ($). You cannot use them without the suffix, use a numerical suffix or use ''DIM, [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]]'' statements. '''Although possible, it's recommended to avoid using reserved names.'''
* '''Warning: Do not use negative array upper bound index values, or OS access or "Out of Memory" [[ERROR Codes|errors]] will occur.'''
* '''Warning: Do not use negative array upper bound index values, or OS access or "Out of Memory" [[ERROR Codes|errors]] will occur.'''
{{PageExamples}}
@ -64,7 +64,7 @@ The [[DIM]] statement is used to declare a variable or a list of variables as a
{{CodeEnd}}
''Example 6:'' QB64 is more flexible than QBasic when it comes to "Duplicate Definition" errors. The following code does not error:
''Example 6:'' QB64 is more flexible than QBasic when it comes to "Duplicate Definition" errors. The following code does not error:
{{CodeStart}} '' ''
x = 1 'x is a {{Cl|SINGLE}} variable
{{Cl|PRINT}} x
@ -74,7 +74,7 @@ x = 1 'x is a {{Cl|SINGLE}} variable
: ''Explanation:'' The [[SINGLE]] variable can be differentiated from the [[LONG]] x variable by using suffixes like x! or x& in later code.
''Example 7:'' The following code will create a "Name already in use" '''[[IDE|status error]]''' in QB64 when the variable types are the same.
''Example 7:'' The following code will create a "Name already in use" '''[[IDE|status error]]''' in QB64 when the variable types are the same.
{{CodeStart}} '' ''
x = 1 'x is a {{Cl|SINGLE}} variable
{{Cl|PRINT}} x
@ -94,4 +94,4 @@ x = 1 'x is a {{Cl|SINGLE}} variable
* [[OPTION _EXPLICIT]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -3,11 +3,11 @@ The [[_DIR$]] function returns common paths in '''Windows''' only such as My Doc
{{PageSyntax}}
: {{Parameter|d$}} = [[_DIR$]]("{{Parameter|folderspecification}}")
: {{Parameter|d$}} = [[_DIR$]]("{{Parameter|folderspecification}}")
{{Parameters}}
* ''folderspecification'' may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data".
* ''folderspecification'' may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data".
* Some variation is accepted for the folder specification:
:: MY DOCUMENTS, TEXT, DOCUMENT, DOCUMENTS, DOWNLOAD, DOWNLOADS
:: MY MUSIC, MUSIC, AUDIO, SOUND, SOUNDS
@ -19,19 +19,19 @@ The [[_DIR$]] function returns common paths in '''Windows''' only such as My Doc
{{PageDescription}}
* The path returned ends with a backslash (Windows).
* A nonexistent folder specification usually defaults to the Desktop folder path.
* In Linux and macOS the function always returns '''"./"'''
* In Linux and macOS the function always returns '''"./"'''
{{PageExamples}}
Example: Displaying default paths in Windows only.
{{CodeStart}}{{Cl|PRINT}} "DESKTOP=" + _DIR$("desktop")
{{Cl|PRINT}} "DOWNLOADS=" + {{Cl|_DIR$}}("download")
{{Cl|PRINT}} "DOCUMENTS=" + {{Cl|_DIR$}}("my documents")
{{Cl|PRINT}} "PICTURES=" + {{Cl|_DIR$}}("pictures")
{{Cl|PRINT}} "MUSIC=" + {{Cl|_DIR$}}("music")
{{Cl|PRINT}} "VIDEO=" + {{Cl|_DIR$}}("video")
{{Cl|PRINT}} "APPLICATION DATA=" + {{Cl|_DIR$}}("data")
{{Cl|PRINT}} "LOCAL APPLICATION DATA=" + {{Cl|_DIR$}}("local application data"
{{CodeStart}}{{Cl|PRINT}} "DESKTOP=" + _DIR$("desktop")
{{Cl|PRINT}} "DOWNLOADS=" + {{Cl|_DIR$}}("download")
{{Cl|PRINT}} "DOCUMENTS=" + {{Cl|_DIR$}}("my documents")
{{Cl|PRINT}} "PICTURES=" + {{Cl|_DIR$}}("pictures")
{{Cl|PRINT}} "MUSIC=" + {{Cl|_DIR$}}("music")
{{Cl|PRINT}} "VIDEO=" + {{Cl|_DIR$}}("video")
{{Cl|PRINT}} "APPLICATION DATA=" + {{Cl|_DIR$}}("data")
{{Cl|PRINT}} "LOCAL APPLICATION DATA=" + {{Cl|_DIR$}}("local application data"
{{CodeEnd}}
{{OutputStart}}DESKTOP=C:\Documents and Settings\Administrator\Desktop\
DOWNLOADS=C:\Documents and Settings\Administrator\Downloads\
@ -49,4 +49,4 @@ LOCAL APPLICATION DATA=C:\Documents and Settings\Administrator\Local Settings\Ap
* [[_STARTDIR$]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -36,9 +36,9 @@
''Example 1:'' Using WHILE to clear the keyboard buffer.
{{CodeStart}}
DO WHILE {{Cl|INKEY$}} <> "": LOOP ' checks evaluation before running loop code
DO WHILE {{Cl|INKEY$}} <> "": LOOP ' checks evaluation before running loop code
DO: LOOP WHILE INKEY$ <> "" ' checks evaluation after one run of loop code
DO: LOOP WHILE INKEY$ <> "" ' checks evaluation after one run of loop code
{{CodeEnd}}
@ -46,9 +46,9 @@ DO: LOOP WHILE INKEY$ <> "" ' checks evaluation after one run of
''Example 2:'' Using UNTIL to clear the keyboard buffer.
{{CodeStart}}
DO UNTIL {{Cl|INKEY$}} = "": LOOP ' checks evaluation before running loop code
DO UNTIL {{Cl|INKEY$}} = "": LOOP ' checks evaluation before running loop code
DO: LOOP UNTIL {{Cl|INKEY$}} = "" ' checks evaluation after one run of loop code
DO: LOOP UNTIL {{Cl|INKEY$}} = "" ' checks evaluation after one run of loop code
{{CodeEnd}}
@ -57,7 +57,7 @@ DO: LOOP UNTIL {{Cl|INKEY$}} = "" ' checks evaluation after one run of
:SUB reads header contents of a [[BSAVE]] file that may include embedded RGB color settings before the image.
{{CodeStart}} '' ''
{{Cl|DEFINT}} A-Z
{{Cl|INPUT}} "Enter a BSAVE file name to read the file for screen mode:"', filenm$
{{Cl|INPUT}} "Enter a BSAVE file name to read the file for screen mode:"', filenm$
CheckScreen filenm$
{{Cl|END}}
@ -73,33 +73,33 @@ CheckScreen filenm$
{{Cl|GET}} #1, , Bsv '1 check for small 2 character
GET #1, , Header '2 - 7 rest of file header
IF Bsv <> {{Cl|CHR$}}(253) THEN ' small 2 character denotes a {{Cl|BSAVE}} file
COLOR 12: LOCATE 15, 33: PRINT "Not a BSAVE file!": SLEEP 3: {{Cl|EXIT}} SUB
IF Bsv <> {{Cl|CHR$}}(253) THEN ' small 2 character denotes a {{Cl|BSAVE}} file
COLOR 12: LOCATE 15, 33: PRINT "Not a BSAVE file!": SLEEP 3: {{Cl|EXIT}} SUB
END IF
GET #1, , widN '8 no color info bmp sizes
GET #1, , depN '9 " " "
GET #1, , depN '9 " " "
DO
IF widN > 63 OR depN > 63 THEN {{Cl|EXIT DO}} ' width and depth already found
IF widN > 63 OR depN > 63 THEN {{Cl|EXIT DO}} ' width and depth already found
FOR i = 10 TO 55 'check for Screen 12 embedded colors
GET #1, , RGB
tot12& = tot12& + RGB
'PRINT i; RGB; : SOUND 300, 1 'test sound slows loop in QB
IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}}
IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}}
IF i = 55 AND tot12& = 0 THEN {{Cl|EXIT DO}}
NEXT
GET #1, , wid12 '56
GET #1, , dep12 '57
IF wid12 > 63 OR dep12 > 63 THEN {{Cl|EXIT DO}}
IF wid12 > 63 OR dep12 > 63 THEN {{Cl|EXIT DO}}
FOR i = 58 TO 775 'check for Screen 13 embedded colors
GET #1, , RGB
tot13& = tot13& + RGB
'PRINT i; RGB; : SOUND 300, 1 'test
IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}}
IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}}
IF i = 775 AND tot13& = 0 THEN {{Cl|EXIT DO}}
NEXT
GET #1, , wid13 '776
@ -110,24 +110,24 @@ CLOSE #1
COLOR 14: LOCATE 10, 25
{{Cl|SELECT CASE}} i
{{Cl|CASE IS}} < 56:
IF widN > 640 THEN
IF widN > 640 THEN
Scr = 13: MaxColors = 0
PRINT "Default Screen 13:"; widN \ 8; "X"; depN
PRINT "Default Screen 13:"; widN \ 8; "X"; depN
ELSE
LOCATE 10, 15
PRINT "Screen 12 ("; widN; "X"; depN; ") OR 13 ("; widN \ 8; "X"; depN; ")"
PRINT "Screen 12 ("; widN; "X"; depN; ") OR 13 ("; widN \ 8; "X"; depN; ")"
DO: SOUND 600, 4
COLOR 13: LOCATE 12, 23 'ask if no data found. Prevents ERROR opening in wrong mode
{{Cl|INPUT}} "Enter a Screen mode 12 or 13 : ", Scrn$
{{Cl|INPUT}} "Enter a Screen mode 12 or 13 : ", Scrn$
Scr = VAL(Scrn$)
LOOP UNTIL Scr = 12 OR Scr = 13
END IF
IF Scr = 12 THEN MaxColors = 0: PWidth = widN: PDepth = depN
IF Scr = 13 THEN MaxColors = 0: PWidth = widN \ 8: PDepth = depN
{{Cl|CASE}} 56 TO 775
PRINT "Custom Screen 12:"; wid12; "X"; dep12
PRINT "Custom Screen 12:"; wid12; "X"; dep12
Scr = 12: MaxColors = 16: PWidth = wid12: PDepth = dep12
{{Cl|CASE}} 776: PRINT "Custom Screen 13:"; wid13 \ 8; "X"; dep13
{{Cl|CASE}} 776: PRINT "Custom Screen 13:"; wid13 \ 8; "X"; dep13
Scr = 13: MaxColors = 256: PWidth = wid13 \ 8: PDepth = dep13
{{Cl|END SELECT}}
@ -147,4 +147,4 @@ COLOR 14: LOCATE 10, 25
* [[FOR...NEXT]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -28,4 +28,4 @@
* [[Variable Types]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -13,28 +13,28 @@ The [[DRAW]] statement uses a [[STRING]] expression to draw lines on the screen.
* 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 after a valid letter.
* DRAW statements are not case sensitive.
** "'''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 graphic cursor will return to the starting position after the line is drawn.
** "'''P''' f [, b]" is used to [[PAINT|paint]] enclosed objects. f denotes the fill color and b the border color, if needed.
** "'''S''' n" changes the pixel move size of the lines. Default is 4 (1 pixel) minimum. "S8" would double the pixel line moves.
** "'''X'''" + [[VARPTR$]](value) can draw another substring.
** "'''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 graphic cursor will return to the starting position after the line is drawn.
** "'''P''' f [, b]" is used to [[PAINT|paint]] enclosed objects. f denotes the fill color and b the border color, if needed.
** "'''S''' n" changes the pixel move size of the lines. Default is 4 (1 pixel) minimum. "S8" would double the pixel line moves.
** "'''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:
** "'''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.
** "'''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 all subsequent draw moves.
** "'''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%)
** "'''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%)
* The graphic cursor is set to the center of the program window on program start for [[STEP]] relative coordinates.
* '''DRAW can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only.'''
@ -44,7 +44,7 @@ The [[DRAW]] statement uses a [[STRING]] expression to draw lines on the screen.
{{CodeStart}} '' ''
SCREEN 12
octagon$ = "C12 R10 F10 D10 G10 L10 H10 U10 E10" 'create a DRAW string value
octagon$ = "C12 R10 F10 D10 G10 L10 H10 U10 E10" 'create a DRAW string value
{{Cl|SCREEN (statement)|SCREEN}} 12
FOR i% = 1 TO 11
{{Cl|PSET}} (i% * 50, 100), 15
@ -56,19 +56,19 @@ The [[DRAW]] statement uses a [[STRING]] expression to draw lines on the screen.
''Explanation:'' Once a DRAW string variable is created, it can be used to draw a shape throughout the program at any time.
''Example 2:'' Creating an analog clock's hour markers using "TA=" + [[VARPTR$]](angle).
''Example 2:'' Creating an analog clock's hour markers using "TA=" + [[VARPTR$]](angle).
{{CodeStart}} '' ''
SCREEN 12
FOR angle = 0 TO 360 {{Cl|STEP}} 30 ' 360/12 hour circles = 30 degrees apart
PSET (175, 250), 6 ' stay at center point of clock
{{Cl|DRAW}} "TA=" + {{Cl|VARPTR$}}(angle) + "BU100" ' move invisibly to set next circle's center point
{{Cl|DRAW}} "TA=" + {{Cl|VARPTR$}}(angle) + "BU100" ' move invisibly to set next circle's center point
{{Cl|CIRCLE}} {{Cl|STEP}}(0, 0), 5, 12 ' circle placed at end of blind line
{{Cl|DRAW}} "P9, 12" ' paint inside of circle
{{Cl|DRAW}} "P9, 12" ' paint inside of circle
{{Cl|SLEEP}} 1 ' slowed for demo only
NEXT '' ''
{{CodeEnd}}
''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.
''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). (See [[TIME$]] example 1)
@ -77,11 +77,11 @@ The [[DRAW]] statement uses a [[STRING]] expression to draw lines on the screen.
DO: sec$ = {{Cl|RIGHT$}}({{Cl|TIME$}}, 2) ' get actual seconds from TIME$ function
degree$ = {{Cl|STR$}}({{Cl|VAL}}(sec$) * -6) ' 60 second moves. TA uses negative angles for clockwise moves
{{Cl|PSET}} (175, 250), 9 ' stay at clock center
DRAW "TA" + degree$ + "U90" ' up becomes TA directional line
DO: LOOP UNTIL RIGHT$(TIME$, 2) <> sec$ ' wait for a new second value
IF INKEY$ <> "" THEN {{Cl|EXIT DO}} ' any key exit
DRAW "TA" + degree$ + "U90" ' up becomes TA directional line
DO: LOOP UNTIL RIGHT$(TIME$, 2) <> sec$ ' wait for a new second value
IF INKEY$ <> "" THEN {{Cl|EXIT DO}} ' any key exit
PSET (175, 250), 0 ' set at clock center to erase line
DRAW "TA" + degree$ + "U90" ' erases old second hand line using color 0 from PSET
DRAW "TA" + degree$ + "U90" ' erases old second hand line using color 0 from PSET
LOOP
{{CodeEnd}}
@ -92,43 +92,43 @@ The [[DRAW]] statement uses a [[STRING]] expression to draw lines on the screen.
{{CodeStart}}
{{Cl|SCREEN}} 12
DO
{{Cl|LOCATE}} 1, 1: {{Cl|INPUT}} "Enter a number 0 to 9: ", num
{{Cl|LOCATE}} 1, 1: {{Cl|INPUT}} "Enter a number 0 to 9: ", num
{{Cl|CLS}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 2, 3, 5 {{Cl|TO}} 9: {{Cl|PSET}} (20, 20), 12
{{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'top horiz
{{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'top horiz
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 4 {{Cl|TO}} 6, 8, 9: {{Cl|PSET}} (20, 20), 12
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'left top vert
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'left top vert
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 2, 6, 8: {{Cl|PSET}} (20, 54), 12
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12, 12" 'left bot vert
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12, 12" 'left bot vert
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 2 {{Cl|TO}} 6, 8, 9: {{Cl|PSET}} (20, 54), 12
{{Cl|DRAW}} "E2R30F2G2L30H2BR5P12, 12" 'middle horiz
{{Cl|DRAW}} "E2R30F2G2L30H2BR5P12, 12" 'middle horiz
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0 {{Cl|TO}} 4, 7 {{Cl|TO}} 9: {{Cl|PSET}} (54, 20), 12
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'top right vert
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'top right vert
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 1, 3 {{Cl|TO}} 9: {{Cl|PSET}} (54, 54), 12
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'bottom right vert
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'bottom right vert
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 2, 3, 5, 6, 8: {{Cl|PSET}} (20, 88), 12
{{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'bottom horiz
{{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'bottom horiz
{{Cl|END SELECT}}
{{Cl|LOOP}} {{Cl|UNTIL}} num > 9 '' ''
{{Cl|LOOP}} {{Cl|UNTIL}} num > 9 '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' The DRAW strings can be used more than once with different [[PSET]] positions to create more digits.
@ -151,7 +151,7 @@ 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|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}}
@ -165,4 +165,4 @@ k = {{Cl|_RGB}}(80, 255, 80)
* [[TIME$]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -17,4 +17,4 @@ The '''$''' is used to denote Qbasic [[Metacommand]]s or as a [[STRING]] variabl
* [[Metacommand]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -30,7 +30,7 @@
''Example 1:'' One line IF statement
{{CodeStart}}
IF x = 100 THEN PRINT "100" ELSE PRINT "Not 100"
IF x = 100 THEN PRINT "100" ELSE PRINT "Not 100"
{{CodeEnd}}
@ -38,8 +38,8 @@ IF x = 100 THEN PRINT "100" ELSE PRINT "Not 100"
{{CodeStart}}
IF x = 100 THEN ' code executed MUST be on next statement line!
PRINT "100"
ELSE PRINT "Not 100"
PRINT "100"
ELSE PRINT "Not 100"
END IF
{{CodeEnd}}
@ -59,4 +59,4 @@ IF a = 3 THEN a = 5 ELSE a = 3
* [[IF...THEN]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -29,7 +29,7 @@
''Example 1:'' IF statement using ELSE IF in one statement line.
{{CodeStart}}
IF x = 100 THEN COLOR 10: PRINT x ELSE IF x > 100 THEN COLOR 12: PRINT x ELSE PRINT "< 100"
IF x = 100 THEN COLOR 10: PRINT x ELSE IF x > 100 THEN COLOR 12: PRINT x ELSE PRINT "< 100"
{{CodeEnd}}
@ -39,8 +39,8 @@ IF x = 100 THEN COLOR 10: PRINT x ELSE IF x > 100 THEN COLOR 12: PRINT x ELSE
IF x = 100 THEN ' must place ANY code on next line!
COLOR 10: PRINT x
ELSEIF x > 100 THEN COLOR 12: PRINT x
ELSE : PRINT "< 100"
ELSEIF x > 100 THEN COLOR 12: PRINT x
ELSE : PRINT "< 100"
END IF
{{CodeEnd}}
@ -52,4 +52,4 @@ END IF
*[[IF...THEN]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -13,8 +13,8 @@ The [[END]] statement terminates a program without an immediate exit or ends a p
{{PageDescription}}
* In '''QB64''', [[END]] can be followed by a code that can be read by another module using the [[SHELL (function)|_SHELL]] or [[_SHELLHIDE]] function (known as [https://blogs.msdn.microsoft.com/oldnewthing/20080926-00/?p=20743 '''errorlevel'''])
* When END is used to end a program, there is a pause and the message "Press any key to continue..." is displayed at the bottom of the program's window.
* If the program does not use END or [[SYSTEM]], the program will still end with a pause and display "Press any key to continue...".
* When END is used to end a program, there is a pause and the message "Press any key to continue..." is displayed at the bottom of the program's window.
* If the program does not use END or [[SYSTEM]], the program will still end with a pause and display "Press any key to continue...".
* In '''QB64''', [[SYSTEM]] will end the program immediately and close the window.
* The '''QB64''' [[_EXIT (function)]] can block a user's Ctrl + Break key presses and clicks on the window's close button (X button) until the program is ready to close.
@ -23,9 +23,9 @@ The [[END]] statement terminates a program without an immediate exit or ends a p
''Example:'' In QB64 you won't return to the IDE unless you are using it to run or edit the program module.
{{CodeStart}} '' ''
{{Cl|PRINT}} "Hello world!"
{{Cl|PRINT}} "Hello world!"
{{Cl|END}}
{{Cl|PRINT}} "Hello no one!" '' ''
{{Cl|PRINT}} "Hello no one!" '' ''
{{CodeEnd}}
''Returns:''
@ -38,8 +38,8 @@ Hello world!
Press any key to continue...
{{OutputEnd}}
:''Explanation:''"Hello no one!" isn't returned because the program ended with the END statement no matter what is after that.
:The message "Press any key to continue..." is displayed after the program ends, both in QBasic and in '''QB64'''.
:''Explanation:''"Hello no one!" isn't returned because the program ended with the END statement no matter what is after that.
:The message "Press any key to continue..." is displayed after the program ends, both in QBasic and in '''QB64'''.
@ -49,4 +49,4 @@ Press any key to continue...
* [[EXIT]] (statement), [[_EXIT (function)]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -9,21 +9,21 @@ The [[ENVIRON$]] function returns a [[STRING]] environmental value from '''Windo
* The function can use an [[INTEGER]] {{Parameter|listIndex%}} value or [[STRING]] {{Parameter|systemID$}} parameter.
* {{Parameter|listIndex%}} refers to the number order of the environmental list. Returns are not in any particular numerical order.
* {{Parameter|systemID$}} is the specific [[STRING]] parameter requested. Returns only the specified environmental [[STRING]] setting:
** "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 in modern computers.
** "PATH" = full path setting 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.
** "PROGRAMFILES" = path to ''Program files'' folder, normally "C:\PROGRAM FILES"
** "PROMPT" = normally "$P$G" on Windows NT.
** "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".
** "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 in modern computers.
** "PATH" = full path setting 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.
** "PROGRAMFILES" = path to ''Program files'' folder, normally "C:\PROGRAM FILES"
** "PROMPT" = normally "$P$G" on Windows NT.
** "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'' below for a complete list in your system.
<!-- Sentence removed for being unclear/needs revision: * The OS in Win 9X or ME can be found in the "PROMPT" parameter ID. Returns are limited in Win 9X and ME. -->
<!-- Sentence removed for being unclear/needs revision: * 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 did in DOS.
@ -35,8 +35,8 @@ The [[ENVIRON$]] function returns a [[STRING]] environmental value from '''Windo
i = i + 1
setting$ = {{Cl|ENVIRON$}}(i) ' get a setting from the list
{{Cl|PRINT}} setting$
{{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$ = ""
{{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
@ -70,8 +70,8 @@ USERPROFILE=C:\Users\Ted
{{CodeStart}}
'=== Enter the EXE file and ICON or BMP image for the shortcut.
Program$ = "QB64.EXE" '<<<<<<<<<< Enter the '''exact''' program name for shortcut
ICON$ = "QB64ICON.BMP" '<<<<<<<<<< Enter icon or bitmap to use from program's folder
Program$ = "QB64.EXE" '<<<<<<<<<< Enter the '''exact''' program name for shortcut
ICON$ = "QB64ICON.BMP" '<<<<<<<<<< Enter icon or bitmap to use from program's folder
DeskTopShortcut Program$, ICON$
@ -79,23 +79,23 @@ DeskTopShortcut Program$, ICON$
{{Cl|SUB}} DeskTopShortcut (Program$, ICON$)
f = {{Cl|FREEFILE}}
{{Cl|SHELL}} {{Cl|_HIDE}} "CD > PRGMDIR.INF" 'get the current program path
{{Cl|OPEN}} "PRGMDIR.INF" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #f
{{Cl|SHELL}} {{Cl|_HIDE}} "CD > PRGMDIR.INF" 'get the current program path
{{Cl|OPEN}} "PRGMDIR.INF" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #f
{{Cl|LINE INPUT (file statement)|LINE INPUT}} #f, PATH$
{{Cl|CLOSE}} #f
{{Cl|KILL}} "PRGMDIR.INF"
PATH$ = PATH$ + "\": FILE$ = PATH + Program$
{{Cl|KILL}} "PRGMDIR.INF"
PATH$ = PATH$ + "\": FILE$ = PATH + Program$
PRINT PATH$ 'DEMO print
A$ = {{Cl|ENVIRON$}}("HOMEDRIVE") '=== Get Current User setting from Environment.
B$ = {{Cl|ENVIRON$}}("HOMEPATH")
A$ = {{Cl|ENVIRON$}}("HOMEDRIVE") '=== Get Current User setting from Environment.
B$ = {{Cl|ENVIRON$}}("HOMEPATH")
C$ = A$ + B$ 'shortcut to user's desktop if found
{{Cl|IF...THEN|IF}} C$ = "" {{Cl|THEN}} C$ = {{Cl|ENVIRON$}}("ALLUSERSPROFILE") 'try desktop for all users
{{Cl|IF...THEN|IF}} C$ = "" {{Cl|THEN}} C$ = {{Cl|ENVIRON$}}("ALLUSERSPROFILE") 'try desktop for all users
PRINT C$ 'DEMO print
URLFILE$ = {{Cl|MID$}}(Program$, 1, {{Cl|INSTR}}(Program$, ".")) + "URL" 'change EXE to URL
URLFILE$ = {{Cl|MID$}}(Program$, 1, {{Cl|INSTR}}(Program$, ".")) + "URL" 'change EXE to URL
{{Cl|IF...THEN|IF}} C$ > "" {{Cl|THEN}}
SHORTCUT$ = C$ + "\Desktop\" + URLFILE$ 'create filename for the desktop
{{Cl|IF...THEN|IF}} C$ > "" {{Cl|THEN}}
SHORTCUT$ = C$ + "\Desktop\" + URLFILE$ 'create filename for the desktop
{{Cl|ELSE}} SHORTCUT$ = PATH$ + URLFILE$ 'if all else fails put in program folder
{{Cl|END IF}}
PRINT SHORTCUT 'DEMO print
@ -103,11 +103,11 @@ PRINT SHORTCUT 'DEMO print
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(f) {{Cl|THEN}} {{Cl|CLOSE}} #f: {{Cl|EXIT SUB}} '=== if filesize is NOT Zero don't overwrite!
Q$ = {{Cl|CHR$}}(34) '=== Write URL Shortcut file info.
{{Cl|PRINT (file statement)|PRINT}} #f, "[InternetShortcut]" 'URL type
{{Cl|PRINT (file statement)|PRINT}} #f, "URL=" + Q$ + "file://" + FILE$ + Q$ 'URL program file
{{Cl|PRINT (file statement)|PRINT}} #f, "WorkingDirectory=" + Q$ + PATH$ + Q$ 'Working path
{{Cl|PRINT (file statement)|PRINT}} #f, "IconIndex = " + Q$ + "0" + Q$ '0 is first index
{{Cl|PRINT (file statement)|PRINT}} #f, "IconFile = " + Q$ + PATH$ + ICON$ + Q$ 'Icon path in working folder
{{Cl|PRINT (file statement)|PRINT}} #f, "[InternetShortcut]" 'URL type
{{Cl|PRINT (file statement)|PRINT}} #f, "URL=" + Q$ + "file://" + FILE$ + Q$ 'URL program file
{{Cl|PRINT (file statement)|PRINT}} #f, "WorkingDirectory=" + Q$ + PATH$ + Q$ 'Working path
{{Cl|PRINT (file statement)|PRINT}} #f, "IconIndex = " + Q$ + "0" + Q$ '0 is first index
{{Cl|PRINT (file statement)|PRINT}} #f, "IconFile = " + Q$ + PATH$ + ICON$ + Q$ 'Icon path in working folder
{{Cl|CLOSE}} #f
{{Cl|END SUB}} '' ''
{{CodeEnd}}
@ -124,4 +124,4 @@ Q$ = {{Cl|CHR$}}(34) '=== Write URL Shortcut file info.
* [[Windows Libraries#Windows User|Windows User Paths Library]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -11,8 +11,8 @@ The [[ENVIRON]] statement is used in DOS/Windows to temporarily set or change an
{{PageDescription}}
* [[Keywords_currently_not_supported_by_QB64|Not supported in QB64.]]
* The {{Parameter|stringExpression$}} must include the environmental parameter ID and the setting:
** Using an '''=''' sign: [[ENVIRON]] "parameterID=setting"
** Using a space: [[ENVIRON]] "parameterID setting"
** Using an '''=''' sign: [[ENVIRON]] "parameterID=setting"
** Using a space: [[ENVIRON]] "parameterID setting"
* If the parameter ID did not previously exist in the environmental string table, it is appended to the end of the table.
* If a parameter ID did exist, it is deleted and the new value is appended to end of the list.
* DOS discards any changes when your program ends so the program must set them when run.
@ -24,4 +24,4 @@ The [[ENVIRON]] statement is used in DOS/Windows to temporarily set or change an
* [[Windows Environment]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -9,7 +9,7 @@ The [[EOF]] function indicates that the end of a file has been reached.
* {{Parameter|fileNumber&}} is the number of the file being read. '''#''' is not required.
* Returns 0 until the end of a file. This avoids a file read error.
* Returns -1 (true) at the end of the file.
<!-- confusing statement; further details are required: * [[CHR$]](26) can be used to denote the end of a file. -->
<!-- confusing statement; further details are required: * [[CHR$]](26) can be used to denote the end of a file. -->
* '''Note that [[GET]] can return invalid data at the end of a file.''' Read [[EOF]] after a GET operation to see if the end of the file has been reached and discard last read.
@ -21,4 +21,4 @@ The [[EOF]] function indicates that the end of a file has been reached.
* [[GET]], [[PUT]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -18,4 +18,4 @@ The [[EQV]] operator returns a value based on the ''equivalence'' of two conditi
* [[Boolean]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -6,7 +6,7 @@ The [[ERASE]] statement is used to clear all data from an array. [[$STATIC]] [[A
{{PageDescription}}
* All string array elements become null strings ("") and all numerical array elements become 0.
* All string array elements become null strings ("") and all numerical array elements become 0.
* Multiple arrays can be erased using commas between the array names.
* [[$DYNAMIC|Dynamic]] arrays must be [[REDIM]]ensioned if they are referenced after erased.
* Dimension subprocedure arrays as [[STATIC]] to use [[ERASE]] and not have to REDIM.
@ -21,4 +21,4 @@ The [[ERASE]] statement is used to clear all data from an array. [[$STATIC]] [[A
* [[Arrays]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -19,4 +19,4 @@
* [[ERROR]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -17,4 +17,4 @@
{{PageNavigation}}
{{PageNavigation}}

View file

@ -40,4 +40,4 @@ errorfix:
* [[ERROR Codes]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -11,7 +11,7 @@ The [[ERR]] function returns the last QBasic error code number.
{{PageExamples}}
''Example:'' Simulating an error to test a program error handler that looks for a "Subscript out of range" error.
''Example:'' Simulating an error to test a program error handler that looks for a "Subscript out of range" error.
{{CodeStart}} '' ''
{{Cl|ON ERROR}} {{Cl|GOTO}} handler
@ -25,7 +25,7 @@ handler:
{{Cl|PRINT}} {{Cl|ERR}}, {{Cl|_ERRORLINE}}
{{Cl|BEEP}}
{{Cl|IF...THEN|IF}} {{Cl|ERR}} = 9 {{Cl|THEN}}
{{Cl|PRINT}} "The program has encountered an error and needs to close! Press a key!"
{{Cl|PRINT}} "The program has encountered an error and needs to close! Press a key!"
K$ = {{Cl|INPUT$}}(1)
{{Cl|SYSTEM}}
{{Cl|END IF}}
@ -41,4 +41,4 @@ handler:
* [[ERROR Codes]]
{{PageNavigation}}
{{PageNavigation}}

View file

@ -38,4 +38,4 @@ handler:
*[[ERROR Codes]] (list)
{{PageNavigation}}
{{PageNavigation}}

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