1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-03 08:51:22 +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}}

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

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.

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

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

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

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)

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

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,8 +128,9 @@ 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)}}

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:''

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

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.

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

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

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

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

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

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

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

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

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

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}} '' ''

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

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

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

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

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

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

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

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

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

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

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

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

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

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}} '' ''

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

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

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

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

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

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

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

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

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

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

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

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

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}} '' ''

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

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.

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:''

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:''

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

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

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

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

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

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

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

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\

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

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

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

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

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

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

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.

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.

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.

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

View file

@ -12,9 +12,9 @@ The [[EXIT]] statement is used to exit certain QBasic procedures.
** [[EXIT]] FOR exits a [[FOR...NEXT]] counter loop.
** [[EXIT]] SUB exits a [[SUB]] procedure before it ends. Use before any [[GOSUB]] procedures using [[RETURN]].
** [[EXIT]] FUNCTION exits a [[FUNCTION]] procedure before it ends. The value passed by the function's name should be defined.
<!-- ** [[EXIT]] DEF exits a [[DEF FN]] function procedure before it ends. The value passed by the function's name should be defined. -->
<!-- ** [[EXIT]] DEF exits a [[DEF FN]] function procedure before it ends. The value passed by the function's name should be defined. -->
* EXIT statements normally use an [[IF...THEN]] statement to evaluate a program condition that would require the EXIT.
* To exit a program and allow the last program screen to be displayed with the message "Press any key to continue...", use [[END]].
* To exit a program and allow the last program screen to be displayed with the message "Press any key to continue...", use [[END]].
* To exit the program immediately, use [[SYSTEM]].

View file

@ -7,11 +7,11 @@ The [[EXP]] math function calculates the exponential function ('''e''' raised to
{{PageDescription}}
* '''e''' is defined as the base of natural logarithms or as the limit of (1 + 1 / n) ^ n, as n goes to infinity.
* The {{Parameter|numericExpression}} must be less than or equal to '''88.02969''' or an [[ERROR Codes|"overflow" error]] will occur.
* The {{Parameter|numericExpression}} must be less than or equal to '''88.02969''' or an [[ERROR Codes|"overflow" error]] will occur.
* Value returned is '''e''' to the exponent parameter ('''e = 2.718282''' approximately).
* Values returned are [[SINGLE]] by default but will return [[DOUBLE]] precision if the {{Parameter|result}} is a variable of type [[DOUBLE]].
* Positive exponent values indicate the number of times to multiply '''e''' by itself.
* Negative exponent values indicate the number of times to divide by '''e'''. Example: <span style="font-family: Courier New, monospace, Courier; background: #dddddd">e<sup>-3</sup> = 1 / e<sup>3</sup> = 1 / (e * e * e)</span>
* Negative exponent values indicate the number of times to divide by '''e'''. Example: <span style="font-family: Courier New, monospace, Courier; background: #dddddd">e<sup>-3</sup> = 1 / e<sup>3</sup> = 1 / (e * e * e)</span>
{{PageSeeAlso}}

View file

@ -1,7 +1,7 @@
The '''=''' condition symbol denotes that a value must equal another value for the condition to be True.
''Example usage:'' IF x [[=]] 320 THEN PRINT "Center of screen"
''Example usage:'' IF x [[=]] 320 THEN PRINT "Center of screen"
* Statements will evaluate as True or -1 when two values are equal or False or 0 when not equal.
@ -11,8 +11,8 @@ The '''=''' condition symbol denotes that a value must equal another value for t
''See also:''
* [[Not_Equal|<>]]
* [[Greater_Than|>]]
* [[Not_Equal|<>]]
* [[Greater_Than|>]]
* [[Less_Than|<]]
* [[Relational Operations]]

View file

@ -7,11 +7,11 @@ The [[FIELD]] statement creates a [[STRING]] type definition for a [[RANDOM|rand
{{PageDescription}}
* {{Parameter|fileNumber%}} is a file number used in the [[OPEN]] statement or a value from the [[FREEFILE]] function.
* Combined size of the {{Parameter|fieldWidth%}} parameters '''must not exceed the [[LEN]] = recordsize in the [[RANDOM]] [[OPEN]] statement''' or a [[ERROR Codes|"FIELD overflow" error]] will occur.
* Combined size of the {{Parameter|fieldWidth%}} parameters '''must not exceed the [[LEN]] = recordsize in the [[RANDOM]] [[OPEN]] statement''' or a [[ERROR Codes|"FIELD overflow" error]] will occur.
* Variables are limited to [[STRING]] types. Use [[TYPE]] instead of FIELD if you want to use numerical values.
* Once a [[FIELD]] is defined in a statement, [[GET]] can read and [[PUT]] can write data without placeholders or variables.
* [[LSET]], [[RSET]], [[PRINT (file statement)|PRINT #]], [[PRINT USING (file statement)|PRINT # USING]], and [[WRITE (file statement)|WRITE #]] can be used to place characters in the file buffer before a [[PUT]].
* All field definitions for a file are removed when the file is [[CLOSE|closed]] or [[RESET]] and all strings are set to null ("").
* All field definitions for a file are removed when the file is [[CLOSE|closed]] or [[RESET]] and all strings are set to null ("").
* '''Do not re-assign a field defined variable value or use it in an [[INPUT]] statement if you want the variable to remain a field'''.
@ -28,12 +28,12 @@ The [[FIELD]] statement creates a [[STRING]] type definition for a [[RANDOM|rand
{{Cl|DIM}} Client {{Cl|AS}} ClientType
RecordLEN = {{Cl|LEN}}(Client) 'find the size of each TYPE record
{{Cl|OPEN}} "ADDRESS.DAT" {{Cl|FOR (file statement)|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = RecordLEN
{{Cl|OPEN}} "ADDRESS.DAT" {{Cl|FOR (file statement)|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = RecordLEN
{{Cl|RESTORE}} ClientData 'restore to start of DATA
record = 0
{{Cl|DO}}
{{Cl|READ}} CName$, Address$, City$, State$, Zip$ 'read DATA
{{Cl|IF}} CName$ = "END" {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|IF}} CName$ = "END" {{Cl|THEN}} {{Cl|EXIT DO}}
record = record + 1 'increment record number
Client.CName = CName$
Client.Address = Address$
@ -46,12 +46,12 @@ record = 0
{{Cl|END}}
ClientData:
{{Cl|DATA}} "Bob White","104 Birdland Rd.","Bellview","PA","15236"
{{Cl|DATA}} "Ward Cleaver","123 W. Beaver St.","Beaver","PA","15255"
{{Cl|DATA}} "Elmer Fudd","45 Wabbit St.","Bethel Park","PA","15022"
{{Cl|DATA}} "Wyley Coyote","33 Roadrunner Ave.","Clairton","PA","15122"
{{Cl|DATA}} "Jim Morrison","19 Doorway Dr.","Belleview","PA","15236"
{{Cl|DATA}} "END",0,0,0,0 '' ''
{{Cl|DATA}} "Bob White","104 Birdland Rd.","Bellview","PA","15236"
{{Cl|DATA}} "Ward Cleaver","123 W. Beaver St.","Beaver","PA","15255"
{{Cl|DATA}} "Elmer Fudd","45 Wabbit St.","Bethel Park","PA","15022"
{{Cl|DATA}} "Wyley Coyote","33 Roadrunner Ave.","Clairton","PA","15122"
{{Cl|DATA}} "Jim Morrison","19 Doorway Dr.","Belleview","PA","15236"
{{Cl|DATA}} "END",0,0,0,0 '' ''
{{CodeEnd}} '' ''
Demo using the FIELD statement to read the file:
@ -59,7 +59,7 @@ Demo using the FIELD statement to read the file:
{{Cl|CONST}} NM = 30, AD = 30, CT = 15, ST = 2, ZC = 5 ' Define field and record lengths with constants.
{{Cl|CONST}} RLEN = NM + AD + CY + ST + ZC
'
{{Cl|OPEN}} "ADDRESS.DAT" {{Cl|FOR (file statement)|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = RLEN
{{Cl|OPEN}} "ADDRESS.DAT" {{Cl|FOR (file statement)|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #1 {{Cl|LEN}} = RLEN
{{Cl|FIELD}} #1, NM {{Cl|AS}} CName$, AD {{Cl|AS}} Address$, CY {{Cl|AS}} City$, ST {{Cl|AS}} State$, ZC {{Cl|AS}} Zip$
{{Cl|FIELD}} #1, RLEN {{Cl|AS}} Clist$ 'define entire record
@ -67,7 +67,7 @@ Demo using the FIELD statement to read the file:
'Read file for zip codes from 15230 to 15239 .
{{Cl|DO}} {{Cl|WHILE}} {{Cl|NOT}} {{Cl|EOF}}(1)
ZipCheck$ = Zip$ 'read zip codes
{{Cl|IF}} (ZipCheck$ >= "15230" {{Cl|AND (boolean)|AND}} ZipCheck$ <= "15239") {{Cl|THEN}}
{{Cl|IF}} (ZipCheck$ >= "15230" {{Cl|AND (boolean)|AND}} ZipCheck$ <= "15239") {{Cl|THEN}}
Info$ = Clist$
{{Cl|PRINT}} {{Cl|LEFT$}}(Info$, 30) 'read name string
{{Cl|PRINT}} {{Cl|MID$}}(Info$, 31, 30) 'read address string

View file

@ -14,7 +14,7 @@ The [[FILEATTR]] function returns a file's current file mode or DOS handle.
* {{Parameter|fileNumber%}} is the number assigned in the file's [[OPEN]] statement.
* {{Parameter|mode%}} specifies the type of information to return, which may have the following values
** {{Parameter|mode%}} = 1: returns the open mode with the following return values:
::{| border="2" cellpadding="1"
::{| border="2" cellpadding="1"
! Return || Open Mode
|-
|  1 ||  [[INPUT]]

View file

@ -10,30 +10,30 @@ The [[FILES]] statement is used to print a list of files in the current director
* {{Parameter|fileSpec$}} can use the * and ? wildcard specifications:
** '''*''' denotes one or more wildcard characters in a filename or path specification as any legal file name character(s).
** '''?''' denotes one wildcard letter in a filename or path specification as any legal filename character.
* If {{Parameter|fileSpec$}} is omitted, it is assumed to be '''"*.*"''' (all files and folders in the current directory).
* Illegal filename characters in '''QB64''' include * > < : " | \ / with any amount of dot extensions being allowed in Windows.
* FILES lists can make the screen roll up. Try using SHELL "DIR" with the /P option. [http://www.computerhope.com/dirhlp.htm DIR command].
* If {{Parameter|fileSpec$}} is omitted, it is assumed to be '''"*.*"''' (all files and folders in the current directory).
* Illegal filename characters in '''QB64''' include * > < : " | \ / with any amount of dot extensions being allowed in Windows.
* FILES lists can make the screen roll up. Try using SHELL "DIR" with the /P option. [http://www.computerhope.com/dirhlp.htm DIR command].
==QBasic/QuickBASIC==
* Illegal filename characters in QBasic included '''* ? , > < ; : " | \ / + [ ]''' and more than one dot extension in [http://www.computerhope.com/issues/ch000209.htm DOS].
* Illegal filename characters in QBasic included '''* ? , > < ; : " | \ / + [ ]''' and more than one dot extension in [http://www.computerhope.com/issues/ch000209.htm DOS].
{{PageExamples}}
''Example 1:'' Finding a list of all BAS files in the current folder.
{{CodeStart}}{{Cl|FILES}} "*.BAS"
{{CodeStart}}{{Cl|FILES}} "*.BAS"
{{CodeEnd}}
<!-- broken link: <center>'''[http://i301.photobucket.com/albums/nn53/burger2227/FILESss.jpg Screenshot shows only the end of a long list of files]'''</center> -->
<!-- broken link: <center>'''[http://i301.photobucket.com/albums/nn53/burger2227/FILESss.jpg Screenshot shows only the end of a long list of files]'''</center> -->
<!-- function obsoleted by _FILEEXISTS; function doesn't use the FILES statement and is not relevant in this context; may be moved to an exclusive page if desired;
{{Parameter|Example 2:'' A function that verifies that a file exists if it is not empty. Note: This function will delete empty files.
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter a file name: ", file$
{{Cl|INPUT}} "Enter a file name: ", file$
{{Cl|IF}} Exist%(file$) {{Cl|THEN}} {{Cl|OPEN}} file$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1: found% = -1 'function call demo
{{Cl|CLOSE}} #1
{{Cl|IF}} found% THEN {{Cl|PRINT}} "File exists!" {{Cl|ELSE}} {{Cl|PRINT}} "File not found!"
{{Cl|IF}} found% THEN {{Cl|PRINT}} "File exists!" {{Cl|ELSE}} {{Cl|PRINT}} "File not found!"
{{Cl|END}}
{{Cl|FUNCTION}} Exist% (filename$)
@ -43,20 +43,20 @@ f% = {{Cl|FREEFILE}}
{{Cl|CLOSE}} #f%
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}{{small|Code by Ted Weissgerber}}}}
-->
-->
==Alternative file list solutions==
''Alternative 1:'' The DIR$ function adapted from PDS (7.1) returns a filename or a list when more than one exist. The file spec can use a path and/or wildcards.
{{CodeStart}} '' ''
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT}}
{{Cl|LINE INPUT}} "Enter a file spec: ", spec$
{{Cl|LINE INPUT}} "Enter a file spec: ", spec$
file$ = DIR$(spec$) 'use a file spec ONCE to find the last file name listed
{{Cl|PRINT}} DIRCount%, file$, 'function can return the file count using {{Cl|SHARED}} variable
{{Cl|IF...THEN|IF}} DIRCount% > 1 {{Cl|THEN}}
{{Cl|IF...THEN|IF}} DIRCount% > 1 {{Cl|THEN}}
DO
K$ = {{Cl|INPUT$}}(1)
file$ = DIR$("") 'use an empty string parameter to return a list of files!
file$ = DIR$("") 'use an empty string parameter to return a list of files!
{{Cl|PRINT}} file$,
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}(file$) = 0 'file list ends with an empty string
{{Cl|END IF}}
@ -65,13 +65,13 @@ f% = {{Cl|FREEFILE}}
{{Cl|END}}
{{Cl|FUNCTION}} DIR$ (spec$)
{{Cl|CONST}} TmpFile$ = "DIR$INF0.INF", ListMAX% = 500 'change maximum to suit your needs
{{Cl|CONST}} TmpFile$ = "DIR$INF0.INF", ListMAX% = 500 'change maximum to suit your needs
{{Cl|SHARED}} DIRCount% 'returns file count if desired
{{Cl|STATIC}} Ready%, Index%, DirList$()
{{Cl|IF...THEN|IF}} {{Cl|NOT}} Ready% {{Cl|THEN}} {{Cl|REDIM}} DirList$(ListMAX%): Ready% = -1 '{{Cl|DIM}} array first use
{{Cl|IF...THEN|IF}} spec$ > "" {{Cl|THEN}} 'get file names when a spec is given
{{Cl|SHELL}} {{Cl|_HIDE}} "DIR " + spec$ + " /b > " + TmpFile$
Index% = 0: DirList$(Index%) = "": ff% = {{Cl|FREEFILE}}
{{Cl|IF...THEN|IF}} spec$ > "" {{Cl|THEN}} 'get file names when a spec is given
{{Cl|SHELL}} {{Cl|_HIDE}} "DIR " + spec$ + " /b > " + TmpFile$
Index% = 0: DirList$(Index%) = "": ff% = {{Cl|FREEFILE}}
{{Cl|OPEN}} TmpFile$ {{Cl|FOR...NEXT|FOR}} {{Cl|APPEND}} {{Cl|AS}} #ff%
size& = {{Cl|LOF}}(ff%)
{{Cl|CLOSE}} #ff%
@ -84,19 +84,19 @@ f% = {{Cl|FREEFILE}}
DIRCount% = Index% '{{Cl|SHARED}} variable can return the file count
{{Cl|CLOSE}} #ff%
{{Cl|KILL}} TmpFile$
{{Cl|ELSE}} {{Cl|IF...THEN|IF}} Index% > 0 {{Cl|THEN}} Index% = Index% - 1 'no spec sends next file name
{{Cl|ELSE}} {{Cl|IF...THEN|IF}} Index% > 0 {{Cl|THEN}} Index% = Index% - 1 'no spec sends next file name
{{Cl|END IF}}
DIR$ = DirList$(Index%)
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' The function will verify that a file exists (even if it is empty) by returning its name, or it returns an empty string if no file exists. It can return a list of file names by using an empty string parameter("") after sending a wildcard spec to get the first file name. The number of file names found is returned by using the SHARED variable, '''DIRCount%'''. Unlike the PDS DIR$ function, '''it must use an empty string parameter as QB64 doesn't support optional parameters.''' The function does not delete empty files.
:''Explanation:'' The function will verify that a file exists (even if it is empty) by returning its name, or it returns an empty string if no file exists. It can return a list of file names by using an empty string parameter("") after sending a wildcard spec to get the first file name. The number of file names found is returned by using the SHARED variable, '''DIRCount%'''. Unlike the PDS DIR$ function, '''it must use an empty string parameter as QB64 doesn't support optional parameters.''' The function does not delete empty files.
''Alternative 2:''
* The member-contributed [[FILELIST$]] function uses the mouse and does not affect your program screens. It can verify that a file name exists or display a list of long and short file names to choose from. It also avoids program errors when a file name does not exist. <!-- broken link: [http://i301.photobucket.com/albums/nn53/burger2227/FILE-ss2.jpg FILELIST$ function screenshot] -->
* The member-contributed [[FILELIST$]] function uses the mouse and does not affect your program screens. It can verify that a file name exists or display a list of long and short file names to choose from. It also avoids program errors when a file name does not exist. <!-- broken link: [http://i301.photobucket.com/albums/nn53/burger2227/FILE-ss2.jpg FILELIST$ function screenshot] -->
<!-- The referenced library is not present in this link anymore ''See Library:'' File Exist C++ Function that does not create a temp file. [http://qb64.net/wiki/index.php?title=C_Libraries#File_Exist FileExist Function] -->
<!-- The referenced library is not present in this link anymore ''See Library:'' File Exist C++ Function that does not create a temp file. [http://qb64.net/wiki/index.php?title=C_Libraries#File_Exist FileExist Function] -->
{{PageSeeAlso}}
* [[SHELL]], [[SCREEN (function)]] {{text|(See Example 3)}}

View file

@ -37,7 +37,7 @@ FOR i = 10 TO 0 {{Cl|STEP}} -2
totaleven% = i + totaleven%
PRINT totaleven%;
NEXT
PRINT "After loop, i ="; i '' ''
PRINT "After loop, i ="; i '' ''
{{CodeEnd}}
{{OutputStart}}10 18 24 28 30 30 After loop, i = -2
{{OutputEnd}}
@ -46,13 +46,13 @@ PRINT "After loop, i ="; i '' ''
''Example 2:'' How an entire FOR loop block is ignored when the start and stop limits do not match the default or [[STEP]] increment.
{{CodeStart}} '' ''
{{Cl|PRINT}} "hi"
{{Cl|PRINT}} "hi"
{{Cl|FOR...NEXT|FOR}} i = 10 {{Cl|TO}} 1 'requires a negative {{Cl|STEP}} value
{{Cl|PRINT}} "lo"
{{Cl|PRINT}} "lo"
{{Cl|NEXT}}
{{Cl|PRINT}} "bye"
{{Cl|PRINT}} "bye"
{{CodeEnd}}
{{OutputStart}}hi
bye {{OutputEnd}}
@ -60,7 +60,7 @@ bye {{OutputEnd}}
<!-- removed redundant example as Example 2 above shows exactly the same technique
''See Example:''
* [http://qb64.net/wiki/index.php?title=Controller_Devices#Example Example that shows how ignoring bad FOR loops can work to a program's advantage without errors.] -->
* [http://qb64.net/wiki/index.php?title=Controller_Devices#Example Example that shows how ignoring bad FOR loops can work to a program's advantage without errors.] -->
{{PageSeeAlso}}

View file

@ -23,21 +23,21 @@
{{Cl|CLS}}
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted."
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted."
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted."
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted."
{{Cl|CLOSE}} #1
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1
{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1)
{{Cl|INPUT (file statement)|INPUT}} #1, a$
{{Cl|PRINT}} a$
{{Cl|LOOP}}
{{Cl|CLOSE}} #1
{{Cl|KILL}} "test.tst"
{{Cl|KILL}} "test.tst"
{{Cl|END}}

View file

@ -22,9 +22,9 @@ The [[FRE]] function returns the amount of memory available in bytes to running
{{PageExamples}}
{{CodeStart}} '' ''
' {{Cl|$DYNAMIC}}
PRINT "Sizes in bytes before dimensioning arrays: "; {{Cl|FRE}}(""), {{Cl|FRE}}(0), {{Cl|FRE}}(-1), {{Cl|FRE}}(-2)
PRINT "Sizes in bytes before dimensioning arrays: "; {{Cl|FRE}}(""), {{Cl|FRE}}(0), {{Cl|FRE}}(-1), {{Cl|FRE}}(-2)
{{Cl|DIM}} Array(100, 100), Text$(5000)
PRINT "Sizes in bytes after dimensioning arrays: "; {{Cl|FRE}}(""), {{Cl|FRE}}(0), {{Cl|FRE}}(-1), {{Cl|FRE}} (-2) '' ''
PRINT "Sizes in bytes after dimensioning arrays: "; {{Cl|FRE}}(""), {{Cl|FRE}}(0), {{Cl|FRE}}(-1), {{Cl|FRE}} (-2) '' ''
{{CodeEnd}}
''Notes:'' Sizes returned may vary by computer used. FRE(-2) must be used in a running program.

View file

@ -11,7 +11,7 @@ The [[FREEFILE]] function returns a [[LONG]] value that is an unused file access
* File numbers [[CLOSE]]d are made available to [[FREEFILE]] for reuse immediately.
* [[FREEFILE]] returns are normally sequential starting with 1. Only file numbers in use will not be returned.
* [[OPEN]] each file number after each [[FREEFILE]] return or the values returned may be the same.
<!-- redundant * [[OPEN COM]] statements cannot use any number assigned to files already OPEN. -->
<!-- redundant * [[OPEN COM]] statements cannot use any number assigned to files already OPEN. -->
{{PageSeeAlso}}

View file

@ -33,13 +33,13 @@ A [[FUNCTION]] block statement is used to create a function procedure to return
{{PageExamples}}
''Example 1:'' A simple function that returns the current path. Place [[FUNCTION]] or [[SUB]] procedures after the program [[END]].
{{CodeStart}} '' ''
{{Cl|PRINT}} "Current path = "; PATH$
{{Cl|PRINT}} "Current path = "; PATH$
{{Cl|END}}
{{Cl|FUNCTION}} PATH$
f% = {{Cl|FREEFILE}}
file$ = "D0Spath.inf" 'file name uses a zero to prevent an overwrite of existing file name
{{Cl|SHELL}} {{Cl|_HIDE}} "CD > " + file$ 'send screen information to a created text file
file$ = "D0Spath.inf" 'file name uses a zero to prevent an overwrite of existing file name
{{Cl|SHELL}} {{Cl|_HIDE}} "CD > " + file$ 'send screen information to a created text file
{{Cl|OPEN}} file$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #f% 'file should exist with one line of text
{{Cl|LINE INPUT (file statement)|LINE INPUT}} #f%, PATH$ 'read file path text to function name
{{Cl|CLOSE}} #f%
@ -50,9 +50,9 @@ A [[FUNCTION]] block statement is used to create a function procedure to return
''Example 2:'' Returns a [[LONG]] array byte size required for a certain sized graphics screen pixel area [[GET (graphics statement)|GET]].
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter a screen mode: ", mode%
{{Cl|INPUT}} "Enter image width: ", wide&
{{Cl|INPUT}} "Enter image depth: ", deep&
{{Cl|INPUT}} "Enter a screen mode: ", mode%
{{Cl|INPUT}} "Enter image width: ", wide&
{{Cl|INPUT}} "Enter image depth: ", deep&
IntegerArray& = ImageBufferSize&(wide&, deep&, mode%) \ 2 ' returns size of an {{Cl|INTEGER}} array.
{{Cl|PRINT}} IntegerArray&
{{Cl|END}}

View file

@ -10,7 +10,7 @@ The [[GET #]] statement reads data from a file or port device by bytes or record
* The [[INTEGER]] or [[LONG]] byte {{Parameter|position}} in a [[BINARY]] file or the record {{Parameter|position}} in a [[RANDOM]] file '''must be greater than zero'''.
* The {{Parameter|position}} can be omitted if the GET operations are consecutive based on the {{Parameter|targetVariable}} [[TYPE]] byte size.
* The {{Parameter|targetVariable}} [[Data types|type]] or [[FIELD]] ''variable'' size determines the byte size and the next {{Parameter|position}} in the file.
* The first byte position in a file is 1. <!-- giving the previous information is enough: This may require adding one to an offset value when documentation uses that position as 0. -->
* The first byte position in a file is 1. <!-- giving the previous information is enough: This may require adding one to an offset value when documentation uses that position as 0. -->
* GET does not require a byte or record {{Parameter|position}} or {{Parameter|targetVariable}} (or comma) when using a [[FIELD]] statement.
* '''QB64''' can [[PUT]] the entire contents of an array to a file and later GET those contents to a {{Parameter|targetArray()}} (include brackets).
* '''GET may ignore the end of a file and return bad data. If the [[EOF]] function returns -1 after a GET operation, it indicates that the data has ended.'''
@ -32,12 +32,12 @@ The [[GET #]] statement reads data from a file or port device by bytes or record
{{Cl|DIM}} record {{Cl|AS}} variabletype
{{Cl|DIM}} newrec {{Cl|AS}} variabletype
file$ = "testrand.inf" '<<<< filename may overwrite existing file
file$ = "testrand.inf" '<<<< filename may overwrite existing file
number% = 1 '<<<<<<<<<< record number to write cannot be zero
RecordLEN% = {{Cl|LEN}}(record)
{{Cl|PRINT}} RecordLEN%; "bytes"
{{Cl|PRINT}} RecordLEN%; "bytes"
record.x = 255
record.y = "Hello world!"
record.y = "Hello world!"
record.z = 65535
{{Cl|PRINT}} record.x, record.y, record.z
@ -47,7 +47,7 @@ record.z = 65535
{{Cl|OPEN}} file$ {{Cl|FOR...NEXT|FOR}} {{Cl|RANDOM}} {{Cl|AS}} #2 {{Cl|LEN}} = RecordLEN%
NumRecords% = {{Cl|LOF}}(2) \ RecordLEN%
PRINT NumRecords%; "records"
PRINT NumRecords%; "records"
{{Cl|GET}} #2, NumRecords% , newrec 'GET last record available
{{Cl|CLOSE}} #2
@ -73,7 +73,7 @@ PRINT NumRecords%; "records"
{{Cl|NEXT}}
showme 'display array contents
{{Cl|OPEN}} "BINFILE.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1
{{Cl|OPEN}} "BINFILE.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1
{{Cl|PUT}} #1, , array()
@ -81,7 +81,7 @@ showme 'display array contents
showme
{{Cl|CLOSE}} #1
{{Cl|OPEN}} "BINFILE.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2
{{Cl|OPEN}} "BINFILE.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2
{{Cl|GET}} #2, , array()
{{Cl|CLOSE}} #2
showme 'display array after transfer from file
@ -92,7 +92,7 @@ showme 'display array after transfer from file
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 100
{{Cl|PRINT}} array(i);
{{Cl|NEXT}}
{{Cl|PRINT}} "done"
{{Cl|PRINT}} "done"
{{Cl|END SUB}} '' ''
{{CodeEnd}}
: ''Note:'' Use empty brackets in QB64 when using [[GET]] to create an array or [[PUT]] to create a [[BINARY]] data file.

View file

@ -41,13 +41,13 @@ The [[GET (graphics statement)|GET]] statement is used in graphics to store a bo
{{Cl|DIM}} BG(300), Box(300), SC(127) ' BG holds background images. Box holds the Box image.
{{Cl|SCREEN (statement)|SCREEN}} 13 ' graphic coordinate minimums are 0 to 319 column or 199 row maximums.
' set up screen background
{{Cl|COLOR}} 4: {{Cl|LOCATE}} 10, 5: {{Cl|PRINT}} "Multikey Keyboard input routine"
{{Cl|COLOR}} 10: {{Cl|LOCATE}} 12, 4: {{Cl|PRINT}} "Use the arrow keys to move the box."
{{Cl|LOCATE}} 13, 4: {{Cl|PRINT}} "Note that you can press two or more"
{{Cl|LOCATE}} 14, 4: {{Cl|PRINT}} "keys at once for diagonal movement!"
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 16, 4: {{Cl|PRINT}} " Also demonstrates how {{Cl|GET (graphics statement)|GET}} and PUT "
{{Cl|LOCATE}} 17, 4: {{Cl|PRINT}} "are used to preserve the background."
{{Cl|COLOR}} 11: {{Cl|LOCATE}} 20, 11: {{Cl|PRINT}} "Press [Esc] to quit"
{{Cl|COLOR}} 4: {{Cl|LOCATE}} 10, 5: {{Cl|PRINT}} "Multikey Keyboard input routine"
{{Cl|COLOR}} 10: {{Cl|LOCATE}} 12, 4: {{Cl|PRINT}} "Use the arrow keys to move the box."
{{Cl|LOCATE}} 13, 4: {{Cl|PRINT}} "Note that you can press two or more"
{{Cl|LOCATE}} 14, 4: {{Cl|PRINT}} "keys at once for diagonal movement!"
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 16, 4: {{Cl|PRINT}} " Also demonstrates how {{Cl|GET (graphics statement)|GET}} and PUT "
{{Cl|LOCATE}} 17, 4: {{Cl|PRINT}} "are used to preserve the background."
{{Cl|COLOR}} 11: {{Cl|LOCATE}} 20, 11: {{Cl|PRINT}} "Press [Esc] to quit"
x = 150: y = 50: PX = x: PY = y ' actual box starting position
{{Cl|GET (graphics statement)|GET}} (x, y)-(x + 15, y + 15), BG ' {{Cl|GET (graphics statement)|GET}} original BG at start box position
@ -60,14 +60,14 @@ The [[GET (graphics statement)|GET]] statement is used in graphics to store a bo
a$ = {{Cl|INKEY$}} ' So the keyboard buffer won't get full
code% = {{Cl|INP}}({{Cl|&H}}60) ' Get keyboard scan code from port 96
{{Cl|IF...THEN|IF}} code% < 128 {{Cl|THEN}} SC(code%) = 1 {{Cl|ELSE}} SC(code% - 128) = 0 'true/false values to array
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|TIMER}} > t!' loop until one tick has passed
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|TIMER}} > t!' loop until one tick has passed
PX = x: PY = y ' previous coordinates
{{Cl|IF...THEN|IF}} SC(75) = 1 {{Cl|THEN}} x = x - 5: {{Cl|IF...THEN|IF}} x < 0 {{Cl|THEN}} x = 0
{{Cl|IF...THEN|IF}} SC(77) = 1 {{Cl|THEN}} x = x + 5: {{Cl|IF...THEN|IF}} x > 304 {{Cl|THEN}} x = 304
{{Cl|IF...THEN|IF}} SC(77) = 1 {{Cl|THEN}} x = x + 5: {{Cl|IF...THEN|IF}} x > 304 {{Cl|THEN}} x = 304
{{Cl|IF...THEN|IF}} SC(72) = 1 {{Cl|THEN}} y = y - 5: {{Cl|IF...THEN|IF}} y < 0 {{Cl|THEN}} y = 0
{{Cl|IF...THEN|IF}} SC(80) = 1 {{Cl|THEN}} y = y + 5: {{Cl|IF...THEN|IF}} y > 184 {{Cl|THEN}} y = 184
{{Cl|IF...THEN|IF}} x <> PX {{Cl|OR (boolean)|OR}} y <> PY {{Cl|THEN}} ' look for a changed coordinate value
{{Cl|IF...THEN|IF}} SC(80) = 1 {{Cl|THEN}} y = y + 5: {{Cl|IF...THEN|IF}} y > 184 {{Cl|THEN}} y = 184
{{Cl|IF...THEN|IF}} x <> PX {{Cl|OR (boolean)|OR}} y <> PY {{Cl|THEN}} ' look for a changed coordinate value
{{Cl|WAIT}} 936, 8: {{Cl|PUT (graphics statement)|PUT}}(PX, PY), BG, {{Cl|PSET}} ' replace previous BG first
{{Cl|GET (graphics statement)|GET}} (x, y)-(x + 15, y + 15), BG ' {{Cl|GET (graphics statement)|GET}} BG at new position before box is set
{{Cl|PUT (graphics statement)|PUT}}(x, y), Box, {{Cl|PSET}} ' PUT box image at new position

View file

@ -7,24 +7,24 @@
{{PageDescription}}
* Use [[RETURN]] in a sub procedure to return to the next line of code after the original [[GOSUB]] call. [[END]] or [[SYSTEM]] can also be used to end program.
<!-- needs clarification: * A procedure loop may be used to return automatically instead of using return. -->
<!-- needs clarification: * A procedure loop may be used to return automatically instead of using return. -->
* GOSUB and GOTO can be used '''within''' [[SUB]] or [[FUNCTION]] procedures, but cannot refer to a label located outside the procedure.
==QBasic/QuickBASIC==
* Too many GOSUBs without a [[RETURN]] can eventually cause "Out of Stack Errors" in QBasic as each GOSUB uses memory to store the location to return to. Each [[RETURN]] frees the memory of the GOSUB it returns to.
* Too many GOSUBs without a [[RETURN]] can eventually cause "Out of Stack Errors" in QBasic as each GOSUB uses memory to store the location to return to. Each [[RETURN]] frees the memory of the GOSUB it returns to.
{{PageExamples}}
''Example:'' Simple usage of GOSUB
{{CodeStart}}
{{Cl|PRINT}} "1. It goes to the subroutine."
{{Cl|PRINT}} "1. It goes to the subroutine."
{{Cl|GOSUB}} subroutine
{{Cl|PRINT}} "3. And it returns."
{{Cl|PRINT}} "3. And it returns."
{{Cl|END}}
subroutine:
{{Cl|PRINT}} "2. It is at the subroutine."
{{Cl|PRINT}} "2. It is at the subroutine."
{{Cl|RETURN}}
{{CodeEnd}}
@ -43,17 +43,17 @@ subroutine:
start:
a = a + 1
{{Cl|IF...THEN|IF}} a = 1 {{Cl|THEN}} {{Cl|GOSUB}} here: {{Cl|PRINT}} "It returned to IF a = 1": {{Cl|END}}
{{Cl|IF...THEN|IF}} a = 2 {{Cl|THEN}} {{Cl|GOSUB}} there: {{Cl|PRINT}} "It returned to IF a = 2": {{Cl|RETURN}}
{{Cl|IF...THEN|IF}} a = 1 {{Cl|THEN}} {{Cl|GOSUB}} here: {{Cl|PRINT}} "It returned to IF a = 1": {{Cl|END}}
{{Cl|IF...THEN|IF}} a = 2 {{Cl|THEN}} {{Cl|GOSUB}} there: {{Cl|PRINT}} "It returned to IF a = 2": {{Cl|RETURN}}
here:
{{Cl|PRINT}} "It went here."
{{Cl|PRINT}} "It went here."
{{Cl|GOTO}} start
there:
{{Cl|PRINT}} "It went there."
{{Cl|PRINT}} "It went there."
{{Cl|RETURN}}
{{CodeEnd}}
{{small|Code by Cyperium}}
@ -63,7 +63,7 @@ It went there.
It returned to IF a = 2
It returned to IF a = 1
{{OutputEnd}}
''Explanation:'' When a = 1 it uses GOSUB to go to "here:", then it uses GOTO to go back to "start:". a is increased by one so when a = 2 it uses GOSUB to go to "there:", and uses RETURN to go the last GOSUB (which is on the IF a = 2 line), it then encounters another RETURN which makes it return to the first GOSUB call we used on the IF a = 1 line.
''Explanation:'' When a = 1 it uses GOSUB to go to "here:", then it uses GOTO to go back to "start:". a is increased by one so when a = 2 it uses GOSUB to go to "there:", and uses RETURN to go the last GOSUB (which is on the IF a = 2 line), it then encounters another RETURN which makes it return to the first GOSUB call we used on the IF a = 1 line.
{{PageSeeAlso}}

View file

@ -19,11 +19,11 @@ The [[GOTO]] statement sends the procedure to a line label or a line number in t
{{PageExamples}}
''Example:''
{{CodeStart}} '' ''
1 {{Cl|PRINT}} "first line": {{Cl|GOTO}} gohere
2 {{Cl|PRINT}} "second line": {{Cl|GOTO}} 3
1 {{Cl|PRINT}} "first line": {{Cl|GOTO}} gohere
2 {{Cl|PRINT}} "second line": {{Cl|GOTO}} 3
gohere:
{{Cl|PRINT}} "third line"
{{Cl|PRINT}} "third line"
{{Cl|GOTO}} 2
3 {{Cl|END}} '' ''
@ -34,7 +34,7 @@ third line
second line
{{OutputEnd}}
:''Explanation:'' After it prints "first line" it goes to the line label "gohere" where it prints "third line", then it goes to the line that is numbered "2" and prints "second line" and goes to line number 3 and an [[END]] statement which ends the program.
:''Explanation:'' After it prints "first line" it goes to the line label "gohere" where it prints "third line", then it goes to the line that is numbered "2" and prints "second line" and goes to line number 3 and an [[END]] statement which ends the program.
{{PageSeeAlso}}

View file

@ -1,17 +1,17 @@
The '''>''' condition symbol denotes that a value must be greater than another value for the condition to be True.
The '''>''' condition symbol denotes that a value must be greater than another value for the condition to be True.
''Example usage:'' IF x [[Greater_Than|>]] 320 THEN PRINT "Right of screen"
''Example usage:'' IF x [[Greater_Than|>]] 320 THEN PRINT "Right of screen"
* Statements will evaluate as True or -1 when the first value is greater or False or 0 when equal or the first value is less.
* More than one > symbol in a numerical statement will create a [[Boolean]] evaluation of the ensuing numerical value.
* More than one > symbol in a numerical statement will create a [[Boolean]] evaluation of the ensuing numerical value.
''See also:''
* [[Equal|=]]
* [[Not_Equal|<>]]
* [[Not_Equal|<>]]
* [[Less_Than|<]]
* [[Relational Operations]]

View file

@ -1,13 +1,13 @@
The '''>=''' condition symbol denotes that a value must be greater than or equal to another value for the condition to be True.
The '''>=''' condition symbol denotes that a value must be greater than or equal to another value for the condition to be True.
''Example usage:'' IF x [[Greater_Than|>]] 320 THEN PRINT "Right or center of screen"
''Example usage:'' IF x [[Greater_Than|>]] 320 THEN PRINT "Right or center of screen"
''See also:''
* [[Equal|=]]
* [[Not_Equal|<>]]
* [[Not_Equal|<>]]
* [[Less_Than_Or_Equal|<=]]
* [[Relational Operations]]

View file

@ -8,16 +8,16 @@ The [[HEX$]] function returns the base 16 hexadecimal representation of an [[INT
{{PageDescription}}
* The function returns the string hexadecimal (base-16) representation of {{Parameter|decimalNumber}}.
* The function does not return a leading sign space so [[LTRIM$]] is not necessary.
<!-- Confusing hack hidden: * Can be used in place of [[STR$]] to trim both sides of positive decimal values 0 to 9 only.}} -->
* [[VAL]] can convert the string value back to a decimal value by prefixing the string return with "&H": {{InlineCode}}dec = VAL("&H" + hexvar$){{InlineCodeEnd}}.
<!-- Confusing hack hidden: * Can be used in place of [[STR$]] to trim both sides of positive decimal values 0 to 9 only.}} -->
* [[VAL]] can convert the string value back to a decimal value by prefixing the string return with "&H": {{InlineCode}}dec = VAL("&H" + hexvar$){{InlineCodeEnd}}.
{{PageExamples}}
''Example 1:'' Comparing decimal, hexadecimal and octal string values 0 to 15.
{{CodeStart}} '' ''
LOCATE 2, 20: PRINT " Decimal | Hexadecimal | Octal "
LOCATE 3, 20: PRINT "-----------+-------------+--------"
template$ = " \ \ | \\ | \\ "
LOCATE 2, 20: PRINT " Decimal | Hexadecimal | Octal "
LOCATE 3, 20: PRINT "-----------+-------------+--------"
template$ = " \ \ | \\ | \\ "
FOR n% = 0 TO 15
LOCATE 4 + n%, 20: {{Cl|PRINT USING}} template$; {{Cl|STR$}}(n%); {{Cl|HEX$}}(n%); {{Cl|OCT$}}(n%)
@ -49,8 +49,8 @@ NEXT n% '' ''
''Example 2:'' Converting hex value to decimal.
{{CodeStart}}
h$ = {{Cl|HEX$}}(255)
{{Cl|PRINT}} "Hex: "; h$
{{Cl|PRINT}} "Converting Hex value to Decimal:"; {{Cl|VAL}}("&H" + h$)
{{Cl|PRINT}} "Hex: "; h$
{{Cl|PRINT}} "Converting Hex value to Decimal:"; {{Cl|VAL}}("&H" + h$)
{{CodeEnd}}
{{OutputStart}}

View file

@ -38,10 +38,10 @@
{{Template:RelationalTable}}
<center> When evaluating a number value, no IF value > 0 operation is necessary for values not 0. Use: IF value THEN </center>
<center> When evaluating a number value, no IF value > 0 operation is necessary for values not 0. Use: IF value THEN </center>
<center>'''Boolean Conditional Operators:'''</center>
<center>'''Boolean Conditional Operators:'''</center>
:::::* [[AND (boolean)]] can be used to add extra conditions to a boolean statement evaluation.
@ -49,28 +49,28 @@
:::::* Parenthesis are allowed inside of boolean statements to clarify an evaluation.
<center>'''Mathematical Logical operators:'''</center>
<center>* Truth table of the 6 BASIC Logical Operators:</center>
<center>'''Mathematical Logical operators:'''</center>
<center>* Truth table of the 6 BASIC Logical Operators:</center>
{{Template:LogicalTruthTable}}
<center>* '''Note that Basic returns -1 for True and 0 for False.'''</center>
<center>* '''Note that Basic returns -1 for True and 0 for False.'''</center>
{{PageExamples}}
''Example 1:'' In a one line IF statement, only [[REM]] can be used to comment out the action without an [[END IF]] error:
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter a number over or under 100: ", x
{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}} {{Cl|PRINT}} x
{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}} {{Cl|REM}} {{Cl|PRINT}} x '' '
{{Cl|INPUT}} "Enter a number over or under 100: ", x
{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}} {{Cl|PRINT}} x
{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}} {{Cl|REM}} {{Cl|PRINT}} x '' '
{{CodeEnd}}
''Example 2:'' IF statement blocks require that the IF THEN and END IF statements be separate from the code executed.
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter a number over or under 100: ", x
{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}}
{{Cl|INPUT}} "Enter a number over or under 100: ", x
{{Cl|IF...THEN|IF}} x > 100 {{Cl|THEN}}
y = 200
{{Cl|PRINT}} y
{{Cl|PRINT}} x
@ -80,38 +80,38 @@
''Example 3:'' True or False evaluation of a numerical value executes only when the value is not 0. '''Cannot evaluate [[STRING]] values.'''
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter a number or just hit Enter: ", x
{{Cl|INPUT}} "Enter a number or just hit Enter: ", x
{{Cl|IF...THEN|IF}} x {{Cl|THEN}} {{Cl|PRINT}} x '' ''
{{CodeEnd}}
:Example will only print if a numerical value is True (positive or negative). (Equivalent to: IF x > 0 OR x < 0 THEN evaluation)
:Example will only print if a numerical value is True (positive or negative). (Equivalent to: IF x > 0 OR x < 0 THEN evaluation)
''Example 4:'' Multiple evaluations using parenthesis to determine the order.
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter a number over or under 100 or 50: ", value
{{Cl|IF...THEN|IF}} (value% > 100 {{Cl|AND (boolean)|AND}} value% < 200) {{Cl|OR (boolean)|OR}} value% = 50 {{Cl|THEN}} {{Cl|PRINT}} "OK" '' ''
{{Cl|INPUT}} "Enter a number over or under 100 or 50: ", value
{{Cl|IF...THEN|IF}} (value% > 100 {{Cl|AND (boolean)|AND}} value% < 200) {{Cl|OR (boolean)|OR}} value% = 50 {{Cl|THEN}} {{Cl|PRINT}} "OK" '' ''
{{CodeEnd}}
''Example 5:'' Using multiple IF options in a one line statement.
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter a number over or under 200: ", x
{{Cl|IF...THEN|IF}} x > 200 {{Cl|THEN}} {{Cl|PRINT}} "High" {{Cl|{{Cl|ELSEIF}}}} x < 0 {{Cl|THEN}} {{Cl|PRINT}} "Low" {{Cl|{{Cl|ELSE}}}} {{Cl|PRINT}} "OK"
{{Cl|INPUT}} "Enter a number over or under 200: ", x
{{Cl|IF...THEN|IF}} x > 200 {{Cl|THEN}} {{Cl|PRINT}} "High" {{Cl|{{Cl|ELSEIF}}}} x < 0 {{Cl|THEN}} {{Cl|PRINT}} "Low" {{Cl|{{Cl|ELSE}}}} {{Cl|PRINT}} "OK"
'' ''
{{CodeEnd}}
''Example 6:'' [[STRING]] values can be compared using greater than, less than, not equal to or equal to operators only.
{{CodeStart}} '' ''
PRINT "Press a letter key: ";
PRINT "Press a letter key: ";
Key$ = {{Cl|INPUT$}}(1)
PRINT Key$
IF Key$ >= {{Cl|CHR$}}(65) AND Key$ <= {{Cl|CHR$}}(90) THEN PRINT "A to Z"
IF Key$ >= {{Cl|CHR$}}(65) AND Key$ <= {{Cl|CHR$}}(90) THEN PRINT "A to Z"
{{CodeEnd}}
: ''Explanation:'' Long [[STRING]] expression values are compared by their cumulative [[ASCII]] code values.
<center>'''QBasic decimal point value comparison errors'''</center>
<center>'''QBasic decimal point value comparison errors'''</center>
* Floating decimal point numerical values may not be compared as exactly the same value. QB64 will compare them the same.
:''Example:'' QBasic would print ''unequal'' in the IF comparison code below even though it is exactly the same value printed.
{{CodeStart}} '' ''
@ -119,7 +119,7 @@ x# = 5 / 10
y# = 6 / 10
z# = x# + y#
{{Cl|PRINT}} x#, y#, z#
{{Cl|IF...THEN|IF}} x# + y# = z# {{Cl|THEN}} {{Cl|PRINT}} "equal" {{Cl|ELSE}} {{Cl|PRINT}} "unequal" '' ''
{{Cl|IF...THEN|IF}} x# + y# = z# {{Cl|THEN}} {{Cl|PRINT}} "equal" {{Cl|ELSE}} {{Cl|PRINT}} "unequal" '' ''
{{CodeEnd}}
: Note: QB64 will make the calculation correctly and print ''equal''. Change older program code that relies on the error accordingly.

View file

@ -7,11 +7,11 @@ The [[INKEY$]] function returns user input as [[ASCII]] [[STRING]] character(s)
{{PageDescription}}
* Returns [[ASCII]] character string values in upper or lower cases. See: [[UCASE$]] and [[LCASE$]]
* Returns "" if no key has been pressed since the last keyboard read.
* Returns "" if no key has been pressed since the last keyboard read.
* Some control keys cannot be read by INKEY$ or will return 2 byte [[ASCII]] codes.
* INKEY$ can also be used to clear a [[SLEEP]] key press or the keyboard buffer in a loop.
* Assign the INKEY$ return to a string variable to save the key entry.
* <span style="font-family: Courier New, monospace, Courier; background: #dddddd">[[LOCATE]] , , 1</span> displays the INKEY$ cursor. Use <span style="font-family: Courier New, monospace, Courier; background: #dddddd">LOCATE , , 0</span> to turn it off.
* <span style="font-family: Courier New, monospace, Courier; background: #dddddd">[[LOCATE]] , , 1</span> displays the INKEY$ cursor. Use <span style="font-family: Courier New, monospace, Courier; background: #dddddd">LOCATE , , 0</span> to turn it off.
* Use [[_DEST]] [[_CONSOLE]] before reading INKEY$ to receive input from a [[$CONSOLE|console]] window.
* Returns can be evaluated as certain [[ASCII]] characters or codes.
{{WhiteStart}}' '''ASCII Keyboard Codes'''
@ -24,10 +24,10 @@ The [[INKEY$]] function returns user input as [[ASCII]] [[STRING]] character(s)
'''' 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 '''
@ -40,58 +40,58 @@ The [[INKEY$]] function returns user input as [[ASCII]] [[STRING]] character(s)
==Two Byte Combinations==
* INKEY$ 2 byte combinations always begin with [[CHR$]](0). [[ASC]] will always read the first byte code as zero.
* Read the second byte code using: '''{{text|code2 <nowiki>=</nowiki> ASC(press$, 2)|green}}'''
* Read the second byte code using: '''{{text|code2 <nowiki>=</nowiki> ASC(press$, 2)|green}}'''
<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: '''{{text|status <nowiki>=</nowiki> _KEYDOWN(CVI(CHR$(0) + "P"))|green}}'''
:In '''QB64''', [[CVI]] can be used to get the [[_KEYDOWN]] 2-byte code value. Example: '''{{text|status <nowiki>=</nowiki> _KEYDOWN(CVI(CHR$(0) + "P"))|green}}'''
{{PageExamples}}
''Example 1:'' Clearing the keyboard buffer after [[SLEEP]] delays for later [[INPUT]].
{{CodeStart}}{{Cl|PRINT}} "Press any keyboard typing key to end SLEEP"
{{CodeStart}}{{Cl|PRINT}} "Press any keyboard typing key to end SLEEP"
{{Cl|SLEEP}}
{{Cl|DO}}: K$ = {{Cl|INKEY$}}: {{Cl|PRINT}} K$: {{Cl|LOOP}} {{Cl|UNTIL}} K$ = "" '' ''
{{Cl|DO}}: K$ = {{Cl|INKEY$}}: {{Cl|PRINT}} K$: {{Cl|LOOP}} {{Cl|UNTIL}} K$ = "" '' ''
{{CodeEnd}}
:''Explanation:'' [[SLEEP]] key presses will be kept in the keyboard buffer and may be added into an [[INPUT]] later.
:See also: [[_KEYCLEAR]]
@ -100,39 +100,39 @@ The [[INKEY$]] function returns user input as [[ASCII]] [[STRING]] character(s)
''Example 2:'' Entering a Ctrl + letter keypress combination will print [[ASCII]] Control characters 1 to 26. .
{{CodeStart}}DO
K$ = {{Cl|INKEY$}}
{{Cl|IF...THEN|IF}} K$ <> "" {{Cl|THEN}} {{Cl|PRINT}} K$; " ";
{{Cl|IF...THEN|IF}} K$ <> "" {{Cl|THEN}} {{Cl|PRINT}} K$; " ";
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27) 'Esc key exit '' ''
{{CodeEnd}}
: ''Note:'' The above code will print Esc arrow, Backspace symbol, and 2 byte characters led by CHR$(0) in addition to normal keys.
''Example 3:'' Use [[UCASE$]](INKEY$) in a keyboard read loop looking for uppercase "Y" or "N" user inputs to avoid multiple IF statements.
''Example 3:'' Use [[UCASE$]](INKEY$) in a keyboard read loop looking for uppercase "Y" or "N" user inputs to avoid multiple IF statements.
{{CodeStart}} '' ''
{{Cl|DO...LOOP|DO}}
{{Cl|PRINT}} "Do you want to continue? (Y/N): "; 'semicolon saves position for user entry
{{Cl|PRINT}} "Do you want to continue? (Y/N): "; 'semicolon saves position for user entry
{{Cl|DO...LOOP|DO}}: K$ = {{Cl|UCASE$}}({{Cl|INKEY$}}) 'change any user key press to uppercase
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = "Y" {{Cl|OR (boolean)|OR}} K$ = "N"
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = "Y" {{Cl|OR (boolean)|OR}} K$ = "N"
{{Cl|PRINT}} K$ 'print valid user entry
{{Cl|IF...THEN|IF}} K$ = "N" {{Cl|THEN}} {{Cl|END}}
{{Cl|IF...THEN|IF}} K$ = "N" {{Cl|THEN}} {{Cl|END}}
{{Cl|LOOP}} '' ''
{{CodeEnd}}
''Example 4:'' Getting just number values entered by a user in an INKEY$ input loop.
{{CodeStart}} '' ''
{{Cl|LOCATE}} 10, 10: {{Cl|PRINT}} "Enter a number value: ";
{{Cl|LOCATE}} 10, 10: {{Cl|PRINT}} "Enter a number value: ";
{{Cl|DO}}: {{Cl|SLEEP}}
K$ = {{Cl|INKEY$}}
{{Cl|IF}} K$ >= {{Cl|CHR$}}(48) {{Cl|AND (boolean)|AND}} K$ <= {{Cl|CHR$}}(57) {{Cl|THEN}} entry$ = entry$ + K$ ' numbers only
{{Cl|IF}} K$ >= {{Cl|CHR$}}(48) {{Cl|AND (boolean)|AND}} K$ <= {{Cl|CHR$}}(57) {{Cl|THEN}} entry$ = entry$ + K$ ' numbers only
L = {{Cl|LEN}}(entry$) ' check entry length for possible backspace
{{Cl|IF}} K$ = {{Cl|CHR$}}(46) {{Cl|AND (boolean)|AND}} flag = 0 {{Cl|THEN}} entry$ = entry$ + K$: flag = 1: mark = L ' decimal point
{{Cl|IF}} K$ = {{Cl|CHR$}}(8) {{Cl|AND (boolean)|AND}} L > 0 {{Cl|THEN}} ' backspace pressed and entry has a length
{{Cl|IF}} K$ = {{Cl|CHR$}}(8) {{Cl|AND (boolean)|AND}} L > 0 {{Cl|THEN}} ' backspace pressed and entry has a length
entry$ = {{Cl|MID$}}(entry$, 1, L - 1) ' remove one character from entry$
{{Cl|IF}} {{Cl|LEN}}(entry$) < mark {{Cl|THEN}} flag = 0 ' allow decimal point entry if other was removed.
{{Cl|LOCATE}} {{Cl|CSRLIN}}, {{Cl|POS}}(0) - 1: {{Cl|PRINT}} {{Cl|SPACE$}}(1); ' remove end character from screen
{{Cl|END IF}}
{{Cl|LOCATE}} 10, 32: {{Cl|PRINT}} entry$; ' display entry to user (semicolon required for correct {{Cl|POS}})
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(13) {{Cl|AND (boolean)|AND}} L > 0 'assures something is entered '' ''
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(13) {{Cl|AND (boolean)|AND}} L > 0 'assures something is entered '' ''
{{CodeEnd}}
: ''Explanation:'' [[SLEEP]] waits for a keypress. It also allows background programs to share the processor and it leaves the keypress in the buffer for INKEY$. Keyboard string number characters range from [[ASCII]] codes 48 to 57. Any other entry is ignored by the IF statement. A decimal point (code 46) entry is allowed once in the input. The flag value stops further decimal point additions. Backspacing (code 8) is also allowed if the entry has at least one character. The cursor column returned by [[POS]](0) reverts too after the end of the entry when printed each loop. The loop exits when [Enter] (code 13) is pressed and the entry has a length.
@ -140,17 +140,17 @@ The [[INKEY$]] function returns user input as [[ASCII]] [[STRING]] character(s)
''Example 5:'' Using arrow keys to move a text character. A change from a previous position tells program when to PRINT:
{{CodeStart}}movey = 1: movex = 1 'text coordinates can never be 0
at$ = "@" 'text sprite could be almost any ASCII character
at$ = "@" 'text sprite could be almost any ASCII character
{{Cl|LOCATE}} movey, movex: {{Cl|PRINT}} at$;
DO
px = movex: py = movey 'previous positions
B$ = {{Cl|INKEY$}}
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(72) {{Cl|AND (boolean)|AND}} movey > 1 {{Cl|THEN}} movey = movey - 1 'rows 1 to 23 only
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(72) {{Cl|AND (boolean)|AND}} movey > 1 {{Cl|THEN}} movey = movey - 1 'rows 1 to 23 only
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(80) {{Cl|AND (boolean)|AND}} movey < 23 {{Cl|THEN}} movey = movey + 1
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(75) {{Cl|AND (boolean)|AND}} movex > 1 {{Cl|THEN}} movex = movex - 1 'columns 1 to 80 only
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(75) {{Cl|AND (boolean)|AND}} movex > 1 {{Cl|THEN}} movex = movex - 1 'columns 1 to 80 only
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(77) {{Cl|AND (boolean)|AND}} movex < 80 {{Cl|THEN}} movex = movex + 1
{{Cl|IF...THEN|IF}} px <> movex {{Cl|OR (boolean)|OR}} py <> movey {{Cl|THEN}} 'only changes when needed
{{Cl|IF...THEN|IF}} px <> movex {{Cl|OR (boolean)|OR}} py <> movey {{Cl|THEN}} 'only changes when needed
{{Cl|LOCATE}} py, px: {{Cl|PRINT}} {{Cl|SPACE$}}(1); 'erase old sprite
{{Cl|LOCATE}} movey, movex: {{Cl|PRINT}} at$; 'show new position
{{Cl|END IF}}
@ -170,24 +170,24 @@ DO
x = 0
y = 0
image = {{Cl|_LOADIMAGE}}("QB64bee.png") 'Here I actually used the QB64 icon
image = {{Cl|_LOADIMAGE}}("QB64bee.png") 'Here I actually used the QB64 icon
DO
{{Cl|_PUTIMAGE}} (x, y), image
DO
Keypress = {{Cl|UCASE$}}({{Cl|INKEY$}})
' ***** The following line detects the arrow keys *****
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(Keypress) > 1 {{Cl|THEN}} Keypress = {{Cl|RIGHT$}}(Keypress, 1)
{{Cl|LOOP}} {{Cl|UNTIL}} Keypress > ""
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(Keypress) > 1 {{Cl|THEN}} Keypress = {{Cl|RIGHT$}}(Keypress, 1)
{{Cl|LOOP}} {{Cl|UNTIL}} Keypress > ""
{{Cl|CLS}} ' blank screen after valid key press to avoid smearing image on page
{{Cl|SELECT CASE}} Keypress
{{Cl|CASE}} "W", "H": y = y - 10 'Up
{{Cl|CASE}} "A", "K": x = x - 10 'Left
{{Cl|CASE}} "S", "P": y = y + 10 'Down
{{Cl|CASE}} "D", "M": x = x + 10 'Right
{{Cl|CASE}} "Q", {{Cl|CHR$}}(27): {{Cl|END}} 'Q or Esc Ends prog.
{{Cl|CASE}} "W", "H": y = y - 10 'Up
{{Cl|CASE}} "A", "K": x = x - 10 'Left
{{Cl|CASE}} "S", "P": y = y + 10 'Down
{{Cl|CASE}} "D", "M": x = x + 10 'Right
{{Cl|CASE}} "Q", {{Cl|CHR$}}(27): {{Cl|END}} 'Q or Esc Ends prog.
{{Cl|END SELECT}}
{{Cl|_PUTIMAGE}} (x, y), image
{{Cl|LOOP}} '' ''
@ -198,13 +198,15 @@ DO
''Example 7:'' Creating upper [[ASCII]] characters in a QB program using '''Alt +''' three number keys:
{{CodeStart}}
DO
A$ = "": {{Cl|WHILE}} A$ = "": A$ = {{Cl|INKEY$}}: {{Cl|WEND}}
A$ = "": {{Cl|
2a79
WHILE}} A$ = "": A$ = {{Cl|INKEY$}}: {{Cl|WEND}}
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(A$) = 2 {{Cl|THEN}} '2 byte INKEY$ return
B$ = {{Cl|RIGHT$}}(A$, 1) 'read second byte
b% = {{Cl|ASC}}(B$) 'read second byte code
{{Cl|IF...THEN|IF}} b% > 119 {{Cl|AND (boolean)|AND}} b% < 130 {{Cl|THEN}} ' Alt + number codes only
{{Cl|IF...THEN|IF}} b% > 119 {{Cl|AND (boolean)|AND}} b% < 130 {{Cl|THEN}} ' Alt + number codes only
C% = b% - 119 ' convert to actual number
{{Cl|IF...THEN|IF}} C% > 9 {{Cl|THEN}} C% = 0
{{Cl|IF...THEN|IF}} C% > 9 {{Cl|THEN}} C% = 0
num$ = num$ + {{Cl|LTRIM$}}({{Cl|STR$}}(C%))
{{Cl|END IF}}
{{Cl|END IF}}

View file

@ -57,23 +57,23 @@ DO: {{Cl|_LIMIT}} 100 'adjust higher for faster
{{Cl|IF...THEN|IF}} ScanKey%(72) {{Cl|THEN}} RTpos = RTpos - 1
{{Cl|IF...THEN|IF}} ScanKey%(80) {{Cl|THEN}} RTpos = RTpos + 1
{{Cl|PRINT}} "Player 1 : "; ponescore; " Player 2 : "; ptwoscore
{{Cl|PRINT}} "Player 1 : "; ponescore; " Player 2 : "; ptwoscore
{{Cl|IF...THEN|IF}} x > xmax - 15 {{Cl|AND (boolean)|AND}} y >= RTpos {{Cl|AND (boolean)|AND}} y <= RTpos + 100 {{Cl|THEN}}
{{Cl|IF...THEN|IF}} x > xmax - 15 {{Cl|AND (boolean)|AND}} y >= RTpos {{Cl|AND (boolean)|AND}} y <= RTpos + 100 {{Cl|THEN}}
dx = -1
{{Cl|ELSEIF}} x > xmax {{Cl|THEN}}
{{Cl|ELSEIF}} x > xmax {{Cl|THEN}}
ponescore = ponescore + 1
{{Cl|GOSUB}} begin
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} x < xmin + 15 {{Cl|AND (boolean)|AND}} y >= LTpos {{Cl|AND (boolean)|AND}} y <= LTpos + 100 {{Cl|THEN}}
{{Cl|IF...THEN|IF}} x < xmin + 15 {{Cl|AND (boolean)|AND}} y >= LTpos {{Cl|AND (boolean)|AND}} y <= LTpos + 100 {{Cl|THEN}}
dx = 1
{{Cl|ELSEIF}} x < xmin {{Cl|THEN}}
ptwoscore = ptwoscore + 1
{{Cl|GOSUB}} begin
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} y > ymax - 5 {{Cl|THEN}} dy = -1
{{Cl|IF...THEN|IF}} y > ymax - 5 {{Cl|THEN}} dy = -1
{{Cl|IF...THEN|IF}} y < ymin + 5 {{Cl|THEN}} dy = 1
' Display the sprite elsewhere on the screen
@ -110,6 +110,9 @@ ScanKey% = keyflags%(scancode%)
* [[INKEY$]], [[_KEYHIT]], [[_KEYDOWN]]
* [[Bitmaps]], [[Scancodes]] {{text|(keyboard)}}
* [[Port Access Libraries]] {{text|(COM or LPT registers)}}
===External Links===
* [http://en.wikipedia.org/wiki/Input/output_base_address#Common_I.2FO_base_address_device_assignments_in_IBM_PC_compatible_computers PC I/O base address device assignments]

View file

@ -33,7 +33,7 @@ PRINT year$ 'display the text entry '' ''
''Example 2:'' Reading bytes from a text file for an 80 wide screen mode.
{{CodeStart}} '' ''
{{Cl|LOCATE}} 5, 5, 1 'locate and display cursor
{{Cl|OPEN}} "Diary.txt" FOR {{Cl|INPUT (file mode)|INPUT}} AS #1 'open existing text file
{{Cl|OPEN}} "Diary.txt" FOR {{Cl|INPUT (file mode)|INPUT}} AS #1 'open existing text file
text$ = {{Cl|INPUT$}}(70, 1)
{{Cl|LOCATE}} 5, 6, 0: PRINT text$ 'print text and turn cursor off '' ''
{{CodeEnd}}
@ -41,7 +41,7 @@ text$ = {{Cl|INPUT$}}(70, 1)
''Example 3:'' Getting the entire text file data as one string value.
{{CodeStart}} '' ''
{{Cl|OPEN}} "Diary.txt FOR {{Cl|BINARY}} AS #1 'open an existing file up to 32767 bytes
{{Cl|OPEN}} "Diary.txt FOR {{Cl|BINARY}} AS #1 'open an existing file up to 32767 bytes
IF {{Cl|LOF}}(1) <= 32767 THEN Text$ = {{Cl|INPUT$}}(LOF(1), 1)
{{Cl|CLOSE}} #1 '' ''
{{CodeEnd}}

View file

@ -2,13 +2,13 @@ The [[INPUT]] statement requests a [[STRING]] or numerical keyboard entry from t
{{PageSyntax}}
: [[INPUT]] [;] "[Question or statement text]"{,|;} {{Parameter|variable}}[, ...]
: [[INPUT]] [;] "[Question or statement text]"{,|;} {{Parameter|variable}}[, ...]
: [[INPUT]] ; {{Parameter|variable}}[, ...]
{{Parameters}}
* A [[semicolon]] after the [[INPUT]] keyword keeps the entry on the same row after enter is pressed and prevents the screen contents from rolling up.
* The optional prompt "Question or statement text" must be a literal predefined [[STRING|string]]. '''The prompt cannot use a variable.'''
* The optional prompt "Question or statement text" must be a literal predefined [[STRING|string]]. '''The prompt cannot use a variable.'''
* [[Quotation mark]]s are required except when a semicolon follows [[INPUT]]. A question mark will appear before the cursor.
* A [[semicolon]] immediately after the text statement will display a question mark with a space after it. Use a [[comma]] for input statements.
@ -17,17 +17,17 @@ The [[INPUT]] statement requests a [[STRING]] or numerical keyboard entry from t
* '''QB64''' does not return ''Redo from start'' errors like QBasic did, as user input is limited to the scope of the variable [[Data types|type]] used.
* Text entries (with a [[STRING]] variable]] can receive any characters, including numerical. '''QB64 will ignore commas in single variable text entries.'''
* The [[Data types|type]] of the {{Parameter|variable}} used to store user input determines the valid numerical range for value entries in QB64, with non-numerical characters limited to D, E, [[&H]], [[&O]] or [[&B]].
** For example, if you use an [[INTEGER]] variable, as in {{InlineCode}}INPUT "Initial value: ", myValue%{{InlineCodeEnd}}, the valid range is -32768 to 32767.
** For example, if you use an [[INTEGER]] variable, as in {{InlineCode}}INPUT "Initial value: ", myValue%{{InlineCodeEnd}}, the valid range is -32768 to 32767.
** [[INTEGER]], [[LONG]], and [[_INTEGER64]] entries will ignore decimal points entered and will use all numbers.
* INPUT can be used to get more than one {{Parameter|variable}} value from the user. Do so by separating input variables with commas in the code.
** The program must inform the user that more than one variable is requested, in order to enter each value separated with a comma at runtime.
** [[STRING|String]] and numerical variables can both be used in multiple entry requests separated by commas.
** '''QB64''' allows comma separated entries to be skipped by the user without generating an error.
* '''Use [[LINE INPUT]] for text input entries that may contain commas such as address or name entries.'''
* The user must press enter for the INPUT procedure to end. <!-- redundant: Multiple entries can be skipped. -->
* The user must press enter for the INPUT procedure to end. <!-- redundant: Multiple entries can be skipped. -->
* [[INPUT]] accepts the [[scientific notation]] letters D or E in [[SINGLE]] or [[DOUBLE]] numerical values.
* Numerical values starting with [[&H]], [[&O]] and [[&B]] can also be entered.
<!-- not valid for QB64, not worth mentioning then denying: * INPUT removes all leading or trailing spaces in a string value entry. '''QB64 does NOT remove those spaces!''' -->
<!-- not valid for QB64, not worth mentioning then denying: * INPUT removes all leading or trailing spaces in a string value entry. '''QB64 does NOT remove those spaces!''' -->
* The statement halts a program until enter is pressed, which may not be desired in programs using mouse input (see [[INKEY$]] loops).
* Use [[_DEST]] [[_CONSOLE]] before INPUT statements to receive input from a [[$CONSOLE|console]] window.
@ -35,9 +35,9 @@ The [[INPUT]] statement requests a [[STRING]] or numerical keyboard entry from t
{{PageExamples}}
''Example 1:'' Using a variable in an input text message using PRINT. INPUT prompts cannot use variables.
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter your name: ", name$
{{Cl|PRINT}} name$ + " please enter your age: ";: {{Cl|INPUT}} "", age% 'empty string with comma
{{Cl|PRINT}} name$ + " how much do you weigh"; : {{Cl|INPUT}} weight% 'no text adds ? '' ''
{{Cl|INPUT}} "Enter your name: ", name$
{{Cl|PRINT}} name$ + " please enter your age: ";: {{Cl|INPUT}} "", age% 'empty string with comma
{{Cl|PRINT}} name$ + " how much do you weigh"; : {{Cl|INPUT}} weight% 'no text adds ? '' ''
{{CodeEnd}}
:''Explanation:'' Use an empty string with a comma to eliminate the question mark that would appear without the string.
@ -45,9 +45,9 @@ The [[INPUT]] statement requests a [[STRING]] or numerical keyboard entry from t
''Example 2:'' How QB64 avoids a ''Redo from start'' multiple entry error. Use commas between values.
{{CodeStart}} '' ''
{{Cl|DO}} '' ''
{{Cl|INPUT}} "What is your name, age, and sex(M/F)"; name$, age%, sex$
{{Cl|INPUT}} "What is your name, age, and sex(M/F)"; name$, age%, sex$
{{Cl|LOOP}} {{Cl|UNTIL}} age% 'loop until age is not 0
{{Cl|IF}} age% >= 21 {{Cl|THEN}} {{Cl|PRINT}} "You can drink beer!" {{Cl|ELSE}} {{Cl|PRINT}} "You cannot drink beer yet!"
{{Cl|IF}} age% >= 21 {{Cl|THEN}} {{Cl|PRINT}} "You can drink beer!" {{Cl|ELSE}} {{Cl|PRINT}} "You cannot drink beer yet!"
{{Cl|END}} '' ''
{{CodeEnd}}
{{OutputStart}}
@ -62,12 +62,12 @@ You can drink beer!
{{Cl|SCREEN}} 12
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 29, 2 ' place cursor at beginning of prompt line
{{Cl|PRINT}} "Enter a name to search for... "; 'print prompt on screen with input to follow
{{Cl|COLOR}} 15: {{Cl|INPUT}} {{text|;|red}} "", name$ ' get search name from user
{{Cl|PRINT}} "Enter a name to search for... "; 'print prompt on screen with input to follow
{{Cl|COLOR}} 15: {{Cl|INPUT}} {{text|;|red}} "", name$ ' get search name from user
{{Cl|LOCATE}} 29, 2: {{Cl|PRINT}} {{Cl|SPC}}(78); ' erase previous prompt
n$ = {{Cl|UCASE$}}(name$) ' convert search name to upper case
{{Cl|COLOR}} 14' change foreground color to yellow
{{Cl|LOCATE}} 29, 2: {{Cl|PRINT}} "Searching..."; 'print message
{{Cl|LOCATE}} 29, 2: {{Cl|PRINT}} "Searching..."; 'print message
{{Cl|SLEEP}}
{{CodeEnd}}
{{OutputStart}}{{text|Enter a name to search for...|#FFFF00}} █

View file

@ -28,7 +28,7 @@
{{CodeStart}} '' ''
{{Cl|PRINT (TCP/IP statement)|PRINT}} #c, a$ ' sends the string value a$ (size is calculated by an INPUT)
PRINT #c, x% ' if x was equal to 5, this would send " 5 " (without the quotation marks)
PRINT #c, x% ' if x was equal to 5, this would send " 5 " (without the quotation marks)
'''INPUT #'''o, a$ ' reads the next available message (if arrived) or sets a$'s length to 0 '' ''
{{CodeEnd}}
:''Explanation:'' INPUT #o,x% 'effectively reads the next message, performs the VAL function upon it and stores the result in x%. If any part of this process doesn't work then EOF(o) will return -1.
@ -49,7 +49,7 @@
t! = TIMER + 3 'wait 3 seconds
DO
'''INPUT #'''myhost, aa%, bb#, cc$ 'when all variables are filled, EOF(myhost) returns 0
IF TIMER > t! THEN EXIT DO ' 3 second timeout
IF TIMER > t! THEN EXIT DO ' 3 second timeout
LOOP WHILE {{Cl|EOF}}(myhost) '' ''
{{CodeEnd}}
:''Explanation:'' Note that communications must be set up in advance for the host and user to know that more than one piece of data is available! Data timing also may affect those communications. Data could be missed using [[GET (TCP/IP statement)]] or [[PUT (TCP/IP statement)]]s as data lengths are unknown.

View file

@ -21,7 +21,7 @@ The '''INPUT''' file mode in an [[OPEN]] statement opens an existing file for [[
{{CodeStart}} '' ''
DIM Fdata$(100)
INPUT "Enter data file name: ", datafile$
INPUT "Enter data file name: ", datafile$
IF _FILEEXISTS(datafile$) THEN
D% = {{Cl|FREEFILE}}: count = 0
{{Cl|OPEN}} datafile$ FOR {{Cl|INPUT (file mode)|INPUT}} AS #D%
@ -31,7 +31,7 @@ The '''INPUT''' file mode in an [[OPEN]] statement opens an existing file for [[
IF count = 100 THEN {{Cl|EXIT}} DO ' don't exceed {{Cl|Arrays|array}} size!
LOOP
{{Cl|CLOSE}} #D%
ELSE : PRINT "File not found!"
ELSE : PRINT "File not found!"
END IF
{{CodeEnd}}
: ''Explanation:'' The [[_FILEEXISTS]] function is used before {{InlineCode}}OPEN datafile$ FOR INPUT AS #D%{{InlineCodeEnd}}, which would generate an error in case the file didn't exist.

View file

@ -25,14 +25,14 @@ The [[INPUT #]] file or port statement reads sequential data using one variable
{{PageExamples}}
''Example 1:'' Writes new data to a text file sequentially and reads it back to the program screen.
{{CodeStart}} '' ''
filename$ = "testfile.dat"
x = 1: y = 2: z$ = "Three"
filename$ = "testfile.dat"
x = 1: y = 2: z$ = "Three"
{{Cl|OPEN}} filename$ {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 'opens and clears an existing file or creates new empty file
{{Cl|WRITE (file statement)|WRITE}} #1, x, y, z$
{{Cl|CLOSE}} #1
{{Cl|PRINT}} "File created with data. Press a key!"
{{Cl|PRINT}} "File created with data. Press a key!"
K$ = {{Cl|INPUT$}}(1) 'press a key
{{Cl|OPEN}} filename$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #2 'opens a file to read it
@ -45,24 +45,24 @@ K$ = {{Cl|INPUT$}}(1) 'press a key
{{Cl|END}} '' ''
{{CodeEnd}}
{{OutputStart}} 1 2 Three
1,2,"Three"
1,2,"Three"
{{OutputEnd}}
: ''Screen output:'' [[PRINT]] string values will not display enclosing quotes. [[WRITE]] screen displays will.
{{TextStart}}1,2,"Three" '' '' {{TextEnd}}
{{TextStart}}1,2,"Three" '' '' {{TextEnd}}
: ''File content:'' [[WRITE (file statement)|WRITE]] string values will include quotation marks, but they are not required to read the file value as a string.
''Example 2:'' Commas inside of string values will not affect the INPUT value as those commas are not [[WRITE (file statement)|WRITE]] separators.
{{CodeStart}} '' ''
x$ = "Hello, how are you?"
y$ = "I'm fine."
x$ = "Hello, how are you?"
y$ = "I'm fine."
{{Cl|OPEN}} "testinp.dat" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1
{{Cl|OPEN}} "testinp.dat" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1
{{Cl|WRITE (file statement)|WRITE}} #1, x$, y$
{{Cl|CLOSE}} #1
{{Cl|OPEN}} "testinp.dat" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1
{{Cl|OPEN}} "testinp.dat" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1
{{Cl|INPUT (file statement)|INPUT}} #1, a$, b$
{{Cl|CLOSE}} #1
@ -71,8 +71,8 @@ y$ = "I'm fine."
{{Cl|WRITE}} a$, b$ '' ''
{{CodeEnd}}
{{OutputStart}}Hello, how are you? I'm fine.
"Hello, how are you?","I'm fine."{{OutputEnd}}
{{TextStart}}"Hello, how are you?","I'm fine."{{TextEnd}}
"Hello, how are you?","I'm fine."{{OutputEnd}}
{{TextStart}}"Hello, how are you?","I'm fine."{{TextEnd}}
: ''File content:'' Commas inside of strings delimited with quotes will be ignored. [[WRITE (file statement)|WRITE]] will always enclose string values in quotes.

View file

@ -28,14 +28,14 @@ The [[INSTR]] function searches for the first occurence of a search [[STRING]] w
{{PageExamples}}
''Example:'' Reading more than one instance of a word in a string using the INSTR return value as the start value plus 1.
{{CodeStart}} '' ''
text$ = "The cats and dogs where playing, even though dogs don't like cats."
text$ = "The cats and dogs where playing, even though dogs don't like cats."
{{Cl|DO...LOOP|DO}}
findcats% = {{Cl|INSTR}}(findcats% + 1, text$, "cats") ' find another occurance after
{{Cl|IF...THEN|IF}} findcats% {{Cl|THEN}} {{Cl|PRINT}} "There is 'cats' in the string at position:"; findcats%
findcats% = {{Cl|INSTR}}(findcats% + 1, text$, "cats") ' find another occurance after
{{Cl|IF...THEN|IF}} findcats% {{Cl|THEN}} {{Cl|PRINT}} "There is 'cats' in the string at position:"; findcats%
{{Cl|LOOP}} {{Cl|UNTIL}} findcats% = 0
findmonkey% = {{Cl|INSTR}}(text$, "monkeys") ' find any occurance?
PRINT findmonkey%; "'monkeys' were found so it returned:"; findmonkey% '' ''
findmonkey% = {{Cl|INSTR}}(text$, "monkeys") ' find any occurance?
PRINT findmonkey%; "'monkeys' were found so it returned:"; findmonkey% '' ''
{{CodeEnd}}
{{OutputStart}}There is 'cats' in the string at position: 5
There is 'cats' in the string at position: 62

View file

@ -6,9 +6,9 @@
* Integers do not use decimal point values but will round those off to the nearest even whole number.
* QBasic integer values can range from -32768 to 32767 without an "overflow" error.
* QBasic integer values can range from -32768 to 32767 without an "overflow" error.
* For larger integer values use the [[LONG]] integer type.
* '''QB64''' [[INTEGER]] values greater than 32767 become negative signed values instead of throwing an "overflow" error, as the top bit designates a negative value. See example 1 below.
* '''QB64''' [[INTEGER]] values greater than 32767 become negative signed values instead of throwing an "overflow" error, as the top bit designates a negative value. See example 1 below.
* '''QB64''' [[_UNSIGNED]] integers can range from 0 to 65535.
* '''QB64''' _UNSIGNED [[_INTEGER64]] values range from 0 to 18446744073709551615
* Many graphic programs require [[INTEGER]] arrays.

View file

@ -15,7 +15,7 @@ The [[INTERRUPT]] statement is an assembly routine for accessing computer inform
==QBasic/QuickBASIC==
* Available in QuickBASIC versions 4 and up and required an external library to be loaded. <!-- Command line: QB.EXE /L in QB4.5 --> '''QB64''' emulates the statement without an external library.
* Available in QuickBASIC versions 4 and up and required an external library to be loaded. <!-- Command line: QB.EXE /L in QB4.5 --> '''QB64''' emulates the statement without an external library.
* {{Parameter|intNum}} is the interrupt reference vector table address. For historic reference, see: [http://www.ctyme.com/intr/cat.htm Ralf Brown's Interrupt List]
* The [[TYPE]] definition below will work for both [[INTERRUPT]] and INTERRUPTX statement calls
* INTERRUPT can use all of the below TYPE elements when they are required.

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