1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-01 04:30:38 +00:00

Adds extra help files that were being ignored. [ci skip]

This commit is contained in:
FellippeHeitor 2019-04-14 22:20:04 -03:00
parent a3a1047a8a
commit cc00228635
38 changed files with 2967 additions and 0 deletions

View file

@ -0,0 +1,35 @@
'''$EXEICON''' pre-compiler metacommand embeds a designated icon file into the compiled EXE file to be viewed in Windows Explorer.
{{PageSyntax}}
: [[$EXEICON]]:'{{Parameter|iconfile.ico}}'
{{Parameters}}
* '{{Parameter|iconfile.ico}}' is a valid [https://en.wikipedia.org/wiki/ICO_(file_format) ICO file]
{{PageDescription}}
* Calling [[_ICON]] without an {{Parameter|imageHandle&}} uses the embeded icon, if available.
** Starting with '''build 20170906/64''', the window will automatically use the icon embedded by [[$EXEICON]], without having to call _ICON.
* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''.
{{PageExamples}}
''Example:'' Embeds a designated icon file into the compiled EXE which can be viewed in Windows Explorer folders.
{{CodeStart}}
{{Cl|$EXEICON}}:'mush.ico'
{{Cl|_ICON}}
{{CodeEnd}}{{small|Code and command by Fellippe Heitor}}
<center>[http://www.qb64.net/forum/index.php?action=dlattach;topic=13762.0;attach=4558 mush.ico download]</center>
{{PageSeeAlso}}
* [[_ICON]]
* [[_TITLE]]
{{PageNavigation}}

View file

@ -0,0 +1,39 @@
{{DISPLAYTITLE:$VERSIONINFO}}
The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resulting executable for identification purposes across the OS. Windows-only.
{{PageSyntax}}
: [[$VERSIONINFO]]:{{Parameter|key}}={{Parameter|value}}
{{Parameters}}
* Text ''keys'' can be: '''CompanyName, FileDescription, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, ProductName, Web, Comments'''
* Numeric {{Parameter|keys}} can be:'''FILEVERSION#''' and '''PRODUCTVERSION#'''
{{PageDescription}}
* Text and numerical values are string literals without quotes entered by programmer. '''No variables are accepted.''' (variable names would be interpreted as literals).
* Numeric key=''value'' must be 4 comma-separated numerical text values entered by programmer which usually stand for major, minor, revision and build numbers).
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]].
==Availability==
* '''Build 20170429/52 and up'''.
{{PageExamples}}
''Example:'' Adding metadata to a Windows exe compiled with QB64:
{{CodeStart}}
{{Cl|$VERSIONINFO}}:CompanyName=Your company name goes here
{{Cl|$VERSIONINFO}}:FILEVERSION#=1,0,0,0
{{Cl|$VERSIONINFO}}:PRODUCTVERSION#=1,0,0,0
{{CodeEnd}}
{{PageSeeAlso}}
* [[$EXEICON]]
* [[_ICON]]
* [https://msdn.microsoft.com/library/windows/desktop/aa381058(v=vs.85).aspx VERSIONINFO resource (MSDN)]
{{PageNavigation}}

45
internal/help/.txt Normal file
View file

@ -0,0 +1,45 @@
The '''\''' mathematical operator performs [[INTEGER]] division on a numerical value.
{{PageSyntax}}
::: return_value = number '''\''' divisor
{{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.
* Return values will be [[INTEGER]] or [[LONG]] value types only.
* Rounding is done to the closest EVEN [[INTEGER|integer]] or [[LONG|long integer]] value.
* Use the [[/]] integer division operator for [[SINGLE]] or [[DOUBLE]] floating decimal point return values.
* Division and multiplication operations are performed before addition and subtraction in Qbasic's order of operations.
''Example:'' Displays how floating decimal point values are rounded to the closest even [[INTEGER|integer]] value.
{{CodeStart}} '' ''
{{Cl|PRINT}} 0.5 \ 1
{{Cl|PRINT}} 1.5 \ 1
{{Cl|PRINT}} 2.5 \ 1
{{Cl|PRINT}} 3.5 \ 1
{{Cl|PRINT}} 4.5 \ 1
{{Cl|PRINT}} 5.5 \ 1 '' ''
{{CodeEnd}}
{{OutputStart}}0
2
2
4
4
6
{{OutputEnd}}
''See also:''
* [[MOD|MOD (remainder division operator)]]
* [[/|/ (normal division operator)]]
* [[INT]], [[CINT]], [[FIX]], [[_ROUND]]
* [[Mathematical Operations]]
{{PageNavigation}}

479
internal/help/ASCII.txt Normal file
View file

@ -0,0 +1,479 @@
==ASCII and Extended Codes==
{| align="right"
| __TOC__
|}
<center>[http://en.wikipedia.org/wiki/Code_page_437 MS-DOS code page 437]:</center>
:{| border="1" cellpadding="2"
! colspan="8"|[http://ascii.cl/control-characters.htm ASCII Control 0 to 31]   |        ASCII Keyboard Character Codes 32 to 127               
|-
! Code ||Character <tt>[key]</tt> || Code || Character || Code || Character || Code || Character
|-
| 0 ||        (NUL) || 32 ||  [<tt>[[SPACE$|Spacebar]]</tt>]|| 64 ||  <tt>@</tt> || 96 ||  <tt>`</tt>
|-
| 1 ||  ☺   (SOH) || 33 ||  ! || 65 ||  A || 97 ||  a
|-
| 2 ||  ☻   (STX) || 34 ||  " || 66 ||  B || 98 ||  b
|-
| 3 ||  ♥   (ETX) || 35 ||  # || 67 ||  C || 99 ||  c
|-
| 4 ||  ♦   (EOT) || 36 ||  $ || 68 ||  D || 100 ||  d
|-
| 5 ||  ♣   (ENQ) || 37 ||  % || 69 ||  E || 101 ||  e
|-
| 6 ||  ♠   (ACK) || 38 ||  & || 70 ||  F || 102 ||  f
|-
| 7 ||  •   (BEL)   <tt>[[BEEP]]</tt>|| 39 ||  ' || 71 ||  G || 103 ||  g
|-
| 8 ||  ◘    [<tt>BackSpace</tt>] **|| 40 ||  ( || 72 ||  H || 104 ||  h
|-
| 9 ||  ○   (HT)    [<tt>TAB</tt>] **|| 41 ||  ) || 73 ||  I || 105 ||   i
|-
| 10 ||  ◙   (LineFeed)  **|| 42 ||  * || 74 ||  J || 106 ||  j
|-
| 11 ||  ♂   (VT) **|| 43 ||  + || 75 ||  K || 107 ||  k
|-
| 12 ||  ♀   (FormFeed) **|| 44 ||  , || 76 ||  L || 108 ||  l
|-
| 13 ||  ♪   (CR) [<tt>Enter</tt>] **|| 45 ||  - || 77 ||  M || 109 ||  m
|-
| 14 ||  ♫   (SO) || 46 ||  . || 78 ||  N || 110 ||  n
|-
| 15 ||  ☼   (SI) || 47 ||  / || 79 ||  O || 111 ||  o
|-
| 16 ||  ►   (DLE) || 48 ||  0 || 80 ||  P || 112 ||  p
|-
| 17 ||  ◄   (DC1) || 49 ||  1 || 81 ||  Q || 113 ||  q
|-
| 18 ||  ↕   (DC2) || 50 ||  2 || 82 ||  R || 114 ||  r
|-
| 19 ||  ‼   (DC3) || 51 ||  3 || 83 ||  S || 115 ||  s
|-
| 20 ||  ¶   (DC4) || 52 ||  4 || 84 ||  T || 116 ||  t
|-
| 21 ||  §   (NAK) || 53 ||  5 || 85 ||  U || 117 ||  u
|-
| 22 ||  ▬   (SYN) || 54 ||  6 || 86 ||  V || 118 ||  v
|-
| 23 ||  ↨   (ETB) || 55 ||  7 || 87 ||  W || 119 ||  w
|-
| 24 ||  ↑   (CAN) || 56 ||  8 || 88 ||  X || 120 ||  x
|-
| 25 ||  ↓   (EM) || 57 ||  9 || 89 ||  Y || 121 ||  y
|-
| 26 ||  →   (SUB)    <tt>[[EOF]]</tt> || 58 ||  : || 90 ||  Z || 122 ||  z
|-
| 27 ||  ←   (ESC)   [<tt>Esc</tt>]|| 59 ||  ; || 91 ||  [ || 123 ||  {
|-
| 28 ||  ∟   (FS) **|| 60 ||  < || 92 ||  \ || 124 ||  <nowiki>|</nowiki>
|-
| 29 ||  ↔   (GS) **|| 61 ||  = || 93 ||  ] || 125 ||  }
|-
| 30 ||  ▲   (RS) **|| 62 ||  > || 94 ||  ^ || 126 ||  ~
|-
| 31 ||  ▼   (US) **|| 63 ||  ? || 95 ||  _ || 127 ||  ⌂ (DEL) *
|-
! colspan="8"| IBM, International, graphical, mathematical and other characters
|-
! Code || Character || Code || Character || Code || Character || Code || Character
|-
| 128 ||  Ç || 160 ||  á || 192 ||  └ || 224 ||  α
|-
| 129 ||  ü || 161 ||  í || 193 ||  ┴ || 225 ||  ß
|-
| 130 ||  é || 162 ||  ó || 194 ||  ┬ || 226 ||  Γ
|-
| 131 ||  â || 163 ||  ú || 195 ||  ├ || 227 ||  π
|-
| 132 ||  ä || 164 ||  ñ || 196 ||  ─ || 228 ||  Σ
|-
| 133 ||  à || 165 ||  Ñ || 197 ||  ┼ || 229 ||  σ
|-
| 134 ||  å || 166 ||  ª || 198 ||  ╞ || 230 ||  µ
|-
| 135 ||  ç || 167 ||  º || 199 ||  ╟ || 231 ||  τ
|-
| 136 ||  ê || 168 ||  ¿ || 200 ||  ╚ || 232 ||  Φ
|-
| 137 ||  ë || 169 ||  ⌐ || 201 ||  ╔ || 233 ||  Θ
|-
| 138 ||  è || 170 ||  ¬ || 202 ||  ╩ || 234 ||  Ω
|-
| 139 ||  ï || 171 ||  ½ || 203 ||  ╦ || 235 ||  δ
|-
| 140 ||  î || 172 ||  ¼ || 204 ||  ╠ || 236 ||  ∞
|-
| 141 ||  ì || 173 ||  ¡ || 205 ||  ═ || 237 ||  φ
|-
| 142 ||  Ä || 174 ||  « || 206 ||  ╬ || 238 ||  ε
|-
| 143 ||  Å || 175 ||  » || 207 ||  ╧ || 239 ||  ∩
|-
| 144 ||  É || 176 ||  ░ || 208 ||  ╨ || 240 ||  ≡
|-
| 145 ||  æ || 177 ||  ▒ || 209 ||  ╤ || 241 ||  ±
|-
| 146 ||  Æ || 178 ||  ▓ || 210 ||  ╥ || 242 ||  ≥
|-
| 147 ||  ô || 179 ||  │ || 211 ||  ╙ || 243 ||  ≤
|-
| 148 ||  ö || 180 ||  ┤ || 212 ||  ╘ || 244 ||  ⌠
|-
| 149 ||  ò || 181 ||  ╡ || 213 ||  ╒ || 245 ||  ⌡
|-
| 150 ||  û || 182 ||  ╢ || 214 ||  ╓ || 246 ||  ÷
|-
| 151 ||  ù || 183 ||  ╖ || 215 ||  ╫ || 247 ||  ≈
|-
| 152 ||  ÿ || 184 ||  ╕ || 216 ||  ╪ || 248 ||  °
|-
| 153 ||  Ö || 185 ||  ╣ || 217 ||  ┘ || 249 ||  ∙
|-
| 154 ||  Ü || 186 ||  ║ || 218 ||  ┌ || 250 ||  ·
|-
| 155 ||  ¢ || 187 ||  ╗ || 219 ||  █ || 251 ||  √
|-
| 156 ||  £ || 188 ||  ╝ || 220 ||  ▄ || 252 ||  ⁿ
|-
| 157 ||  ¥ || 189 ||  ╜ || 221 ||  ▌ || 253 ||  ²
|-
| 158 ||  ₧ || 190 ||  ╛ || 222 ||  ▐ || 254 ||  ■
|-
| 159 ||  ƒ || 191 ||  ┐ || 223 || ▀ || 255 ||  ''NBSP'' ***
|}
:''' * DEL was used to erase paper tape data by punching out all of the 7 holes.'''
:'''** Control characters 8 to 13 and 28 to 31 can move text formatting when [[PRINT|printed]] and do not display'''
:'''*** NBSP is a Non-breaking Space used to indent text. Some browsers may handle this character differently'''
<center>[http://www.lammertbies.nl/comm/info/ascii-characters.html More information about ASCII Control Characters] </center>
<center>[[Unicode|Unicode Character Table]]</center>
==Control Characters==
* [[INKEY$]] will return Control + letter key press combinations as the equivalent control characters or bold '''function keys''' listed below:
{{WhiteStart}} CTRL + A = CHR$(1) ☺ StartHeader (SOH) CTRL + B = CHR$(2) ☻ StartText (STX)
CTRL + C = CHR$(3) ♥ EndText (ETX) CTRL + D = CHR$(4) ♦ EndOfTransmit (EOT)
CTRL + E = CHR$(5) ♣ Enquiry (ENQ) CTRL + F = CHR$(6) ♠ Acknowledge (ACK)
CTRL + G = CHR$(7) {{text|•|red}} [[BEEP|Bell]] (BEL) CTRL + H = CHR$(8) ◘ '''[Backspace]''' (BSP)
CTRL + I = CHR$(9) {{text|○|red}} Horiz.Tab '''[Tab]''' CTRL + J = CHR$(10) {{text|◙|red}} LineFeed(printer) (LF)
CTRL + K = CHR$(11) {{text|♂|red}} Vert. Tab (VT) CTRL + L = CHR$(12) {{text|♀|red}} FormFeed(printer) (FF)
CTRL + M = CHR$(13) {{text|♪|red}} '''[Enter]''' (CR) CTRL + N = CHR$(14) ♫ ShiftOut (SO)
CTRL + O = CHR$(15) ☼ ShiftIn (SI) CTRL + P = CHR$(16) ► DataLinkEscape (DLE)
CTRL + Q = CHR$(17) ◄ DevControl1 (DC1) CTRL + R = CHR$(18) ↕ DeviceControl2 (DC2)
CTRL + S = CHR$(19) ‼ DevControl3 (DC3) CTRL + T = CHR$(20) ¶ DeviceControl4 (DC4)
CTRL + U = CHR$(21) § NegativeACK (NAK) CTRL + V = CHR$(22) ▬ Synchronous Idle (SYN)
CTRL + W = CHR$(23) ↨ EndTXBlock (ETB) CTRL + X = CHR$(24) ↑ Cancel (CAN)
CTRL + Y = CHR$(25) ↓ EndMedium (EM) CTRL + Z = CHR$(26) → End Of File(SUB) (EOF)
'''{{text|Red symbols will format text and not [[PRINT]] the symbol.|red}} [[_PRINTSTRING]] can print in QB64'''
{{WhiteEnd}}
* Control characters '''1 to 26''' can be used to simulate ''Ctrl + letter'' key shortcuts in Windows programs using [[_SCREENPRINT]].
* [[_CONTROLCHR]] OFF can also be used in QB64 to allow control characters to be printed without formatting the text.
<center>'''ASCII in Text and Printing'''</center>
* Characters '''0'''(NULL) and '''255'''(NBSP) can also be used to print spaces('''32'''). Useful for making file names harder to delete too.
* Character '''7''' will create a [[BEEP]] sound when printed in '''QB64''' or an error sound in Qbasic using a '''SCREEN 0''' window.
* Character '''8''' is returned when the '''Backspace''' key is pressed.
* Characters '''9 thru 13''' and '''28 thru 31''' can affect screen or file text placements and do not display the character when [[PRINT|printed]]:
:* Character '''9''' will '''Tab''' space the cursor 8 column spaces when printed.
:* Character '''10''' moves the cursor or ''"line feeds"'' the printer head down one row.
:* Character '''11''' vertical tabs the cursor back to top left position of page or screen. Acts like [[CLS]].
:* Character '''12''' acts like [[CLS]] when printed. ''"Form feeds"'' the page out of printers.
:* Character '''13''' is the cursor or typing '''"carriage return"''' to the start of the line on left side. Returned when '''Enter''' key pressed.
:* Character '''28''' designates a File Separator. Moves the print cursor one space right. Combination Ctrl + \
:* Character '''29''' designates a Group Separator. Moves the print cursor one space left. Combination Ctrl + ]
:* Character '''30''' designates a Record Separator. Moves the print cursor one row up. Combination Ctrl + ^
:* Character '''31''' designates a Unit Separator. Moves the print cursor one row down. Combination Ctrl + _
* '''QB64''' can display all of the control characters without formatting the text using [[_PRINTSTRING]].
* Characters '''13''' and '''10''' can be combined to create the '''CrLf''' carriage return used in files or printing. crlf$ = CHR$(13) + CHR$(10).
* Character '''16''', the data link escape(DLE) character, can designate that a control character is being sent from a [[OPEN COM|COM port]].
: ''Example:'' (DLE) <XON> <DATA PACKET> (DLE) <XOFF> or (DLE) <STX> <DATA PACKET> (DLE) <ETX>
* Character '''17''', Device Control 1, is used with [[OPEN COM|COM ports]] to mark the start of a transmission as "XON". The character is read.
* Character '''19''', Device Control 3, is used with [[OPEN COM|COM ports]] to mark the end of a transmission as "XOFF". The character is NOT read.
* Character '''26''' can be used to designate the end of a file. See [[EOF]].
* Character '''27''' '''{{text|←|green}}''' is returned when the '''Escape''' key is pressed.
<center>'''Control character [[PRINT]] actions can be controlled using [[_CONTROLCHR]] OFF or ON in QB64.'''</center>
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|COLOR}} 14: {{Cl|PRINT}} "Press Control + letter key combinations."
DO
K$ = {{Cl|INKEY$}}
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(K$) {{Cl|THEN}}
code = {{Cl|ASC}}(K$)
{{Cl|IF...THEN|IF}} code < 32 {{Cl|THEN}} {{Cl|_PRINTSTRING}} (220, 100), "Ctrl + " + {{Cl|CHR$}}(code + 64) + " = " + K$ + " "
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27)
{{Cl|END}} '' ''
{{CodeEnd}}
<center>'''ASCII Character Usage'''</center>
* Characters are one byte and take up one space(byte) in a [[STRING]] value or variable.
* Extended(non-keyboard) characters can be entered by holding down ''Alt'' key and entering the code number on the Number pad.
* [[PRINT]]s text characters and symbols or formats the screen, printer or file.
* [[BINARY]] files often store values below 256 in the one byte character. To read the value get the code with [[ASC]].
* Numerical values placed into a [[BINARY]] or [[RANDOM]] file using a [[GET]] or [[PUT]] variable, they will be stored in [[_MK$]] format.
* Characters '''176''' to '''223''' can be used to create screen borders or boundaries in an ASCII game. See: [[SCREEN (function)]]
* Character '''253'''(small 2) can be found as the first character byte of a [[BSAVE]]d image file opened in [[BINARY]] mode.
* Character '''255''' can be used as the NBSP(non-breaking space) character on web pages to fill in extra spaces.
* Can be used to crudely encrypt a file so others cannot read it by shifting the code values. See [[CHR$]] example 2.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==[[ASC]] Codes==
<center>'''[[ASC]] cannot read empty [[INKEY$]] = "" loop reads! Check for them before reading [[ASC]] key press codes!'''</center>
{{WhiteStart}}' '''ASCII Keyboard Codes'''
'
'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause'''
' 27 +59 +60 +61 +6
4000
2 +63 +64 +65 +66 +67 +68 +133 +134 - - -
'''' `~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -'''
' 126 33 64 35 36 37 94 38 42 40 41 95 43 8 +82 +71 +73 - 47 42 45
''' 96 49 50 51 52 53 54 55 56 57 48 45 61''
'''' 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/-►
' - 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'''
' * 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 '''
' * - * 32 * - - * +75 +80 +77 +82 +83 13
' '' 48 46''
'
' ''' ''Italics'' = LCase/NumLock On ____________ + = 2 Byte: CHR$(0) + CHR$(code)'''
'{{small|NOTE: The above commented table can be copied and pasted directly into the QB64 IDE}}
{{WhiteEnd}}
<center>Use '''{{text|ASC(RIGHT$(key$, 1))|green}}''' or '''{{text|ASC(key$, 2)|green}}''' in QB64 to read a two byte code when '''{{text|ASC(key$) <nowiki>=</nowiki> 0|green}}'''</center>
<center>'''* See the Two Byte Ctrl, Alt and Shift + Function key combinations below'''</center>
{{CodeStart}}' Demo displays all ASCII codes and 2 byte code combinations
{{Cl|DO...LOOP|DO}}: K$ = {{Cl|INKEY$}}
{{Cl|IF...THEN|IF}} K$ <> "" {{Cl|THEN}} 'ASC will return an error if an empty string is read!
{{Cl|IF...THEN|IF}} {{Cl|ASC}}(K$) > 0 {{Cl|THEN}}
{{Cl|PRINT}} "{{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}({{Cl|ASC}}(K$))) + ")" 'display normal keypress codes
{{Cl|ELSE}} {{Cl|PRINT}} "{{Cl|CHR$}}(0) + {{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}({{Cl|ASC}}(K$, 2))) + ")" 'display 2 byte codes
{{Cl|END IF}}
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27) 'escape key press exits '' ''
{{CodeEnd}}
: ''Note:'' In QB64 [[ASC]](K$, 2) can read the second byte of the 2 byte code when [[ASC]](K$) reads the first byte as 0.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==Two Byte Codes==
<center>'''Two Byte ASCII Keyboard Return Values'''</center>
* [[INKEY$]] returns both bytes when two byte keys or key combinations are pressed. The second byte = [[RIGHT$]](keypress$, 1)
* If the character returned is a two byte code, [[ASC]] will return 0. '''Warning:''' ASC cannot read empty [[INKEY$]] string values!
* In '''QB64''' only, [[ASC]](keypress$, 2) can return the second byte code. Don't read empty string values!
* String values returned can be compared in an [[IF...THEN|IF]] or [[SELECT CASE]] routine by using the actual string definitions such as:
:IF INKEY$ = CHR$(0) + CHR$(80) THEN row = row + 1 '''or''' IF INKEY$ = CHR$(0) + "P" THEN row = row + 1
{{WhiteStart}} '''Two Byte Character Codes    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) [↑] Up Arrow "H"
CHR$(0) + CHR$(73) [Page Up] "I"
CHR$(0) + CHR$(75) [←] Left Arrow "K"
CHR$(0) + CHR$(76) [5 NumberPad] "L" (NumLock off in QB64)
CHR$(0) + CHR$(77) [→] Right Arrow "M"
CHR$(0) + CHR$(79) [End] "O"
CHR$(0) + CHR$(80) [↓] Down 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] "î"
{{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}}'''
<center>'''See [[Scancodes]] for other keyboard function keys.'''</center>
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==Code Examples==
''Example 1:'' Using arrow keys to move a text character. A change from a previous position tells program when to PRINT:
{{CodeStart}}movey = 1: movex = 1 'text coordinates can never be 0
at$ = "@" 'text sprite could be almost any ASCII character
{{Cl|LOCATE}} movey, movex: {{Cl|PRINT}} at$;
DO
px = movex: py = movey 'previous positions
B$ = {{Cl|INKEY$}}
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(72) {{Cl|AND (boolean)|AND}} movey > 1 {{Cl|THEN}} movey = movey - 1 'rows 1 to 23 only
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(80) {{Cl|AND (boolean)|AND}} movey < 23 {{Cl|THEN}} movey = movey + 1
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(75) {{Cl|AND (boolean)|AND}} movex > 1 {{Cl|THEN}} movex = movex - 1 'columns 1 to 80 only
{{Cl|IF...THEN|IF}} B$ = {{Cl|CHR$}}(0) + {{Cl|CHR$}}(77) {{Cl|AND (boolean)|AND}} movex < 80 {{Cl|THEN}} movex = movex + 1
{{Cl|IF...THEN|IF}} px <> movex {{Cl|OR (boolean)|OR}} py <> movey {{Cl|THEN}} 'only changes when needed
{{Cl|LOCATE}} py, px: {{Cl|PRINT}} {{Cl|SPACE$}}(1); 'erase old sprite
{{Cl|LOCATE}} movey, movex: {{Cl|PRINT}} at$; 'show new position
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} B$ = {{Cl|CHR$}}(27) 'ESCape key exit
{{Cl|END}}
{{CodeEnd}}
''Example 2:'' Routine displays all keypress codes including Ctrl, Alt and Shift combinations. Ctrl + letter = control codes 1 to 26.
{{CodeStart}}
'' ''
SCREEN 13
tmp$ = " CHR$(###),\\,\ \ "
tmp2$ = " CHR$(0) + CHR$(###) \ \"
COLOR 14: LOCATE 3, 3: PRINT "The code can tell what key is pressed"
COLOR 12: LOCATE 5, 14: PRINT CHR$(3); SPACE$(3);
COLOR 13: PRINT CHR$(5); SPACE$(3);
COLOR 12: PRINT CHR$(4); SPACE$(3);
COLOR 13: PRINT CHR$(6)
COLOR 10: LOCATE 7, 4: PRINT " Hit a key to find the ASCII Code"
COLOR 5: LOCATE 13, 1: PRINT " Codes below 33 are called control keys"
LOCATE 14, 1: PRINT " CHR$(0) + are 2 byte Extended key codes"
COLOR 13: LOCATE 16, 1: PRINT " Extended: Press Alt + numberpad: Enter"
LOCATE 18, 1: PRINT " Try some Ctrl, Alt, or Shift Combo's"
COLOR 5: LOCATE 20, 1: PRINT " INKEY$ is used to detect the key entry"
COLOR 2: LOCATE 22, 15: PRINT CHR$(1); " "; CHR$(2)
COLOR 4: LOCATE 24, 10: PRINT "To Quit hit the TAB key";
COLOR 9
DO
DO: {{Cl|SLEEP}}: A$ = {{Cl|INKEY$}}: LOOP UNTIL A$ <> "" 'legal ASC read keys
IF {{Cl|ASC}}(A$) > 0 THEN ' normal key codes
code% = ASC(A$)
SELECT CASE code%
CASE 7: Key$ = "Beep"
CASE 8: Key$ = "Backspace"
CASE 9: Key$ = "Tab Key"
CASE 10: Key$ = "Line Feed"
CASE 12: Key$ = "Form Feed"
CASE 13: Key$ = "Enter"
CASE 27: Key$ = "Escape"
CASE 32: Key$ = "Space Bar"
CASE 48 TO 57: Key$ = "Number"
CASE 65 TO 90: Key$ = "Uppercase"
CASE 97 TO 122: Key$ = "Lowercase"
CASE ELSE: Key$ = ""
END SELECT
SELECT CASE code% 'check for unprintable control combo characters
CASE 10 TO 13: Kcode% = 32
CASE ELSE: Kcode% = code%
END SELECT
COLOR 9: LOCATE 10, 5: {{Cl|PRINT USING}} tmp$; code%; {{Cl|CHR$}}(Kcode%); Key$;
END IF
IF {{Cl|ASC}}(A$) = 0 THEN 'two byte key codes
code% = ASC({{Cl|RIGHT$}}(A$, 1)) 'QBasic code
'code% = ASC(A$, 2) 'QB64 code alternative
SELECT CASE code%
CASE 16 TO 50: Key$ = "Alt+ letter"
CASE 72: Key$ = CHR$(24) + " Arrow"
CASE 75: Key$ = CHR$(27) + " Arrow"
CASE 77: Key$ = CHR$(26) + " Arrow"
CASE 80: Key$ = CHR$(25) + " Arrow"
CASE 83: Key$ = "Delete"
CASE 59: Key$ = "F1"
CASE 60: Key$ = "F2"
CASE 61: Key$ = "F3"
CASE 62: Key$ = "F4"
CASE 63: Key$ = "F5"
CASE 64: Key$ = "F6"
CASE 65: Key$ = "F7"
CASE 66: Key$ = "F8"
CASE 67: Key$ = "F9"
CASE 68: Key$ = "F10"
CASE 71: Key$ = "Home"
CASE 73: Key$ = "Page " + CHR$(24)
CASE 79: Key$ = "End"
CASE 81: Key$ = "Page " + CHR$(25)
CASE 82: Key$ = "Insert"
CASE 83: Key$ = "Delete"
CASE 84 TO 93: Key$ = "Shift+ F"
CASE 94 TO 103: Key$ = "Ctrl+ F"
CASE 104 TO 113: Key$ = "Alt+ F"
CASE 114 TO 119: Key$ = "Ctrl + pad"
CASE 120 TO 129: Key$ = "Alt+ number"
CASE 132: Key$ = "Ctrl + pad"
CASE 133: Key$ = "F11"
CASE 134: Key$ = "F12"
CASE 135: Key$ = "Shift+ F11"
CASE 136: Key$ = "Shift+ F12"
CASE 137: Key$ = "Ctrl+ F11"
CASE 138: Key$ = "Ctrl+ F12"
CASE 139: Key$ = "Alt+ F11"
CASE 140: Key$ = "Alt+ F12"
CASE ELSE: Key$ = ""
END SELECT
LOCATE 10, 5: {{Cl|PRINT USING}} tmp2$; code%; Key$
END IF
LOOP UNTIL A$ = CHR$(9)
SOUND 400, 4
SLEEP 3
SYSTEM '' ''
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
''Explanation:'' The routine checks for a keypress and [[SLEEP]] guarantees that [[ASC]] will never read an empty string from INKEY$. When the keypress is determined to be two bytes ([[ASC]](A$) = 0) the second SELECT CASE routine is used. You can even display non-keyboard extended characters. Just press Alt + numberpad code, release and press enter.
:::Note: Ctrl + letter keys will list the contol keys as normal codes. EX: Ctrl + G will BEEP (CHR$(7)).
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==References==
''Printable ASCII Table:'' [[_PRINTIMAGE]] (see Example 2 on page)
{{PageSeeAlso}}
* [[_KEYHIT]], [[_KEYDOWN]]
* [[_MAPUNICODE]], [[_MAPUNICODE (function)]]
* [[Code Pages]] {{text|(Various Unicode Languages)}}
* [[ASC (statement)]] {{text|(QB64 only)}}
* [[ASC]], [[INSTR]]
* [[CHR$]], [[INKEY$]]
* [[LEFT$]], [[MID$]], [[RIGHT$]]
* [[PRINT]], [[SCREEN]]
* [[MKI$]], [[MKL$]], [[MKS$]], [[MKD$]], [[_MK$]]
* [[_PRINTSTRING]], [[_SCREENPRINT]]
* [[_CONTROLCHR]] {{text|(turns control PRINT actions OFF/ON)}}
* [[Scancodes]](keyboard), [[Unicode]](character table)
* [[Text Using Graphics]]
{{PageNavigation}}

339
internal/help/Arrays.txt Normal file
View file

@ -0,0 +1,339 @@
{| align="center"
| __TOC__
|}
===What are Arrays?===
Arrays are simply variables with a number of elements that can each hold data in memory. To designate a certain element, integers denote the value's position in memory. Don't let talk about memory scare you! Basic does all of the work for you just by using the simple commands in this tutorial. Besides that, you have already been using memory since you created your first variable!
Arrays can store element bytes of information like any other variable depending on the type of the variable. The total memory bytes used by an array type can be determined using the table below multiplied by the number of array elements:
:::::: [[STRING]] = 1 byte per character
:::::: [[INTEGER]] = 2 bytes (signed Integer values from -32768 to 32767)
:::::: [[LONG]] = 4 bytes (signed Integer values from -2147483648 to 2147483647)
:::::: [[SINGLE]] = 4 bytes (up to 7 digit floating decimal point values)
:::::: [[DOUBLE]] = 8 bytes (up to 15 digit floating point values)
:::::: [[_BIT]] * 8 = 1 byte(signed Integer values of -1 or 0)
:::::: [[_BYTE]] = 1 byte (signed Integer values from -128 to 127)
:::::: [[_INTEGER64]] = 8 bytes (signed values from -9223372036854775808 to 9223372036854775807
:::::: [[_FLOAT]] = 10 bytes (better than Double accuracy)
While Qbasic uses signed values '''QB64''' can use signed or [[_UNSIGNED]] values for [[_BIT]], [[_BYTE]], [[INTEGER]], [[LONG]] or [[_INTEGER64]] variable type values.
The array's variable type must be determined when the array is created. If no type is used, the default type is [[SINGLE]].
<center>[[#toc|Return to Top]]</center>
===When do I need an Array?===
'''When you find yourself creating several variables with numbers in their names.''' This may seem simplistic, but normally programmers tend to use similar names to denote similar value types. This makes arrays perfect in many cases. You can get several values of the same type simply by referring to the element positions in an array. Plus you can have thousands of possibilities when needed.
Arrays can be created to hold values until they are needed. They can hold image or file data too! There are many possible uses!
The only drawback is that the data is lost when the program ends, but array data can be permanently stored in files when you want to save the data. All that you need is a simple loop to transfer the data sequencially or save the entire array to a [[BINARY]] file using '''QB64''' with a simple [[PUT]] statement. You also can retrieve the array data using one [[GET]].
<center>[[#toc|Return to Top]]</center>
===Creating Array Variables===
First we need to create a place in memory for the array. To do that we have to tell Basic the array's name, type of values it will hold and how many values we need to access. This is called dimensioning an array.
How good are you at counting from zero? This might seem like a simple question, but think about this. How many elements would we have if they were numbered 0 through 10? If you said 11, then you were correct. Some people have problems counting when 0 is involved so Basic has an option to allow all arrays to start at 1.
[[OPTION BASE]] 1 will cause all array dimensions to begin at 1, [[OPTION BASE]] 0 will cause all dimensions to begin at 0. The default when just using the maximum array size is 0. Use whatever option you are comfortable with.
Arrays in QuickBASIC 4.5 and QBASIC are limited to 32767 elements, while arrays in '''QB64''' are limited to 2147483647 elements (over 2 billion). When the 64-bit version of QB64 is implemented 9223372036854775807 elements will be the limit (but only on 64-bit systems).
{{KW|DIM}} reserves the array's name, variable type and number of elements in memory before the array is used. DIM reserves a {{KW|STATIC}} (unchangeable) array unless the {{KW|$DYNAMIC}} (changeable) metacommand is used at the program's start or {{KW|REDIM}} was used to dimension the array originally.
''Example 1:'' Dimensions an array named 'Array' that is capable of holding 101 integer values including element 0.
{{CodeStart}}
{{Cl|DIM}} Array(100) AS {{Cl|INTEGER}}
{{CodeEnd}}
An array starts at element 0 unless changed by {{KW|OPTION BASE}} 1 (which can set the start at 1), you can also define the start and end area by [[DIM]]ensioning within a range.
[[DIM]]ensioning with a range is possible also by using TO between the minimum and highest elements. Arrays can start and end at any element(index) value up to 32767. '''QB64''' allows larger array sizes!
''Example 2:'' dimensions an Integer array that can hold 100 values in indices 1 to 100.
{{CodeStart}}
{{Cl|DIM}} Array%(1 TO 100)
{{CodeEnd}}
''Note:'' The array type can also be designated by variable suffixes as % designates Integers above.
{{KW|REDIM}} can be used to redimension a dynamic array. Any information contained in the array before the REDIM will be lost...however. In order to use {{KW|REDIM}}, the variable must have originally been dimensioned using {{KW|REDIM}}, or a {{KW|$DYNAMIC}} metacommand must be placed at the top of the program.
''Example 3:''
{{CodeStart}}
{{Cl|OPTION BASE}} 1 ' placed before any arrays are dimensioned
{{Cl|REDIM}} Array$(1000) ' REDIM creates a dynamic array
{{CodeEnd}}
'''QB64''' has a REDIM {{KW|_PRESERVE}} action which can be used in a REDIM statement in order to preserve the data information in the array.
''Example 4:'' REDIM without the _PRESERVE action erases the array contents
{{CodeStart}}
{{Cl|REM}} {{Cl|$DYNAMIC}}
{{Cl|DIM}} array(20)
array(10) = 24
{{Cl|PRINT}} array(10)
{{Cl|REDIM}} {{Cl|_PRESERVE}} array(30)
{{Cl|PRINT}} array(10)
{{Cl|REDIM}} array(10)
{{Cl|PRINT}} array(10)
{{CodeEnd}}
{{OutputStart}}
24
24
0
{{OutputEnd}}
{{KW|_PRESERVE}} also allows the lowest index to be changed. The old starting index data value will always be in the lowest new index when the index range limits are changed.
''Example 5:'' Changing the starting index number using the {{KW|_PRESERVE}} action moves the data.
{{CodeStart}}
{{Cl|REDIM}} Array$(1 TO 50)
Array$(1) = "I'm number one!"
Array$(50) = "I'm 50..."
{{Cl|REDIM}} {{Cl|_PRESERVE}} Array$(51 TO 100)
PRINT Array$(51) ' display new start index data
PRINT Array$(100) ' display new end data
{{CodeEnd}}
{{OutputStart}}
I'm number one!
I'm 50...
{{OutputEnd}}
''Example 6:'' The memory segment address of the array is defined in {{KW|DEF SEG}}.
{{CodeStart}}
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(array(0))
offset = {{Cl|VARPTR}}(array(0)) 'program designated offset element
{{CodeEnd}}
NOTE: If {{KW|OPTION BASE}} 1 is used change the 0 to 1. The array start index can be changed when some other data is indexed in the array.
<center>[[#toc|Return to Top]]</center>
===Mult-Dimensional Arrays===
Multiple dimensions are possible to create tables of values. QuickBASIC can use up to 60 dimensions. In '''QB64''' the number of dimensions possible depends on your system memory (a lot more than 60 dimensions). Array data can be saved and restored using file data.
<center>'''Otherwise the data is lost when a program closes.'''</center>
{{TextStart}}
''' TWO DIMENSIONAL ARRAY TABLES'''
Setting up a car sales Database: The sales for each month as represented in an array.
DIM Vehicle%(12, 4) ' Vehicle%(month%, type%)
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
''' 1 2 3 4 5 6 7 8 9 10 11 12 ← Month index'''
'''Type index ↓''' -----------------------------------------------
Cars '''1:''' 5 10 15 20 30 19 17 12 24 20 33 30
Trucks '''2:''' 3 8 7 10 15 9 11 8 15 10 16 11
Vans '''3:''' 4 6 8 9 7 10 9 7 9 8 10 7
SUV '''4:''' 10 8 8 5 10 8 6 8 10 11 9 8
To find monthly and yearly totals you could do something like this:
FOR month% = 1 TO 12
FOR type% = 1 TO 4
MonthlySales% = MonthlySales% + Vehicle%(month%, type%)
NEXT
YearlySales% = YearlySales% + MonthlySales%
PRINT "Monthly =", MonthlySales%; " Yearly ="; YearlySales%; " "
INPUT$(1) 'stop to view each month
MonthlySales% = 0 'zero month sales for next months total
NEXT
{{TextEnd}}
''Example 7:'' Creating a two-dimensional array. A comma separates each dimension size.
{{CodeStart}}
{{Cl|DIM}} Array(12, 10) ' 2 dimensions can hold 143 data values
{{CodeEnd}}
One dimension could hold the month number and the other the number of items sold in 10 categories.
''Example 8:'' Dimensioning using index ranges.
{{CodeStart}}
{{Cl|DIM}} Array(1 TO 12, 1 TO 10) ' 2 dimensions can hold 120 data values
{{CodeEnd}}
<center>[[#toc|Return to Top]]</center>
===Working with the Array Elements===
Once an array is created, you have to put something in it. As you may have noticed, each element or index has an integer value associated with it. Array(number%) refers to just one element of the array no matter what type it is. '''Arrays CAN have negative numbered elements!'''
You can place data into an array using several methods. The slowest method is directly placing data from the user. You can even use the array as the [[INPUT]] variable. It is recommended that ANY program user entries be limited to text as INPUT will give Redo from start errors if a user enters a string value when a numerical input was desired. Numerical string data can be converted from strings simply by using [[VAL]]. This creates less user errors! NOTE: '''QB64''' does not return a "Redo from start" error as [[INPUT]] monitors entries.
{{CodeStart}}
DO
{{Cl|INPUT}} "Enter your age: ", howold$
age% = {{cl|VAL}}(howold$)
LOOP UNTIL age% > 0
Playerage%(user%) = age% 'saves the players age to an indexed player number
PRINT Playerage%(user%) 'print array element to screen to verify entry
user% = user% + 1 'increment user number when all data has been entered
{{CodeEnd}}
You could use several arrays to hold the player's name, high scores, etc. Once the data is in the array, it can be used until the program ends. Then the data is lost, but you can store the data to a file before closing the program simply by using a loop. See next section.
'''To pass array data to a [[SUB]] or [[FUNCTION]] parameter, an empty element bracket passes all elements while a number only passes one specified element of the array.'''
===Array Indexing===
Arrays can be set up to hold more than one kind of data, by indexing the two or more kinds of data. To do this, the programmer reserves one set of element or index values for each kind of data. The type of values MUST be the same except when using a [[TYPE]] definition value.
<center>[[#toc|Return to Top]]</center>
===Sorting Array Data===
Arrays can be sorted numerically or alphabetically using various sorting routines. Commonly [[SWAP]] is used to trade element values in descending or ascending order.
<center>[[#toc|Return to Top]]</center>
===Saving Array Data===
Since variables and arrays exist in memory, data is lost when a program closes. To preserve program data you must either create a permanent [[DATA]] field or save the data to files.
The next time a program is used, it can [[OPEN]] that file and quickly restore all of the array data using a loop or '''QB64''' can [[GET]] the entire file's data in one GET. Use [[LINE INPUT (file statement)|LINE INPUT]] # to set the array sizes by counting the number of data rows in a file if you used a [[WRITE]] '''CSV'''(comma separated values) or a [[PRINT (file statement)|PRINT]] # sequencial file. The number of records in a [[TYPE]] or [[FIELD]] defined [[RANDOM]] access file can be found by dividing the record size into the [[LOF]]. You may want
3640
to make the array slightly larger for new entries.
<center>[[#toc|Return to Top]]</center>
===Image Arrays===
[[INTEGER]] arrays are used to hold image information when using the following graphic procedures: [[GET (graphics statement)|GET]], [[PUT (graphics statement)| PUT]], [[BSAVE]] and [[BLOAD]].
The [[INTEGER]] array size can be estimated by multiplying the height by the width of the image area. To find the actual size needed you can use the following routine to count backwards until something is found in the array. The example below returns the array size required to create a 20 by 20 image:
{{CodeStart}}
wide& = 20: deep& = 20 'change the sizes for any image area
{{Cl|DIM}} array(wide& * deep&) AS {{Cl|INTEGER}}
{{Cl|LINE}} (0, 0)-(wide& - 1, deep& - 1), 12, B 'the box border is all that you need to color.
{{Cl|GET (graphics statement)|GET}} (0, 0)-(wide& - 1, deep& - 1), array(0)
{{Cl|FOR...NEXT|FOR}} s& = wide& * deep& {{Cl|TO}} 0 {{Cl|STEP}} -1
{{Cl|IF...THEN|IF}} array(s&) {{Cl|THEN}} arraysize& = s&: {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}}
{{Cl|NEXT}}
{{Cl|PRINT}} arraysize&
{{Cl|END}} '' ''
{{CodeEnd}}
<center>'''Note: QB64 can [[GET (graphics statement)|GET]] the entire SCREEN 12 area into one array!'''</center>
See also: [[Creating Sprite Masks]]
<center>[[#toc|Return to Top]]</center>
===SHARED Arrays===
When array data is used with [[SUB]] or [[FUNCTION]] procedures they can be passed as parameters. When passed as parameters, a specific index or the entire array can be used. To specify an index, the array is passed with the element number. If the entire array is passed, the element brackets should be empty. Example: '''{{text|SUB SubName (ArrayName() AS INTEGER)|green}}'''
Arrays can also be [[SHARED]] by all procedures by using [[DIM]] [[SHARED]] when the array is created. This allows the array data to be used in the main procedure and all sub-procedures.
[[COMMON]] allows Array data to be shared between program modules when used with [[CHAIN]]. The two modules can share any variable values in a list of variables. The lists can use different variable names, but the types of values MUST be listed in the SAME order in both modules.
[[COMMON SHARED]] allows data to be shared between both modules and SUB or FUNCTION procedures.
Arrays can be created inside of [[SUB]] or [[FUNCTION]] procedures by using [[DIM]] or [[REDIM]]. Also [[SHARED]](without DIM) can be used inside of a sub-procedure to share variable data with the Main program module ONLY. Other sub-procedures cannot reference the data. To share array data with other sub-procedures, array FUNCTIONS can be created that use the internal array elements as a parameter. '''QB64 may allow sub-procedures to share values with other procedures soon!'''
Arrays can be set as [[STATIC]] to retain the values when a sub-procedure is exited. The values will be retained until changed inside of the procedure. If the procedure creates it's own array, you can use a STATIC True or False variable to determine when to [[DIM]] or [[REDIM]] a STATIC array so that values are not lost every call. The ''Ready%'' variable below DIMs the array when the function is first used:
{{CodeStart}} '' ''
{{Cl|FUNCTION}} ScanKey% (scancode%)
{{Cl|STATIC}} Ready%, keyflags%()
{{Cl|IF}} {{Cl|NOT}} Ready% {{Cl|THEN}} {{Cl|REDIM}} keyflags%(0 {{Cl|TO}} 127): Ready% = -1
i% = {{Cl|INP}}({{Cl|&H}}60) 'read keyboard states
{{Cl|IF}} (i% {{Cl|AND (boolean)|AND}} 128) {{Cl|THEN}} keyflags%(i% {{Cl|XOR (boolean)|XOR}} 128) = 0
{{Cl|IF}} (i% {{Cl|AND (boolean)|AND}} 128) = 0 {{Cl|THEN}} keyflags%(i%) = -1
K$ = {{Cl|INKEY$}}
ScanKey% = keyflags%(scancode%)
{{Cl|IF}} scancode% = 0 {{Cl|THEN}} Ready% = 0 'allows program to reset all values to 0 with a REDIM
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
:''Explanation:'' The STATIC ''Ready%'' value is always 0 when a procedure is first run. [[NOT]] zero makes the IF statement True so the array is created. The ''Ready%'' value is then changed to anything but zero to make NOT ''Ready%'' False when the procedure is called again. The FUNCTION is referenced just like an array would be. The value it returns is either 0 or -1 to verify that a certain key was released or pressed respectively. The keyboard status is also updated in the array each call. If the ''scancode%'' sent is 0(a key scan code that does not exist), the array is reset(re-dimensioned) on the next call as ''Ready%'' is reset to zero.
<center>[[#toc|Return to Top]]</center>
===Preserving Data===
[[_PRESERVE]] can preserve data when [[REDIM]] or [[$DYNAMIC]] is used to create dynamic arrays. The current array data can be preserved while changing the array element size. Increasing the size will preserve data inside of existing indices in the resized array. If the size is decreased, only the existing indices values will be preserved. '''The array [[TYPE]] and number of array dimensions cannot be changed!'''
<center>'''{{text|REDIM _PRESERVE ArrayName(1 TO 100)|green}}'''</center>
<center>[[#toc|Return to Top]]</center>
===See Also===
{{PageNavigation}}

89
internal/help/Boolean.txt Normal file
View file

@ -0,0 +1,89 @@
'''Boolean''' statements are numerical evaluations that return True (-1 or NOT 0) or False (0) values that can be used in other calculations.
:::::::''Basic Returns:''
* True evaluations return -1. [[NOT]] 0 = -1 in Basic. Can be used to increment a value.
* For positive True results, subtract it, multiply it by a negative value or use [[ABS]].
* False evaluations return 0. Watch out for [[ERROR Codes|"Division by 0" errors]]!
{{Template:RelationalTable}}
* When evaluating a True value, an IF value < 0 statement is NOT necessary for return values not 0.
<center>''' Truth table of the BASIC Logical Operators:'''</center>
{{Template:LogicalTruthTable}}
<center>'''Boolean Conditional Operators:'''</center>
* [[AND (boolean)|AND]] can be used to add extra conditions to a boolean statement evaluation. Both must be True.
* [[OR (boolean)|OR]] can be used to add alternate conditions to a boolean statement evaluation. One must be True.
* Parenthesis are allowed inside of boolean statements to clarify an evaluation.
* '''Note that Basic returns -1 for True and 0 for False.'''
''Example 1:'' Using 2 different boolean evaluations to determine a leap year.
{{CodeStart}} '' ''
INPUT "Enter a year greater than 1583: ", annum$
Y = {{Cl|VAL}}(annum$)
leap1 = (Y {{Cl|MOD}} 4 = 0 AND Y {{Cl|MOD}} 100 <> 0) OR (Y {{Cl|MOD}} 400 = 0)
leap2 = (Y {{Cl|MOD}} 4 = 0) - (Y {{Cl|MOD}} 100 = 0) + (Y {{Cl|MOD}} 400 = 0)
PRINT "Year = "; annum$, "Leap1 = "; leap1, "Leap2 = "; leap2 '' ''
{{CodeEnd}}
:''Explanation:'' Both boolean evaluations will return -1 if the year is a leap year. It is not simply every four years as many people think. That is checked by the first evaluation (Y MOD 4 = 0) of each. In new century years like 1900 (which was not a leapyear) there is only one leap year every 400 years. 100 is used with [[MOD]] to see if there is a remainder. When that is true, the boolean return of that part of the first evaluation will be 0. The second returns -1 (which is actually added). In both evaluations the result of (Y MOD 400 = 0) indicates a century leap year.
:Entry year = 2000:
::leap1 = (-1 AND 0) OR -1 = -1 ' the AND evaluation returns False(0) so the OR value is used.
::leap2 = (-1) - (-1) + (-1) = -1 + 1 + -1 = -1
:Entry year = 1900:
:: leap1 = (-1 AND 0) OR 0 = 0 OR 0 = 0
:: leap2 = (-1) - (-1) + (0) = -1 + 1 + 0 = 0
''Example 2:'' Moving an [[ASCII]] character using the arrow keys and boolean statements to determine the new coordinate.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|COLOR}} 7
{{Cl|LOCATE}} 11, 20: {{Cl|PRINT}} "Using Screen 12 here to be in 80 X 30 coordinates mode"
{{Cl|LOCATE}} 13, 6: {{Cl|PRINT}} "Simple Example of Alternative programming without IF-{{Cl|THEN}}-{{Cl|ELSE}} Statements"
{{Cl|LOCATE}} 15, 1: {{Cl|PRINT}} "Use the four Cursor keys to move the yellow cursor, text will not be disturbed"
{{Cl|LOCATE}} 17, 12: {{Cl|PRINT}} "When you {{Cl|END}} the program with the ESC key, cursor will disappear"
cordx% = 40
cordy% = 15
{{Cl|DO...LOOP|DO}}
oldcordx% = cordx%
oldcordy% = cordy%
p% = {{Cl|SCREEN (function)|SCREEN}}(cordy%, cordx%) 'get ASCII character code at present position
{{Cl|COLOR}} 14: {{Cl|LOCATE}} cordy%, cordx%: {{Cl|PRINT}} {{Cl|CHR$}}(178); 'print cursor character to position
{{Cl|WHILE}} cordx% = oldcordx% {{Cl|AND (boolean)|AND}} cordy% = oldcordy% {{Cl|AND (boolean)|AND}} k$ <> {{Cl|CHR$}}(27)
k$ = {{Cl|INKEY$}}
cordx% = cordx% + (k$ = ({{Cl|CHR$}}(0) + "K") {{Cl|AND (boolean)|AND}} cordx% > 1) + {{Cl|ABS}}(k$ = ({{Cl|CHR$}}(0) + "M") {{Cl|AND (boolean)|AND}} cordx% < 80)
cordy% = cordy% + (k$ = ({{Cl|CHR$}}(0) + "H") {{Cl|AND (boolean)|AND}} cordy% > 1) + {{Cl|ABS}}(k$ = ({{Cl|CHR$}}(0) + "P") {{Cl|AND (boolean)|AND}} cordy% < 30)
{{Cl|WEND}}
{{Cl|COLOR}} 7: {{Cl|LOCATE}} oldcordy%, oldcordx%: {{Cl|PRINT}} {{Cl|CHR$}}(p%); 'replace overwritten screen characters
{{Cl|LOOP}} {{Cl|UNTIL}} k$ = {{Cl|CHR$}}(27) '' ''
{{CodeEnd}}
{{small|Code by AlgoreIthm}}
''See also:''
* [[IF...THEN]], [[SELECT CASE]]
* [[Binary]], [[ABS]], [[SGN]]
* [[AND]], [[OR]], [[XOR]]
{{PageNavigation}}

48
internal/help/Comma.txt Normal file
View file

@ -0,0 +1,48 @@
The '''comma''' is used to [[TAB]] the cursor after a [[PRINT]] statement's text to tab append another printed value.
''Usage:'' INPUT "Name, age and sex(M or F): ", nm$, age%, sex$
* Commas in [[PRINT]] statements [[TAB]] space values up to 15 column places with column 57 being the maximum per row.
* A comma following the prompt text in an [[INPUT]] statement does not display a question mark. A [[Semicolon|semicolon]] or no prompt does.
* Commas are also used between [[INPUT]] statement variables when more than one input is required.
* [[LINE INPUT]] can use a comma or [[semicolon]] after the prompt text. Neither will display a [[question mark]].
* Commas are used as [[argument]] separators in many kinds of Qbasic statements and [[SUB]] or [[FUNCTION]] parameter lists.
* [[WRITE]] statements use commas to separate values printed to the screen or sent to a file '''without tab spacing them'''.
* '''Literal numerical values entered into program code, [[DATA]], files or user [[INPUT]] cannot contain comma separators!'''
''Example 1:'' Comparing [[TAB]] to [[comma]] tab spacing.
{{CodeStart}} '' ''
{{Cl|PRINT}} {{Cl|TAB}}(15); "T"
{{Cl|PRINT}} , "T" '' ''
{{CodeEnd}}
''Example 2:'' Comparing PRINT and WRITE statement displays.
{{CodeStart}}
value1 = 23567: value2 = 45678: value3 = 354126
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 2, 1: {{Cl|PRINT}} value1, value2, value3
{{Cl|COLOR}} 12: {{Cl|LOCATE}} 4, 1: {{Cl|WRITE}} value1, value2, value3
'' ''
{{CodeEnd}}
{{OutputStart}}
{{text|23567 45678 354126|yellow}}
{{text|23567,45678,354126|red}}
{{OutputEnd}}
:''Note:'' [[WRITE]] does not space any values. The commas separate the numerical values without the normal PRINT spacing.
''See also:''
* [[Semicolon]], [[Colon]]
* [[TAB]], [[SPC]], [[SPACE$]]
* [[PRINT]], [[PRINT USING]]
* [[WRITE]], [[INPUT]], [[LINE INPUT]]
{{PageNavigation}}

View file

@ -0,0 +1,156 @@
<center>'''QB64 Compiler Errors''': To troubleshoot compiler errors try this: [[QB64_FAQ#Q:_How_can_I_find_what_caused_a_Compiler_error.3F|recompile scripts]]</center>
<center>'''Please report any Operating System or Compiler errors or failures you cannot fix [http://www.qb64.net/forum/index.php?board=3.0 HERE!]'''</center>
<center>'''It's a good idea to exclude "QB64.exe" from any real-time anti-virus scanning to prevent IDE Module Errors!'''</center>
The following table describes the error codes that are reported by the '''QB64''' compiler, as well as possible causes and solutions:
{| border="1" cellpadding="2"
|-
! colspan="6"|QB/64 Error Codes
|-
! Code || Description || Common cause/Resolution || QB64 Differences
|-
| 1 || [[NEXT]] without [[FOR]] || Missing loop end or look for a missing [[END IF]] or [[END SELECT]] statement. || none
|-
| 2 || Syntax error || Mistyped keyword statements or puctuation errors can create syntax errors. || none
|-
| 3 || [[RETURN]] without [[GOSUB]] || Place sub-procedure line label after program [[END]] or [[EXIT]] in a [[SUB]]-procedure.|| none
|-
| 4 || Out of DATA || A [[READ]] has read past the end of [[DATA]]. Use [[RESTORE]] to reset to data start. . || none
|-
| 5 || Illegal function call || A parameter passed does not match the function type or exceeds certain function limitations. See [[Illegal Function]]. || none
|-
| 6 || Overflow || A numerical value has exceeded the limitations of a [[Variable Types|variable type]]. || none
|-
| 7 || Out of memory || A module has exceeded the 64K memory limitation of QB. Try breaking the code up to smaller modules.|| no limit
|-
| 8 || Label not defined || [[GOTO]] or [[GOSUB]] tries to branch to a label that doesn't exist. || none
|-
| 9 || Subscript out of range || An [[Arrays|array's]] [[UBOUND|upper]] or [[LBOUND|lower]] [[DIM|dimensioned]] boundary has been exceeded. || none
|-
| 10 || Duplicate definition || You can't define a variable twice with [[DIM]], the first time a variable is used it is also defined. || none
|-
| 11 || Division by zero || You cannot divide any value by zero! Even using [[MOD]]. || none
|-
| 12 || Illegal in direct mode || A statement (like [[DIM]]) in the Immediate window wasn't allowed. || N/A
|-
| 13 || Type mismatch || A [[SUB]] or [[FUNCTION]] parameter does not match the procedure Declaration. || none
|-
| 14 || Out of [[STRING|string]] space || A module has exceeded the 32767 text character limit. Use SUB print procedures. || no limit.
|-
| 16 || String formula too complex. || A string formula was too long or [[INPUT]] statement requested more than 15 strings || N/A
|-
| 17 || Cannot continue. || The program while debugging has changed in a way that it cannot continue. || no debug
|-
| 18 || Function not defined. || The function used by the program must be defined. Did you include the .bi file while using a library? || none
|-
| 19 || No [[RESUME]]. || Use [[RESUME]] at the end of the [[ON ERROR]] [[GOTO]] routine, not [[RETURN]]. || none
|-
| 20 || RESUME without error. || [[RESUME]] can only be used in an error handler called by [[ON ERROR]] [[GOTO]]. || none
|-
| 24 || Device timeout. || Use DS0 (DSzero)in the [[OPEN COM]] statement to avoid modem timeouts. || none
|-
| 25 || Device fault. || Device not connected or does not exist. || none
|-
| 26 || [[FOR]] without [[NEXT]]. || Missing loop end or look for a missing [[END IF]] or [[END SELECT]] statement. || none
|-
| 27 || Out of paper || A printer paper error when using [[LPRINT]]. || none
|-
| 29 || [[WHILE]] without [[WEND]]. || [[WEND]] must end a [[WHILE]] loop. Otherwise look for missing [[END IF]] or [[END SELECT]] || none
|-
| 30 || [[WEND]] without [[WHILE]] || Missing loop end or look for a missing [[END IF]] or [[END SELECT]] statement. || none
|-
| 33 || Duplicate label || Line numbers or labels cannot be used twice in a procedure. || none
|-
| 35 || Subprogram not defined. || Often occurs when the Quickbasic Library is not used with [[CALL ABSOLUTE]] or [[INTERRUPT]] or a [[SUB]] or [[FUNCTION]] procedure has not been created for a [[CALL]]. || none
|-
| 37 || Argument-count mismatch || The number of sub-procedure [[parameters]] do not match the call. || none
|-
| 38 || Array not defined || [[Arrays]] using more than 10 elements must be [[DIM|DIMensioned]]. || none
|-
| 40 || Variable required. || [[LEN]] cannot read literal numerical values. A [[GET]] or [[PUT]] statement must specify a variable when reading or writing a file opened in [[BINARY]] mode. || none
|-
| 50 || [[FIELD]] overflow. || A [[FIELD]] statement tried to allocate more bytes than were specified for the record length of a random access file. || none
|-
| 51 || Internal error. || An internal malfunction occured in QuickBASIC or QB64. || none
|-
| 52 || Bad file name or number. || The filename must follow the rules for filenames in the OS and use filenumbers from 1 and 255. Use [[FREEFILE]] to avoid duplicate [[OPEN]] file numbers. || none
|-
| 53 || File not found. || File not in current directory or path. Use [[_FILEEXISTS]] to verify file names. || none
|-
| 54 || Bad file mode. || File access mode does not match a current [[OPEN]] file procedure. || none
|-
| 55 || File already open. || [[CLOSE]] a file to open it in a different mode. || none
|-
| 56 || FIELD statement active. || '''WRITEME''' || N/A
|-
| 57 || Device I/O error. || '''WRITEME''' || N/A
|-
| 58 || File already exists. || The filename specified in the [[NAME]] statement was identical to a file that already exists. || none
|-
| 59 || Bad record length. || Record length exceeds 32767 bytes or is 0 || none
|-
| 61 || Disk full. || The amount of data to write to the disk was more than the free space available, remove some files you don't need and try again. || none
|-
| 62 || Input past end of file. || Check for the end of file with [[EOF]] when reading from a file. || none
|-
| 63 || Bad record number. || [[GET]] read exceeds number of records in a [[RANDOM]] file. || none
|-
| 64 || Bad file name || File name contains illegal characters or exceeds 12 characters. || none
|-
| 67 || Too many files || Over 15 files are open in Qbasic. || none
|-
| 68 || Device unavailable. || Device does not exist, busy or not connected. || none
|-
| 69 || Communication-buffer overflow. || '''WRITEME''' || N/A
|-
| 70 || Permission denied || A file or port is in use on a network, blocked, read only or locked. || none
|-
| 71 || Disk not ready. || Disk is busy or has no media. || none
|-
| 72 || Disk-media error. || Improper media format or bad data. || none
|-
| 73 || Feature unavailable. || Based on the DOS version available. || none
|-
| 74 || Rename across disks. || '''WRITEME''' || N/A
|-
| 75 || Path/File access error. || File or path cannot be accessed. || none
|-
| 76 || Path not found. || Path is not access-able or does not exist. Use [[_DIREXISTS]] to check paths.|| none
|-
| 97 || (no error message) || Can be used to trigger an error trap event with [[ERROR]] 97, nothing else will cause this error, so create your own errors for [[ON ERROR]]. || none
|-
|}
<center>'''N/A means Not Available or Not Applicable to QB64.'''</center>
{| border="1" cellpadding="2"
! colspan="6"|QB64 Error Codes
|-
! Code || Description || Common cause/resolution || QB Differences
|-
| 258 || Invalid handle || Zero or bad handle values cannot be used by the QB64 procedure creating the error. || N/A
|}
==Other Errors==
* '''Syntax errors''': '''QB64''' will display most statement syntax and parameter errors in the Status area below the editing area in the [[IDE]]. It may also show missing brackets or other syntax punctuation required. Check the keyword's [[Syntax Notation Conventions|syntax]] when necessary!
* '''CPU Memory errors''' can be created when QB64 loads too many images at one time using [[_LOADIMAGE]] or [[_NEWIMAGE]] without freeing them. Use [[_FREEIMAGE]] to free unused handles. Also may be caused by continually running loops.
* '''Parameter Type Mismatch''': Qbasic's IDE may add DEF statements before any [[SUB]] or [[FUNCTION]]. '''QB64'''(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures!
==See also==
* [[ERROR]] (simulates error), [[ERR]] ('''QB''' error code number), [[ERL]] (closest line number when line numbers are used)
* [[ON ERROR]] (calls error handing routine using [[GOTO]] only), [[_ERRORLINE]] (actual '''QB64''' text code line)
{{PageNavigation}}

View file

@ -0,0 +1,328 @@
* '''Keyboards with Alt Gr key:''' [[_KEYHIT]] may return both Alt(100307) and Ctrl(100306) codes when that key is pressed or released.
* '''Linux with foreign keyboards:''' [[SHELL]] [[_HIDE]] "setxkbmap us" will setup a keyboard to read US [[Scancodes]].
==INKEY$ Codes==
* [[INKEY$]] returns a [[STRING]] [[ASCII]] character or a function key two byte string. [[ASC]] converts to code. Use: '''{{text|key$ <nowiki>=</nowiki> INKEY$|green}}'''
* Key presses are read consecutively from the keyboard buffer which will retain a [[SLEEP]] key press.
{{WhiteStart}}' '''ASCII Keyboard Codes'''
'
'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause'''
' 27 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +133 +134 - - -
'''' `~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -'''
' 126 33 64 35 36 37 94 38 42 40 41 95 43 8 +82 +71 +73 - 47 42 45
''' 96 49 50 51 52 53 54 55 56 57 48 45 61''
'''' 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/-►
' - 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'''
' * 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 '''
' * - * 32 * - - * +75 +80 +77 +82 +83 13
' '' 48 46''
'
' ''' ''Italics'' = LCase/NumLock On [[INKEY$#Two_Byte_Combinations|* = 2 byte combo only]], + = 2 Byte: CHR$(0) + CHR$(code)'''
'
{{WhiteEnd}}
<center>GO TO: [[Keyboard_scancodes#INP_Scan_Codes|Scan Codes]],
[[Keyboard_scancodes#ON_KEY_Events|ON KEY]], [[Keyboard_scancodes#KEYHIT_and_KEYDOWN_Codes|_KEYHIT]], [[Keyboard_scancodes#DEVICES_Button|_DEVICES]], [[Keyboard_scancodes#Windows_Virtual_Codes|Windows Virtual]]</center>
==INP Scan Codes==
* [[INP]]([[&H]]60) returns multiple [[INTEGER]] press and release codes as keys are used. Use: '''{{text|code% <nowiki>=</nowiki> INP(96)|green}}'''
* To clear the keyboard buffer, use the [[INKEY$]] function before or after the [[INP]] read to avoid buffer overflows and beeps.
* Keys are assigned only one code irregardless of case or Lock mode with release codes being the press code + 128.
{{WhiteStart}}' '''Extended Keyboard Press Scancodes'''
'
'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SysReq ScrL Pause'''
' 1 59 60 61 62 63 64 65 66 67 68 87 88 0 70 29
' '''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSpc Insert Home PgUp NumL / * -'''
' 41 2 3 4 5 6 7 8 9 10 11 12 13 14 82 71 73 69 53 55 74
' '''Tab Q W E R T Y U I O P [{ ]} \| Delete End PgDn 7/Home 8/▲ 9/PU + '''
' 15 16 17 18 19 20 21 22 23 24 25 26 27 43 83 79 81 71 72 73 78
' '''CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-► E'''
' 58 30 31 32 33 34 35 36 37 38 39 40 28 75 76 77 '''n'''
' '''Shift Z X C V B N M ,< .> /? Shift ▲ 1/End 2/▼ 3/PD t'''
' 42 44 45 46 47 48 49 50 51 52 53 54 72 79 80 81 '''e'''
' '''Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0/Insert ./Del r'''
' 29 {{text|91|purple}} 56 57 56 {{text|92 93|purple}} 29 75 80 77 82 83 28
'
' {{text|QB64 codes only!|purple}} '''Release codes = Press code + 128. Pause/Break may lock code returns.'''
'
{{WhiteEnd}}
<center>[http://www.quadibloc.com/comp/scan.htm Keyboard Scan Codes]........... [http://www.win.tue.nl/~aeb/linux/kbd/scancodes.html Other Keyboards]</center>
<center>GO TO:[[Keyboard_scancodes#INKEY.24_Codes|INKEY$]], [[Keyboard_scancodes#ON_KEY_Events|ON KEY]], [[Keyboard_scancodes#KEYHIT_and_KEYDOWN_Codes|_KEYHIT]], [[Keyboard_scancodes#DEVICES_Button|_DEVICES]], [[Keyboard_scancodes#Windows_Virtual_Codes|Windows Virtual]]</center>
==ON KEY Events==
* Assign user defined Soft Key or key combination numbers 15 to 29 with: '''{{text|[[KEY n]]umber, CHR$({{text|keyflag|purple}}) + CHR$(scancode)|green}}'''
* Combo Key flags: {{text|<nowiki>0 = none, LShift = 1, RShift = 2, LCtrl = 4, LAlt = 8, NumLock = 32, CapsLock = 64</nowiki>|purple}}, {{text|Extended keys <nowiki>=</nowiki> 128|blue}}
* {{text|Red|red}} KEY numbers {{text|1 to 14, 30 or 31|red}} assign predefined one key events using: '''[[ON KEY(n)|ON KEY]]({{text|number|red}}) [[GOSUB]] {{text|subname|green}}'''
{{WhiteStart}}' '''Soft Key Scan Code Values'''
'
' {{text|1 2 3 4 5 6 7 8 9 10 30 31 Predefined Keys|red}}
'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SysReq ScrL Pause'''
' 1 59 60 61 62 63 64 65 66 67 68 87 88 -- 70 29
' '''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSpc Insert Home PgUp NumL / * -'''
' 41 2 3 4 5 6 7 8 9 10 11 12 13 14 {{text|82 71 73|blue}} {{text|32|purple}}/69 {{text|53|blue}} 55 74
' '''Tab Q W E R T Y U I O P [{ ]} \| Delete End PgDn 7/Home 8/▲ 9/PU + '''
' 15 16 17 18 19 20 21 22 23 24 25 26 27 43 {{text|83 79 81|blue}} 71 {{text|11|red}}/72 73 78
' '''CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-► E'''
' {{text|64|purple}}/58 30 31 32 33 34 35 36 37 38 39 40 28 {{text|12|red}}/75 76 {{text|13|red}}/77 '''n'''
' '''Shift Z X C V B N M ,< .> /? Shift ▲ 1/End 2/▼ 3/PD t'''
' {{text|1|purple}}/42 44 45 46 47 48 49 50 51 52 53 {{text|2|purple}}/54 {{text|72|blue}} 79 {{text|14|red}}/80 81 '''e'''
' '''Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0/Insert ./Del r'''
' {{text|4|purple}}/29 {{text|91|orange}} {{text|8|purple}}/56 57 {{text|56|blue}} {{text|92 93|orange}} {{text|29 75 80 77|blue}} 82 83 {{text|28|blue}}
'
' '''Keyflag:''' {{text|Function(0, 1, 2, 4, 8, 32, 64)|purple}}, {{text|Extended(128)|blue}} '''Scan Code: '''1-88, {{text|QB64 only(91-93)|orange}}
'
' Reserved and function key combinations can be made using the scan code instead.
' Add function and/or extended flag values for more key combinations.
{{WhiteEnd}}
<center>GO TO:[[Keyboard_scancodes#INKEY.24_Codes|INKEY$]], [[Keyboard_scancodes#INP_Scan_Codes|Scan Codes]], [[Keyboard_scancodes#KEYHIT_and_KEYDOWN_Codes|_KEYHIT]], [[Keyboard_scancodes#DEVICES_Button|_DEVICES]], [[Keyboard_scancodes#Windows_Virtual_Codes|Windows Virtual]]</center>
==KEYHIT and KEYDOWN Codes==
* [[_KEYHIT]] returns multiple [[LONG]] press and negative release codes as keys are used. Use: '''{{text|code& <nowiki>=</nowiki> _KEYHIT|green}}'''
* [[_KEYDOWN]] returns -1 when a specified key code value is pressed or 0. Use: '''{{text|status% <nowiki>=</nowiki> _KEYDOWN(code&)|green}}'''
* [[_KEYCLEAR]] clears the keyboard buffer memory instantly without a [[LOOP|loop]].
{{WhiteStart}}' '''QB64 _KEYHIT and _KEYDOWN Values'''
'
''''Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause'''
' 27 15104 15360 15616 15872 16128 16384 16640 16896 17152 17408 34048 34304 +316 +302 +019
''''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -'''
'126 33 64 35 36 37 94 38 42 40 41 95 43 8 20992 18176 18688 +300 47 42 45
''' 96 49 50 51 52 53 54 55 56 57 48 45 61''
''''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 21248 20224 20736 18176 18432 18688 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/-►
'+301 65 83 68 70 71 72 74 75 76 58 34 13 19200 19456 19712 '''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'''
'+304 90 88 67 86 66 78 77 60 62 63 +303 18432 20224 20480 20736 '''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 '''
'+306 +311 +308 32 +307 +312 +319 +305 19200 20480 19712 20992 21248 13
' '' 48 46''
' ''' Lower value = LCase/NumLock On __________________ + = add 100000 '''
{{WhiteEnd}}
<center>GO TO: [[Keyboard_scancodes#INKEY.24_Codes|INKEY$]], [[Keyboard_scancodes#INP_Scan_Codes|Scan Codes]], [[Keyboard_scancodes#ON_KEY_Events|ON KEY]], [[Keyboard_scancodes#DEVICES_Button|_DEVICES]], [[Keyboard_scancodes#Windows_Virtual_Codes|Windows Virtual]]</center>
: Most keys use [[ASCII]] key code values. Function key code values can be calculated using the [[INKEY$]], two byte values with [[CVI]].
<center>Example: '''{{text|status <nowiki>=</nowiki> _KEYDOWN(CVI(CHR$(0) + "P"))|green}}'''</center>
<center>[[INKEY$#Two_Byte_Combinations|For Ctrl, Alt, Shift Key Combinations see Two Byte Codes]]</center>
==[[DEVICES]] Button==
* [[_LASTBUTTON]](1) keyboards will normally return 512 buttons. One button is read per loop through all numbers.
* [[_BUTTONCHANGE]](number) returns -1 when pressed, 1 when released and 0 when there is no event since the last read.
* [[_BUTTON]](number) returns -1 when a button is pressed and 0 when released.
{{WhiteStart}}' '''Keyboard Device 1 Button Numbers'''
'
'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SysReq ScrL Pause'''
' 177 436 433 434 439 440 437 438 395 396 393 394 399 402 392 ---
' '''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSpc Insert Home PgUp NumL / * -'''
' 246 155 156 153 154 159 160 157 158 147 134 135 151 174 447 448 446 386 417 418 423
' '''Tab Q W E R T Y U I O P [{ ]} \| Delete End PgDn 7/Home 8/▲ 9/PU + '''
' 163 219 221 207 220 218 211 223 195 197 198 241 247 242 213 445 435 429 430 419 424
' '''CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-► E'''
' 391 203 217 202 208 205 206 196 193 194 145 141 167 426 431 432 '''n'''
' '''Shift Z X C V B N M ,< .> /? Shift ▲ 1/End 2/▼ 3/PD t'''
' 390 212 222 201 224 204 200 199
4000
130 136 133 389 443 427 428 432 '''e'''
' '''Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0/Insert ./Del r'''
' 412 413 410 182 409 414 405 411 442 444 441 86 420 421
'
' '''Mouse Device 2 buttons: Left = 1, Middle = 2, Right = 3'''
{{WhiteEnd}}
<center>GO TO: [[Keyboard_scancodes#INKEY.24_Codes|INKEY$]], [[Keyboard_scancodes#INP_Scan_Codes|Scan Codes]], [[Keyboard_scancodes#ON_KEY_Events|ON KEY]], [[Keyboard_scancodes#KEYHIT_and_KEYDOWN_Codes|_KEYHIT]],
[[Keyboard_scancodes#Windows_Virtual_Codes|Windows Virtual]]</center>
==Windows Virtual Codes==
* Virtual key code status can be read '''independently of program focus in Windows'''. Not available in Linux or Mac systems.
* Use: '''{{text|status <nowiki>=</nowiki> GetKeyState%(code%)|green}}''' or '''{{text|GetAsyncKeyState%(code&)|green}}''' or with '''{{text|keybd_event|green}}''' in [[Windows_Libraries#Hot_Keys_.28maximize.29|DECLARE LIBRARY]] "User32".
{{WhiteStart}}' '''Virtual KeyState Codes'''
'
'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause'''
' 27 112 113 114 115 116 117 118 119 120 121 122 123 44 145 19
'''' `~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkS Ins Hme PUp NumL / * -'''
' 192 49 50 51 52 53 54 55 56 57 48 189 187 8 45 36 33 144 111 106 109
'''' 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 219 221 120 46 35 34 103 104 105 107
'''' CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-► E'''
' 20 65 83 68 70 71 72 74 75 76 186 222 13 100 101 102 '''n'''
'''' Shift Z X C V B N M ,< .> /? Shift ▲ 1End 2/▼ 3PD t'''
' 16/160 90 88 67 86 66 78 77 188 190 191 16/161 38 97 98 99 '''e'''
'''' Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0Ins .Del r'''
' 17/162 91 18/164 32 18/165 92 93 17/163 37 40 39 96 110 13
'
' Num Lock On values shown. Off values same as functions and arrows, 5 = code 12.
'
' '''Mouse click returns: LB = 1, RB = 2, MB = 4, etc. [http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx Special keys] may also work.'''
{{WhiteEnd}}
<center>GO TO: [[Keyboard_scancodes#INKEY.24_Codes|INKEY$]], [[Keyboard_scancodes#INP_Scan_Codes|Scan Codes]], [[Keyboard_scancodes#ON_KEY_Events|ON KEY]], [[Keyboard_scancodes#KEYHIT_and_KEYDOWN_Codes|_KEYHIT]], [[Keyboard_scancodes#DEVICES_Button|_DEVICES]], </center>
==Example Code==
''Example 1:'' An [[INP]] Function that retrieves multiple scancodes (allows 2 players and diagonal moves). Function includes it's own array.
{{CodeStart}} '' ''
{{Cl|DECLARE}} {{Cl|FUNCTION}} ScanKey%(code%) '{{Cl|NOT}} required in QB64
{{Cl|CLS}}
x = 40: px = x
y = 20: py = y
xx = 41: pxx = xx
yy = 21: pyy = yy
{{Cl|DO...LOOP|DO}} ' program or game loop
{{Cl|_LIMIT}} 20 ' Delay .05 'in QBasic
{{Cl|COLOR}} 15
{{Cl|LOCATE}} 8, 14: {{Cl|PRINT}} "W A S D": {{Cl|LOCATE}} 8, 52: {{Cl|PRINT}} "ARROW PAD"
{{Cl|IF...THEN|IF}} ScanKey%(17) {{Cl|THEN}} 'W key
{{Cl|LOCATE}} 2, 15: {{Cl|PRINT}} " UP "
{{Cl|IF...THEN|IF}} y > 1 {{Cl|THEN}} y = y - 1
{{Cl|ELSE}} {{Cl|LOCATE}} 2, 15: {{Cl|PRINT}} "----"
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} ScanKey%(31) {{Cl|THEN}} 'S key
{{Cl|LOCATE}} 6, 15: {{Cl|PRINT}} "DOWN"
{{Cl|IF...THEN|IF}} y < 25 {{Cl|THEN}} y = y + 1
{{Cl|ELSE}} {{Cl|LOCATE}} 6, 15: {{Cl|PRINT}} "----"
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} ScanKey%(30) {{Cl|THEN}} 'A key
{{Cl|LOCATE}} 4, 12: {{Cl|PRINT}} "LEFT"
{{Cl|IF...THEN|IF}} x > 1 {{Cl|THEN}} x = x - 1
{{Cl|ELSE}} {{Cl|LOCATE}} 4, 12: {{Cl|PRINT}} "----"
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} ScanKey%(32) {{Cl|THEN}} 'D key
{{Cl|LOCATE}} 4, 18: {{Cl|PRINT}} "RIGHT"
{{Cl|IF...THEN|IF}} x < 80 {{Cl|THEN}} x = x + 1
{{Cl|ELSE}} {{Cl|LOCATE}} 4, 18: {{Cl|PRINT}} "---- "
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} ScanKey%(72) {{Cl|THEN}} 'up arrow
{{Cl|LOCATE}} 2, 55: {{Cl|PRINT}} " UP "
{{Cl|IF...THEN|IF}} yy > 1 {{Cl|THEN}} yy = yy - 1
{{Cl|ELSE}} {{Cl|LOCATE}} 2, 55: {{Cl|PRINT}} "----"
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} ScanKey%(80) {{Cl|THEN}} 'down arrow
{{Cl|LOCATE}} 6, 55: {{Cl|PRINT}} "DOWN"
{{Cl|IF...THEN|IF}} yy < 25 {{Cl|THEN}} yy = yy + 1
{{Cl|ELSE}} {{Cl|LOCATE}} 6, 55: {{Cl|PRINT}} "----"
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} ScanKey%(75) {{Cl|THEN}} 'left arrow
{{Cl|LOCATE}} 4, 52: {{Cl|PRINT}} "LEFT"
{{Cl|IF...THEN|IF}} xx > 1 {{Cl|THEN}} xx = xx - 1
{{Cl|ELSE}} {{Cl|LOCATE}} 4, 52: {{Cl|PRINT}} "----"
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} ScanKey%(77) {{Cl|THEN}} 'right arrow
{{Cl|LOCATE}} 4, 58: {{Cl|PRINT}} "RIGHT"
{{Cl|IF...THEN|IF}} xx < 80 {{Cl|THEN}} xx = xx + 1
{{Cl|ELSE}} {{Cl|LOCATE}} 4, 58: {{Cl|PRINT}} "---- "
{{Cl|END IF}}
{{Cl|LOCATE}} py, px: {{Cl|PRINT}} {{Cl|SPACE$}}(1); 'erase sprite at previous position
{{Cl|LOCATE}} pyy, pxx: {{Cl|PRINT}} {{Cl|SPACE$}}(1);
{{Cl|COLOR}} 10: {{Cl|LOCATE}} y, x: {{Cl|PRINT}} {{Cl|CHR$}}(1); 'place sprite at new position
{{Cl|COLOR}} 12: {{Cl|LOCATE}} yy, xx: {{Cl|PRINT}} {{Cl|CHR$}}(2);
px = x: py = y: pxx = xx: pyy = yy
{{Cl|LOOP}} {{Cl|UNTIL}} ScanKey%(1)
zerocodes% = ScanKey%(0) 'reset all array values to zero for next part of program
{{Cl|END}}
{{Cl|FUNCTION}} ScanKey% (scancode%)
{{Cl|STATIC}} Ready%, keyflags%() 'retain values on procedure exit
{{Cl|IF...THEN|IF}} {{Cl|NOT}} Ready% {{Cl|THEN}} {{Cl|REDIM}} keyflags%(0 {{Cl|TO}} 127): Ready% = -1 'create array on first use
i% = {{Cl|INP}}({{Cl|&H}}60) 'read keyboard states
{{Cl|IF...THEN|IF}} (i% {{Cl|AND (boolean)|AND}} 128) {{Cl|THEN}} keyflags%(i% {{Cl|XOR (boolean)|XOR}} 128) = 0
{{Cl|IF...THEN|IF}} (i% {{Cl|AND (boolean)|AND}} 128) = 0 {{Cl|THEN}} keyflags%(i%) = -1
K$ = {{Cl|INKEY$}} 'clears the key from buffer to prevent beeps
ScanKey% = keyflags%(scancode%)
{{Cl|IF...THEN|IF}} scancode% = 0 {{Cl|THEN}} Ready% = 0 'a zero scancode value clears all previous key presses with a REDIM
{{Cl|END FUNCTION}}
{{Cl|SUB}} Delay (dlay!) 'optional QBasic delay
start! = {{Cl|TIMER}}
{{Cl|DO...LOOP|DO}} {{Cl|WHILE}} start! + dlay! >= {{Cl|TIMER}}
{{Cl|IF...THEN|IF}} start! > {{Cl|TIMER}} {{Cl|THEN}} start! = start! - 86400
{{Cl|LOOP}}
{{Cl|END SUB}} '' ''
{{CodeEnd}}
{{OutputStart}}
UP UP
---- RIGHT LEFT ----
---- ----
W A S D ARROW PAD
{{text|☺|#00FF00}}
{{text|☻|#FF0000}}
{{OutputEnd}}
{{small|Adapted from Code by Cyperium.}}
:''Explanation:'' Displays multiple arrow key presses to move a game character diagonally or allows 2 players to press keys at once. Each keypress is placed into a [[STATIC]] array inside of the ScanKey function. When a key is pressed, the corresponding code index in the array is changed to -1 or True. When a key is released, the scancode returned is over 128 so AND 128 becomes True and the XOR 128 index value is changed to 0. XOR causes 128 to be subtracted from the release code index value which is then changed to 0 (False) from -1. As the main program loop reads the array each of the IF statements look to see if that code is -1. When a statement is True, it prints the appropriate key(s). The example moves two [[ASCII]] sprites. '''Note:''' [[INKEY$]] can be removed from the function if it is used elsewhere to help clear the key buffer.
<center>'''The Scankey Function array can be cleared by sending 0 as the ''scancode%'' or press the ''Print Scrn/SysReq'' key.'''</center>
''Example 2:'' How to get Control, Alt and shift key entries from a user using [[PEEK]] in QB64 or QBasic:
{{CodeStart}} '' ''
DO
{{Cl|_LIMIT}} 50
{{Cl|DEF SEG}} = {{Cl|&H}}40 'set memory segment to read
ShiftFlag = {{Cl|PEEK}}({{Cl|&H}}17) 'read keyboard function keys
{{Cl|DEF SEG}}
{{Cl|IF...THEN|IF}} ShiftFlag <> x {{Cl|THEN}} 'find key not previously read
x = ShiftFlag 'read a new keypress
{{Cl|IF...THEN|IF}} (ShiftFlag {{Cl|AND (boolean)|AND}} 1) = 1 {{Cl|THEN}} {{Cl|PRINT}} "rightshift"
{{Cl|IF...THEN|IF}} (ShiftFlag {{Cl|AND (boolean)|AND}} 2) = 2 {{Cl|THEN}} {{Cl|PRINT}} "leftshift"
{{Cl|IF...THEN|IF}} (ShiftFlag {{Cl|AND (boolean)|AND}} 4) = 4 {{Cl|THEN}} {{Cl|PRINT}} "ctrl"
{{Cl|IF...THEN|IF}} (ShiftFlag {{Cl|AND (boolean)|AND}} 8) = 8 {{Cl|THEN}} {{Cl|PRINT}} "alt"
{{Cl|END IF}}
x$ = {{Cl|INKEY$}} 'clear keyboard buffer to prevent beeping
{{Cl|IF...THEN|IF}} x$ <> "" {{Cl|THEN}} {{Cl|PRINT}} {{Cl|ASC}}(x$) 'read other keypress {{Cl|ASCII}} codes
{{Cl|LOOP}} {{Cl|UNTIL}} x$ = {{Cl|CHR$}}(27) 'Escape key exit
{{CodeEnd}} {{small|Derived from code by eoredson}}
: Note: Each key must be read individually or sequentially. For combinations use the QB64 [[_KEYDOWN]] function.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==Reference==
''See also:''
* [[INKEY$]], [[ASCII]], [[ASC]]
* [[_KEYHIT]], [[_KEYDOWN]], [[_KEYCLEAR]]
* [[ON KEY(n)]], [[KEY(n)]], [[KEY]],
* [[INP]], [[Scancodes]] {{text|(examples)}}
* [[Windows_Libraries#Hot_Keys_.28maximize.29|Windows hot keys]]
* [http://www.howtogeek.com/236462/which-key-on-a-mac-keyboard-corresponds-to-the-symbol/ Mac keyboard Symbols]
{{PageNavigation}}

View file

@ -0,0 +1,59 @@
'''Metacommands''' are program wide commands that start with $.
==Legacy metacommands (Qbasic/QuickBASIC)==
===Syntax===
:REM [[$INCLUDE]]: '[[QB.BI]]' 'loads a reference file or library
:REM [[$DYNAMIC]] 'enables resizing of array dimensions with REDIM
:REM [[$STATIC]] 'arrays cannot be resized once dimensioned
===Description===
* Qbasic Metacommands are normally used at the program start and are in effect throughout the program.
* Qbasic Metacommands are always prefixed with $ and MUST be commented with an apostrophe or [[REM]].
* [[$INCLUDE]] is always followed by a colon and the full text code file name is commented on both sides.
* [[$DYNAMIC]] allows larger arrays that are changeable in size at runtime.
* [[$STATIC]] makes all arrays unchangeable in size.
* '''Qbasic metacommands should have their own program line because they are commented.'''
==QB64 metacommands==
===Syntax===
:[[$CHECKING]]{OFF|ON} 'disables QB64 C++ event and error checking (no spaces)
:[[$CONSOLE]] 'creates a QB64 console window throughout the program
:[[$RESIZE]]:{ON|OFF} 'determines if re-sizing of the program screen by the user is allowed(no spaces)
:[[$SCREENHIDE]] 'hides the QB64 program window throughout the program
:[[$SCREENSHOW]] 'displays the main QB64 program window
:[[$EXEICON]]:'iconfile.ico' 'embeds an .ICO file into the final executable (Windows only)
:[[$VERSIONINFO]]:key=value 'embeds version info metadata into the final executable (Windows only)
:[[$IF]]...[[$END IF]] 'precompiler directive
===Description===
* [[$INCLUDE]] can be used at the beginning or at the end of program SUB procedures.
* [[$CHECKING]]:OFF should only be used with '''errorless''' code where every CPU cycle counts! Use '''ON''' to re-enable event checking. Event checking can be turned OFF or ON throughout a program.
* [[$CONSOLE]] creates a console window which can be turned off later with [[_CONSOLE]] OFF.
* [[$RESIZE]]:ON allows a user to resize the program window. OFF is default.
* [[$SCREENHIDE]] hides the QB64 program window throughout the program until [[$SCREENSHOW]] is used.
* [[$IF]]...[[$END IF]] allows selective inclusion of code in the final program.
* '''Do not comment out with ' or [[REM]] QB64-specific metacommands.'''
{{PageSeeAlso}}
* [[Statement]], [[Function (explanatory)]]
* [[REM]]
* [[DIM]], [[REDIM]]
* [[ON TIMER(n)]]
{{PageNavigation}}

22
internal/help/ON.txt Normal file
View file

@ -0,0 +1,22 @@
ON creates event procedure calls or enables event trapping.
* Set the sub-procedure call for [[KEY(n)]], [[ON COM (n)|COM(n)]], [[PEN]], [[PLAY]], [[STRIG(n)]], [[TIMER]], [[UEVENT]]
* To turn on event trapping for [[ON COM (n)]], [[ON KEY (n)]], [[ON PEN]], [[ON PLAY (n)]], [[ON STRIG (n)]], [[ON TIMER (n)]] and [[ON UEVENT]].
* In the case of [[ON ERROR]] the trap is also enabled until a subsequent ON ERROR statement.
* ON procedures should be used only in the main program module and not inside of SUB procedures!
* If you have used the [[$CHECKING]]:[[OFF]] metacommand, [[$CHECKING]]:'''ON''' will turn on c++ error checking again.
''See also:''
[[ON...GOSUB]], [[ON...GOTO]]
[[OFF]], [[STOP]], [[KEY]]
[[$CHECKING]]
{{PageNavigation}}

View file

@ -0,0 +1,71 @@
{{DISPLAYTITLE:OPTION _EXPLICIT}}
[[OPTION _EXPLICIT]] instructs the compiler to require variable declaration with [[DIM]], [[REDIM]] or an equivalent statement.
{{PageSyntax}}
: [[OPTION _EXPLICIT]]
{{PageDescription}}
* With [[OPTION _EXPLICIT]] you can avoid typos by having QB64 immediately warn in the '''Status area''' of new variables used without previous declaration.
* Enable [[OPTION _EXPLICIT]] temporarily even if a program source file doesn't contain the directive by specifying the '''-e''' switch when compiling via command line (''qb64 -c file.bas -e'').
{{PageErrors}}
* If used, [[OPTION _EXPLICIT]] must be the very first statement in your program. No other statements can precede it (except for comment lines started with an [[Apostrophe|apostrophe]] or [[REM]]).
* Do not use [[OPTION _EXPLICIT]] in [[$INCLUDE]]d modules.
{{PageExamples}}
''Example:'' Avoiding simple typos with [[OPTION _EXPLICIT]] results shown in the QB64 [[IDE]] Status area.
{{CodeStart}}{{Cl|OPTION _EXPLICIT}}
{{Cl|DIM}} myVariable {{Cl|AS}} {{Cl|INTEGER}}
myVariable = 5
{{Cl|PRINT}} myVariabe
{{CodeEnd}}
<center>QB64 IDE Status:</center>
{{CodeStart}}{{text|██|blue}} '''QB64''' _ {{xbox| X }}{{CodeEnd}}
{{TextStart}}  '''File   Edit   View   Search   Run   Options Help''' {{TextEnd}}
{{CodeStart}}┌────────────────────────────────────█{{title|Untitled}}█─────────────────────────────────────────────┐
│OPTION _EXPLICIT {{title|↑|black}}
│ {{text|█|black}}
│DIM myVariable AS INTEGER ▒
│ ▒
│myVariable = 5 ▒
│ ▒
│PRINT myVariabe_ ▒
│ ▒
│ ▒
│ ▒
│ ▒
│ ▒
│ ▒
│ ▒
│ ▒
│ ▒
│ ▒
│ ▒
│ ▒
│ {{title|↓|black}}
{{title|←|black}}{{text|█|black}}▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒{{title|→|black}}│
────────────────────────────────────── Status ──────────────┤{{text|{{Cl|Quick Search Bar|Find[ }} {{Cl|Quick Search list|↕]}}|aqua}}├─┤
│Variable 'myVariabe' (SINGLE) not defined on line 7 │
│ {{title|↑|black}}
│ ▒
│ ▒
│ {{title|↓|black}}
{{CodeEnd}}
{{BlueStart}} '''7:17'''{{BlueEnd}}
{{PageSeeAlso}}
* [[DIM]], [[REDIM]]
* [[SHARED]]
* [[STATIC]]
{{PageNavigation}}

View file

@ -0,0 +1,75 @@
__NOTOC__
QB64 supports several relational operations, which are binary operations that test numeric or string values and return an [[INTEGER]] value representing a boolean ''true'' (<tt>-1</tt>) or ''false'' (<tt>0</tt>) result. These operations are primarily used in expressions where a condition is required, such as the [[IF...THEN]] statement.
==List of relational operations==
The following table describes the relational operations, where <tt>A</tt> is the left-hand side operand, and <tt>B</tt> is the right-hand side operand:
{{RelationalOperationsTable}}
<center>True statements return -1 in [[Boolean]] evaluations. False returns zero.
</center>
==Comparing numerical values and variables==
For numeric operands, such as [[INTEGER]] or [[DOUBLE]] values, the relational operations behave as one would expect. For example, the expression (-3.4 [[Less_Than|<]] 1.2) evaluates to ''true'', and the expression (50 [[Equal|=]] 100) evaluates to ''false''.
''Example:'' When a user enters a value greater than or equal to 5, the boolean statement returns -1 . Zero is printed otherwise.
{{CodeStart}} '' ''
{{Cl|INPUT}} "Enter a value from 1 to 10: ", number
{{Cl|PRINT}} number >= 5 '' ''
{{CodeEnd}}
==Comparing string values and variables==
For string operands, the [[Equal|=]] and [[Not_Equal|<>]] operators test, respectively, if the operands are of the same or differing length, and that each of the corresponding characters match or don't match. For example, the three expressions ("abc" [[Equal|=]] "abc"), ("abc" [[Not_Equal|<>]] "abd") and ("abc" [[Not_Equal|<>]] "abcdef") all evaluate to ''true''.
When two strings are compared, the left string sets the number of characters to evaluate when not checking for equality. The [[Less_Than|<]] and [[Greater_Than|>]] operators find the first set of non-matching characters and test if the [[ASCII]] code values of those characters are less than or greater than each other, respectively. '''Equal strings MUST be of the same length with identical [[UCASE$|cased]] letters or [[ASCII]] characters!'''
If one string is identical to part of the other, [[Less_Than|<]] returns ''false'' if the left-hand side string is shorter than the right-hand side string, while [[Greater_Than|>]] returns ''true'' if the left-hand side string is longer than the right-hand side string. For example, the expressions ("abc" [[Less_Than|<]] "abd") and ("abcdef" [[Greater_Than|>]] "abc") both evaluate to ''true''. Even [[SPACE$|space]] [[ASCII]] character values are evaluated!
''Example:'' Shows that the left hand string sets the number of characters to evaluate when using > or < and are not equal when longer.
{{CodeStart}} '' ''
PRINT "abc" < "abcd"
PRINT "abc" = "abc"
PRINT "abc" = "abcd"
PRINT "abcd" > "abc" '' ''
{{CodeEnd}}
{{OutputStart}} 0
-1
0
-1
{{OutputEnd}}
==Comparing user-defined type variables==
Variables of a [[TYPE|user-defined type]] (UDT) cannot be used as operands to the relational operators, but numeric or string type fields can be used as described above. For example:
:: TYPE T
::: a AS INTEGER
:: END TYPE
:: TYPE U
::: b AS INTEGER
:: END TYPE
:: DIM x AS T : x.a = 10
:: DIM y AS U : y.b = 20
:: PRINT x < y ' <- error: type mismatch
:: PRINT x.a < y.b ' <- outputs "-1"
==Boolean values==
The [[INTEGER]] values for ''true'' and ''false'' are such that the bitwise Logical Operators, such as [[NOT]], [[AND]] and [[OR]] can be used to invert and combine test results. For example, the expression ([[NOT]] (10 [[Greater_Than_Or_Equal|>=]] 20)) evaluates to ''true'', while the expression ((2 [[Less_Than|<]] 1) [[AND]] ("three" [[Equal|=]] "four")) evaluates to ''false''.
{{Template:LogicalTruthTable}}
==See also==
* [[IF...THEN]]
* [[DO...LOOP]], [[WHILE...WEND]]
* [[IS|CASE IS]], [[NOT]]
* [[AND]], [[OR]], [[XOR]], [[EQV]], [[IMP]]
{{PageNavigation}}

View file

@ -0,0 +1,59 @@
{{DISPLAYTITLE:_ACCEPTFILEDROP}}
The [[_ACCEPTFILEDROP]] statement prepares a program window to receive files dropped from Windows Explorer in a drag/drop operation.
{{PageSyntax}}
: [[_ACCEPTFILEDROP]] [{ON|OFF}]
{{PageDescription}}
* Calling the statement with no parameters turns drag/dropping ON.
* To know when files have been dropped into your program's window, check that [[_TOTALDROPPEDFILES]] is greater than 0.
* Use [[_DROPPEDFILE]] to read the list, either sequentially or by index.
* If using [[_DROPPEDFILE]] with an index, you must call [[_FINISHDROP]] after you finish working with the list.
* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''.
==Availability==
* '''Version 1.3 and up'''.
{{PageExamples}}
''Example:'' Accepting files dragged from a folder and processing the list received sequentially.
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(128, 25, 0)
{{Cl|_ACCEPTFILEDROP}} 'enables drag/drop functionality
{{Cl|PRINT}} "Drag files from a folder and drop them in this window..."
{{Cl|DO}}
{{Cl|IF}} {{Cl|_TOTALDROPPEDFILES}} {{Cl|THEN}}
{{Cl|FOR}} i = 1 {{Cl|TO}} {{Cl|_TOTALDROPPEDFILES}}
a$ = {{Cl|_DROPPEDFILE}} 'reads the list sequentially; when the result is empty ("") it means the list is over
{{Cl|COLOR}} 15
{{Cl|PRINT}} i,
{{Cl|IF}} {{Cl|_FILEEXISTS}}(a$) {{Cl|THEN}}
{{Cl|COLOR}} 2: {{Cl|PRINT}} "file",
{{Cl|ELSE}}
{{Cl|IF}} {{Cl|_DIREXISTS}}(a$) {{Cl|THEN}}
{{Cl|COLOR}} 3: {{Cl|PRINT}} "folder",
{{Cl|ELSE}}
{{Cl|COLOR}} 4: {{Cl|PRINT}} "not found", 'highly unlikely, but who knows?
{{Cl|END IF}}
{{Cl|END IF}}
{{Cl|COLOR}} 15
{{Cl|PRINT}} a$
{{Cl|NEXT}}
{{Cl|END IF}}
{{Cl|_LIMIT}} 30
{{Cl|LOOP}}
{{CodeEnd}}
{{PageSeeAlso}}
* [[_TOTALDROPPEDFILES]], [[_DROPPEDFILE]], [[_FINISHDROP]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
{{PageNavigation}}

View file

@ -0,0 +1,76 @@
{{DISPLAYTITLE:_ALLOWFULLSCREEN}}
The [[_ALLOWFULLSCREEN]] statement allows setting the behavior of the ALT+ENTER combo.
{{PageSyntax}}
: [[_ALLOWFULLSCREEN]] [{_STRETCH|_SQUAREPIXELS|OFF|_ALL}][, {_SMOOTH|OFF|_ALL}]
{{PageDescription}}
* Calling the statement with no parameters enables all four possible full screen modes (and is the default state when a program is started): both [[_STRETCH]] ([[_SMOOTH]] and [[_OFF]]) and [[_SQUAREPIXELS]] ([[_SMOOTH]] and [[_OFF]]).
** Using [[_ALLOWFULLSCREEN]] [[_ALL]], [[_ALL]] has the same effect.
* [[_ALLOWFULLSCREEN]] only affects the behavior of ALT+ENTER. The [[_FULLSCREEN]] statement is not bound by [[_ALLOWFULLSCREEN]]'s settings so all modes can be accessed programmatically.
* To limit just the mode but allow both _SMOOTH + _OFF antialiasing modes, pass just the first parameter: ''Example:'' [[_ALLOWFULLSCREEN]] _SQUAREPIXELS
* To allow multiple modes with _SMOOTH or _OFF as default, pass just the second parameter. ''Example:'' [[_ALLOWFULLSCREEN]] , _SMOOTH
* And possible permutation of the parameters is allowed.
* With [[_ALLOWFULLSCREEN]] _OFF you can trap Alt+Enter manually in your program and reassign it. See example 2 below.
==Availability==
* '''Version 1.3 and up'''.
{{PageExamples}}
''Example 1:'' Allowing only one fullscreen mode with square pixels and no antialiasing:
{{CodeStart}}
{{Cl|_ALLOWFULLSCREEN}} {{Cl|_SQUAREPIXELS}}, {{Cl|OFF}}
{{CodeEnd}}
''Example 2:'' Disabling _FULLSCREEN with Alt+ENTER so the combo can be manually trapped:
{{CodeStart}}
{{Cl|DO}}
{{Cl|CLS}}
{{Cl|LOCATE}} 7
{{Cl|PRINT}} " - Press ALT+ENTER to test trapping the combo..."
{{Cl|PRINT}} " _ Press SPACEBAR to allow fullscreen again..."
k& = {{Cl|_KEYHIT}}
{{Cl|IF}} k& = 13 {{Cl|THEN}}
{{Cl|IF}} {{Cl|_KEYDOWN}}(100307) {{Cl|OR}} {{Cl|_KEYDOWN}}(100308) {{Cl|THEN}}
altEnter = altEnter + 1
{{Cl|END IF}}
{{Cl|ELSEIF}} k& = 32 {{Cl|THEN}}
fullscreenEnabled = {{Cl|NOT}} fullscreenEnabled
{{Cl|END IF}}
{{Cl|LOCATE}} 14
{{Cl|IF}} fullscreenEnabled {{Cl|THEN}}
{{Cl|_ALLOWFULLSCREEN}} {{Cl|_ALL}}, {{Cl|_ALL}}
altEnter = 0
{{Cl|PRINT}} "_ALLOWFULLSCREEN _ALL, _ALL"
{{Cl|LOCATE}} 18
{{Cl|PRINT}} "ALT+ENTER will trigger all four fullscreen modes now."
{{Cl|ELSE}}
{{Cl|_ALLOWFULLSCREEN}} {{Cl|OFF}}
{{Cl|PRINT}} "_ALLOWFULLSCREEN OFF"
{{Cl|END IF}}
{{Cl|IF}} altEnter {{Cl|THEN}}
{{Cl|LOCATE}} 18
{{Cl|PRINT}} "ALT+ENTER manually trapped"; altEnter; "times."
{{Cl|END IF}}
{{Cl|_DISPLAY}}
{{Cl|_LIMIT}} 30
{{Cl|LOOP}}
{{CodeEnd}}
{{PageSeeAlso}}
* [[_FULLSCREEN]], [[_SMOOTH (function)]]
{{PageNavigation}}

View file

@ -0,0 +1,23 @@
{{DISPLAYTITLE:_AUTODISPLAY (function)}}
The [[_AUTODISPLAY (function)|_AUTODISPLAY]] function returns the current display mode as true (-1) if automatic or false (0) if disabled using [[_DISPLAY]].
{{PageSyntax}}
: {{Parameter|displayStatus%%}} = [[_AUTODISPLAY (function)|_AUTODISPLAY]]
{{PageDescription}}
* The function returns true (-1) if [[_AUTODISPLAY]] is enabled. This is the default state and indicates that every screen change (text or graphics) is displayed immediately to the user.
* If [[_DISPLAY]] is used, then [[_AUTODISPLAY (function)|_AUTODISPLAY]] returns 0, to indicate that screen changes (text or graphics) are only displayed per request, by calling [[_DISPLAY]] again to refresh the screen.
==Availability==
* '''Build 20170924/69'''.
{{PageSeeAlso}}
* [[_AUTODISPLAY]]
* [[_DISPLAY]]
{{PageNavigation}}

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

@ -0,0 +1,35 @@
{{DISPLAYTITLE:_BLINK}}
The [[_BLINK]] statement toggles blinking colors in text mode (SCREEN 0). Default state is ON.
{{PageSyntax}}
: [[_BLINK]] {ON|OFF}
{{PageDescription}}
* SCREEN 0 emulates the VGA palette with regular colors from 0 to 15 and blinking colors from 16-31 (these are the same colors as 0-15, except their blink attribute is set to on). [[_BLINK]] OFF emulates writing to the video memory and disabling blinking for colors 16-31.
* Using colors 16-31 for the foreground with [[_BLINK]] set to OFF will produce high intensity background colors.
* [[_BLINK]] is only effective in SCREEN 0. It's ignored in graphic modes.
* IF [[_DISPLAY]] is used, blinking is disabled, even if _BLINK is ON, but high intensity backgrounds aren't enabled in this case.
==Availability:==
* Build 20170816/61 up (August 16, 2017).
{{PageExamples}}
{{CodeStart}}{{Cl|COLOR}} 16, 7
{{Cl|PRINT}} "This is printed in black over gray background. Black letters are blinking."
{{Cl|PRINT}} "Hit a key..."
{{Cl|SLEEP}}
{{Cl|_BLINK}} OFF
{{Cl|PRINT}} "Now the same text is printed in black over bright white, because blinking was disabled."
{{CodeEnd}}
{{PageSeeAlso}}
* [[_BLINK (function)]]
* [[OUT]]
* [[_DISPLAY]]
{{PageNavigation}}

View file

@ -0,0 +1,31 @@
{{DISPLAYTITLE:_BLINK (function)}}
The [[_BLINK]] function returns the current blink setting for SCREEN 0 colors. If enabled, returns -1 (default), otherwise returns 0.
{{PageSyntax}}
: {{Parameter|blinkState%%}} = [[_BLINK]]
==Availability==
* Build 20170816/61 up (August 16, 2017).
{{PageExamples}}
{{CodeStart}}{{Cl|COLOR}} 16, 7
'Try uncommenting the line below:
'{{Cl|_BLINK}} OFF
{{Cl|IF}} _BLINK {{Cl|THEN}}
{{Cl|PRINT}} "I'm blinking"
{{Cl|ELSE}}
{{Cl|PRINT}} "I'm not blinking"
{{Cl|END IF}}
{{CodeEnd}}
{{PageSeeAlso}}
* [[_BLINK]] (statement)
* [[OUT]]
{{PageNavigation}}

View file

@ -0,0 +1,56 @@
{{DISPLAYTITLE:_CLIPBOARDIMAGE}}
The [[_CLIPBOARDIMAGE]] statement copies a valid QB64 image to the clipboard.
{{PageSyntax}}
: [[_CLIPBOARDIMAGE]] = {{Parameter|existingImageHandle&}}
{{PageDescription}}
* {{Parameter|existingImageHandle&}} is a valid handle to a graphic QB64 image in memory, created with [[_NEWIMAGE]], [[_LOADIMAGE]] or [[_COPYIMAGE]].
* You can pass [[_SOURCE]], [[_DEST]] or [[_DISPLAY]] to copy the current source, destination or active display pages, as long as they are valid graphic images.
* SCREEN 0 handles (created either with [[_NEWIMAGE]] or passed using _DEST while in a text screen) are not valid and will create an [[ERROR Codes|Illegal Function Call]] or [[ERROR Codes|Invalid Handle]] error.
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]].
==Availability==
* '''Build 20170906/64''' onward.
{{PageExamples}}
''Example:'' Create a sample image and copy it to the clipboard:
{{CodeStart}}{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32)
'Create image in memory:
canvas& = {{Cl|_NEWIMAGE}}(300, 200, 32)
{{Cl|_DEST}} canvas&
'Draw some random rectangles:
{{Cl|RANDOMIZE}} {{Cl|TIMER}}
{{Cl|FOR}} i = 1 {{Cl|TO}} 100
{{Cl|LINE}} (-100 + RND * _WIDTH, -100 + RND * _HEIGHT)-STEP(RND * 150, RND * 150), _RGB(RND * 255, RND * 255, RND * 255), BF
{{Cl|NEXT}}
LINE (0, 0)-(_WIDTH - 1, _HEIGHT - 1), _RGB(255, 255, 255), B
{{Cl|COLOR}} {{Cl|_RGB}}(0, 0, 0), _RGB(255, 255, 255)
m$ = " Hello, world! "
{{Cl|_PRINTSTRING}} (_WIDTH / 2 - _PRINTWIDTH(m$) / 2, _HEIGHT / 2 - _FONTHEIGHT / 2), m$
'Show the image:
{{Cl|_DEST}} 0
{{Cl|_PUTIMAGE}} (_WIDTH / 2 - _WIDTH(canvas&) / 2, _HEIGHT / 2 - _HEIGHT(canvas&) / 2), canvas&
{{Cl|PRINT}} "Image generated."
'Copy to the clipboard:
{{Cl|_CLIPBOARDIMAGE}} = canvas&
PRINT "Image copied to clipboard."
{{CodeEnd}}
{{small|Code by Fellippe Heitor}}
{{PageSeeAlso}}
* [[_CLIPBOARDIMAGE (function)|_CLIPBOARDIMAGE]] {{text|(function - used to paste an image from the clipboard)}}
* [[_CLIPBOARD$]], [[_CLIPBOARD$ (statement)]] {{text|(used to copy/paste text)}}
{{PageNavigation}}

View file

@ -0,0 +1,51 @@
{{DISPLAYTITLE:_CLIPBOARDIMAGE (function)}}
The [[_CLIPBOARDIMAGE (function)|_CLIPBOARDIMAGE]] function pastes an image from the clipboard into a new 32-bit image in memory.
{{PageSyntax}}
: {{Parameter|newImageHandle&}} = [[_CLIPBOARDIMAGE (function)|_CLIPBOARDIMAGE]]
{{PageDescription}}
* When the paste operation is successful, {{Parameter|newImageHandle&}} will be < -1. Handle values of -1 or 0 indicate that there wasn't an image in the clipboard or that the format wasn't accepted.
* Use [[_FREEIMAGE]] to free the memory used by {{Parameter|newImageHandle&}} when it's no longer needed by your program.
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]].
==Availability==
* '''Build 20170906/64''' onward.
{{PageExamples}}
''Example:'' Monitoring the clipboard for new images copied from other programs:
{{CodeStart}}{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32)
{{Cl|DO}}
{{Cl|CLS}}
{{Cl|COLOR}} {{Cl|_RGB32}}(177, 177, 177)
{{Cl|PRINT}} "Monitoring clipboard..."
{{Cl|IF}} img& < -1 {{Cl|THEN}} _FREEIMAGE img&
img& = {{Cl|_CLIPBOARDIMAGE}}
IF img& < -1 THEN
{{Cl|PRINT}} "Image found:"
{{Cl|COLOR}} _RGB32(255, 255, 255)
{{Cl|PRINT}} "Width :"; {{Cl|_WIDTH (function)|_WIDTH}}(img&)
{{Cl|PRINT}} "Height:"; {{Cl|_HEIGHT|_HEIGHT}}(img&)
w = {{Cl|_WIDTH (function)|_WIDTH}} / 2 - {{Cl|_WIDTH (function)|_WIDTH}}(img&) / 2
IF w < 0 THEN w = 0
{{Cl|_PUTIMAGE}} (w, {{Cl|CSRLIN}} * {{Cl|_FONTHEIGHT}}), img&
ELSE
PRINT "No image found."
END IF
{{Cl|_DISPLAY}}
{{Cl|_LIMIT}} 10
{{Cl|LOOP}}
{{CodeEnd}}
{{small|Code by Fellippe Heitor}}
{{PageSeeAlso}}
* [[_CLIPBOARDIMAGE]] {{text|(statement - used to copy an image to the clipboard)}}
* [[_CLIPBOARD$]], [[_CLIPBOARD$ (statement)]] {{text|(used to copy/paste text)}}
{{PageNavigation}}

View file

@ -0,0 +1,33 @@
{{DISPLAYTITLE:_CONTINUE}}
The [[_CONTINUE]] statement is used in a [[DO...LOOP]], [[WHILE...WEND]] or [[FOR...NEXT]] block to skip the remaining lines of code in a block (without exiting it) and start the next iteration. It works as a shortcut to a [[GOTO]], but without the need for a [[line numbers|line label]].
{{PageSyntax}}
: [[_CONTINUE]]
==Availability==
* Build 20170628/55 up.
{{PageExamples}}
''Example:''
{{CodeStart}}
{{Cl|FOR}} i = 1 {{Cl|TO}} 10
{{Cl|IF}} i = 5 {{Cl|THEN}} {{Cl|_CONTINUE}}
{{Cl|PRINT}} i;
{{Cl|NEXT}}
{{CodeEnd}}
{{OutputStart}}
1 2 3 4 6 7 8 9 10
{{OutputEnd}}
{{PageSeeAlso}}
* [[DO...LOOP]]
* [[WHILE...WEND]]
* [[FOR...NEXT]]
* [[GOTO]]
{{PageNavigation}}

52
internal/help/_DIR$.txt Normal file
View file

@ -0,0 +1,52 @@
{{DISPLAYTITLE:_DIR$}}
The [[_DIR$]] function returns common paths in '''Windows''' only such as My Documents, My Pictures, My Music, Desktop.
{{PageSyntax}}
: {{Parameter|d$}} = [[_DIR$]]("{{Parameter|folderspecification}}")
{{Parameters}}
* ''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
:: MY PICTURES, PICTURE, PICTURES, IMAGE, IMAGES, PHOTO, PHOTOS, DCIM, CAMERA, CAMERA ROLL
:: MY VIDEOS, VIDEO, VIDEOS, MOVIE, MOVIES,
:: DATA, APPDATA, APPLICATION DATA, PROGRAM DATA, LOCAL DATA, LOCALAPPDATA, LOCAL APPLICATION DATA, LOCAL PROGRAM DATA
{{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 '''"./"'''
{{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"
{{CodeEnd}}
{{OutputStart}}DESKTOP=C:\Documents and Settings\Administrator\Desktop\
DOWNLOADS=C:\Documents and Settings\Administrator\Downloads\
DOCUMENTS=C:\Documents and Settings\Administrator\My Documents\
PICTURES=C:\Documents and Settings\Administrator\My Documents\My Pictures\
MUSIC=C:\Documents and Settings\Administrator\My Documents\My Music\
VIDEO=C:\Documents and Settings\Administrator\My Documents\My Videos\
APPLICATION DATA=C:\Documents and Settings\Administrator\Application Data\
LOCAL APPLICATION DATA=C:\Documents and Settings\Administrator\Local Settings\Application Data\
{{OutputEnd}}
{{PageSeeAlso}}
* [[_CWD$]]
* [[_STARTDIR$]]
{{PageNavigation}}

View file

@ -0,0 +1,63 @@
{{DISPLAYTITLE:_DROPPEDFILE}}
The [[_DROPPEDFILE]] function returns the list of items (files or folders) dropped in a program's window after [[_ACCEPTFILEDROP]] is enabled.
{{PageSyntax}}
''Syntax 1''
: {{Parameter|nextItem$}} = [[_DROPPEDFILE]]
''Syntax 2''
: {{Parameter|nextItem$}} = [[_DROPPEDFILE]]({{Parameter|index&}})
{{PageDescription}}
* After [[_ACCEPTFILEDROP]] is enabled, once [[_TOTALDROPPEDFILES]] is greater than 0 the list of dropped items will be available for retrieval with [[_DROPPEDFILE]]
* When using [[_DROPPEDFILE]] to read the list sequentially (without specifying an ''index&''), an empty string ("") indicates the list is over and then [[_TOTALDROPPEDFILES]] gets reset to 0.
* When using [[_DROPPEDFILE]] with an index (which goes from 1 to [[_TOTALDROPPEDFILES]]), you must call [[_FINISHDROP]] after you finish working with the list.
* Because it returns a string, [[_DROPPEDFILE]] also accepts being followed by a string suffix ([[_DROPPEDFILE]]'''$''')
* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''.
==Availability==
* '''Version 1.3 and up'''.
{{PageExamples}}
''Example:'' Accepting files dragged from a folder and processing the list received by specifying an index.
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(128, 25, 0)
{{Cl|_ACCEPTFILEDROP}} 'enables drag/drop functionality
{{Cl|PRINT}} "Drag files from a folder and drop them in this window..."
{{Cl|DO}}
{{Cl|IF}} {{Cl|_TOTALDROPPEDFILES}} {{Cl|THEN}}
{{Cl|FOR}} i = 1 {{Cl|TO}} {{Cl|_TOTALDROPPEDFILES}}
a$ = {{Cl|_DROPPEDFILE}}(i)
{{Cl|COLOR}} 15
{{Cl|PRINT}} i,
{{Cl|IF}} {{Cl|_FILEEXISTS}}(a$) {{Cl|THEN}}
{{Cl|COLOR}} 2: {{Cl|PRINT}} "file",
{{Cl|ELSE}}
{{Cl|IF}} {{Cl|_DIREXISTS}}(a$) {{Cl|THEN}}
{{Cl|COLOR}} 3: {{Cl|PRINT}} "folder",
{{Cl|ELSE}}
{{Cl|COLOR}} 4: {{Cl|PRINT}} "not found", 'highly unlikely, but who knows?
{{Cl|END IF}}
{{Cl|END IF}}
{{Cl|COLOR}} 15
{{Cl|PRINT}} a$
{{Cl|NEXT}}
{{Cl|_FINISHDROP}}
{{Cl|END IF}}
{{Cl|_LIMIT}} 30
{{Cl|LOOP}}
{{CodeEnd}}
{{PageSeeAlso}}
* [[_ACCEPTFILEDROP]], [[_TOTALDROPPEDFILES]], [[_FINISHDROP]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
{{PageNavigation}}

32
internal/help/_ECHO.txt Normal file
View file

@ -0,0 +1,32 @@
{{DISPLAYTITLE:_ECHO}}
The [[_ECHO]] statement allows outputting text to a [[$CONSOLE]] window without having to alternate between [[_DEST]] pages.
{{PageSyntax}}
: [[_ECHO]] {''"text to output"'' | {{Parameter|textVariable$}}}
{{PageDescription}}
* [[_ECHO]] is a shorthand to saving current [[_DEST]], switching to [[_DEST]] [[_CONSOLE]], [[PRINT]]ing, then switching back to the previous [[_DEST]].
* To output numbers, use the [[STR$]] function.
==Availability==
* '''Version 1.3 and up'''.
{{PageExamples}}
{{CodeStart}}
{{Cl|$CONSOLE}}
{{Cl|PRINT}} "this will show in the main window"
{{Cl|_ECHO}} "this will show in the console"
{{CodeEnd}}
{{PageSeeAlso}}
* [[_DEST]]
* [[$CONSOLE]], [[_CONSOLE]]
* [[STR$]]
{{PageNavigation}}

View file

@ -0,0 +1,56 @@
{{DISPLAYTITLE:_FINISHDROP}}
The [[_FINISHDROP]] statement resets [[_TOTALDROPPEDFILES]] and clears the [[_DROPPEDFILE]] list of items (files/folders).
{{PageSyntax}}
: [[_FINISHDROP]]
{{PageDescription}}
* When using [[_DROPPEDFILE]] with an index (which goes from 1 to [[_TOTALDROPPEDFILES]]), you must call [[_FINISHDROP]] after you finish working with the list in order to prepare for the next drag/drop operation.
* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''.
==Availability==
* '''Version 1.3 and up'''.
{{PageExamples}}
''Example:'' Accepting files dragged from a folder and processing the list received by specifying an index.
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(128, 25, 0)
{{Cl|_ACCEPTFILEDROP}} 'enables drag/drop functionality
{{Cl|PRINT}} "Drag files from a folder and drop them in this window..."
{{Cl|DO}}
{{Cl|IF}} {{Cl|_TOTALDROPPEDFILES}} {{Cl|THEN}}
{{Cl|FOR}} i = 1 {{Cl|TO}} {{Cl|_TOTALDROPPEDFILES}}
a$ = {{Cl|_DROPPEDFILE}}(i)
{{Cl|COLOR}} 15
{{Cl|PRINT}} i,
{{Cl|IF}} {{Cl|_FILEEXISTS}}(a$) {{Cl|THEN}}
{{Cl|COLOR}} 2: {{Cl|PRINT}} "file",
{{Cl|ELSE}}
{{Cl|IF}} {{Cl|_DIREXISTS}}(a$) {{Cl|THEN}}
{{Cl|COLOR}} 3: {{Cl|PRINT}} "folder",
{{Cl|ELSE}}
{{Cl|COLOR}} 4: {{Cl|PRINT}} "not found", 'highly unlikely, but who knows?
{{Cl|END IF}}
{{Cl|END IF}}
{{Cl|COLOR}} 15
{{Cl|PRINT}} a$
{{Cl|NEXT}}
{{Cl|_FINISHDROP}} 'If _FINISHDROP isn't called here then _TOTALDROPPEDFILES never gets reset.
{{Cl|END IF}}
{{Cl|_LIMIT}} 30
{{Cl|LOOP}}
{{CodeEnd}}
{{PageSeeAlso}}
* [[_ACCEPTFILEDROP]], [[_TOTALDROPPEDFILES]], [[_DROPPEDFILE]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
{{PageNavigation}}

View file

@ -0,0 +1,19 @@
{{DISPLAYTITLE:_GLRENDER}}
{{PageSyntax}}
:'''_GLRENDER '''''mode''
{{Parameters}}
Mode can be:
* _BEHIND - renders OpenGL context behind the software rendering
* _ONTOP - renders OpenGL context on the top of the software rendering [default]
* _ONLY - renders OpenGL context only
''See also:''
* [[Hardware images]]
{{PageNavigation}}

40
internal/help/_HYPOT.txt Normal file
View file

@ -0,0 +1,40 @@
{{DISPLAYTITLE:_HYPOT}}
The [[_HYPOT]] function returns the hypotenuse of a right-angled triangle whose legs are x and y.
{{PageSyntax}}
: {{Parameter|result!}} = [[_HYPOT]]({{Parameter|x}}, {{Parameter|y}})
{{Parameters}}
* {{Parameter|x}} and {{Parameter|y}} are the floating point values corresponding to the legs of a right-angled (90 degree) triangle for which the hypotenuse is computed.
{{PageDescription}}
* The function returns what would be the square root of the sum of the squares of x and y (as per the Pythagorean theorem).
* The hypotenuse is the longest side between the two 90 degree angle sides
{{PageExamples}}
''Example:''
{{CodeStart}} '' ''
{{Cl|DIM}} leg_x {{Cl|AS}} {{Cl|DOUBLE}}, leg_y {{Cl|AS}} {{Cl|DOUBLE}}, result {{Cl|AS}} {{Cl|DOUBLE}}
leg_x = 3
leg_y = 4
result = {{Cl|_HYPOT}}(leg_x, leg_y)
{{Cl|PRINT}} {{Cl|USING}} "## , ## and ## form a right-angled triangle."; leg_x; leg_y; result
{{CodeEnd}}
{{OutputStart}}
3 , 4 and 5 form a right-angled triangle.
{{OutputEnd}}
{{PageSeeAlso}}
* [[ATN]] {{text|(arctangent)}}
* [[_PI]] {{text|(function)}}
* [[Mathematical Operations]]
* [http://www.cplusplus.com/reference/cmath/hypot/ C++ reference for hypot() - source of the text and sample above]
{{PageNavigation}}

View file

@ -0,0 +1,54 @@
{{DISPLAYTITLE:_INCLERRORFILE$}}
The [[_INCLERRORFILE$]] function returns the name of the original source code [[$INCLUDE]] module that caused the most recent error.
{{PageSyntax}}
: {{Parameter|errfile$}} = [[_INCLERRORFILE$]]
{{PageDescription}}
If the last error occurred in the main module, [[_INCLERRORFILE$]] returns an empty string.
==Availability==
* '''Version 1.1 and up'''.
{{PageExamples}}
''Example:''
{{CodeStart}}
{{Cl|ON ERROR}} {{Cl|GOTO}} DebugLine
{{Cl|ERROR}} 250 'simulated error code - an error in the main module leaves _INCLERRORLINE empty (= 0)
'{{Cl|$INCLUDE}}:'haserror.bi'
{{Cl|END}}
DebugLine:
{{Cl|PRINT}} "An error occurred. Please contact support with the following details:
{{Cl|PRINT}} "ERROR "; {{Cl|ERR}}; " ON LINE: "; {{Cl|_ERRORLINE}}
{{Cl|IF...THEN|IF}} {{Cl|_INCLERRORLINE}} {{Cl|THEN}}
{{Cl|PRINT}} " IN MODULE "; {{Cl|_INCLERRORFILE$}}; " (line"; {{Cl|_INCLERRORLINE}}; ")"
{{Cl|END IF}}
{{Cl|RESUME}} {{Cl|NEXT}} '' ''
{{CodeEnd}}
{{OutputStart}}An error occurred. Please contact support with the following details:
ERROR 250 ON LINE: 6
An error occurred. Please contact support with the following details:
ERROR 250 ON LINE: 9
IN MODULE haserror.bi ( line 1 )
{{OutputEnd}}
{{PageSeeAlso}}
* [[_INCLERRORLINE]]
* [[ON ERROR]], [[ERR]]
* [[ERROR]]
* [[ERROR Codes]]
* [[$INCLUDE]]
{{PageNavigation}}

View file

@ -0,0 +1,56 @@
{{DISPLAYTITLE:_INCLERRORLINE}}
The [[_INCLERRORFILE$]] function returns the line number in an [[$INCLUDE]] file that caused the most recent error.
{{PageSyntax}}
: {{Parameter|errline&}} = [[_INCLERRORLINE]]
{{PageDescription}}
* If the last error occurred in the main module, _INCLERRORLINE returns 0.
* By checking _INCLERRORLINE you can report exactly what line inside an included module caused the last error.
==Availability==
* '''Version 1.1 and up'''.
{{PageExamples}}
''Example:''
{{CodeStart}}
{{Cl|ON ERROR}} {{Cl|GOTO}} DebugLine
{{Cl|ERROR}} 250 'simulated error code - an error in the main module leaves _INCLERRORLINE empty (= 0)
'{{Cl|$INCLUDE}}:'haserror.bi'
{{Cl|END}}
DebugLine:
{{Cl|PRINT}} "An error occurred. Please contact support with the following details:
{{Cl|PRINT}} "ERROR "; {{Cl|ERR}}; " ON LINE: "; {{Cl|_ERRORLINE}}
{{Cl|IF...THEN|IF}} {{Cl|_INCLERRORLINE}} {{Cl|THEN}}
{{Cl|PRINT}} " IN MODULE "; {{Cl|_INCLERRORFILE$}}; " (line"; {{Cl|_INCLERRORLINE}}; ")"
{{Cl|END IF}}
{{Cl|RESUME}} {{Cl|NEXT}} '' ''
{{CodeEnd}}
{{OutputStart}}An error occurred. Please contact support with the following details:
ERROR 250 ON LINE: 6
An error occurred. Please contact support with the following details:
ERROR 250 ON LINE: 9
IN MODULE haserror.bi ( line 1 )
{{OutputEnd}}
{{PageSeeAlso}}
* [[_INCLERRORFILE$]]
* [[ON ERROR]], [[ERR]]
* [[ERROR]]
* [[ERROR Codes]]
* [[$INCLUDE]]
{{PageNavigation}}

View file

@ -0,0 +1,73 @@
{{DISPLAYTITLE:_INSTRREV}}
The [[_INSTRREV]] function searches for a substring inside another string, but unlike [[INSTR]] it searches from right to left.
{{PageSyntax}}
: {{Parameter|position%}} = [[_INSTRREV]]([{{Parameter|start%}},] {{Parameter|baseString$}}, {{Parameter|subString$}})
{{Parameters}}
* The optional literal or variable [[INTEGER]] {{Parameter|start%}} indicates where in the {{Parameter|baseString$}} the search must start, counted from the left.
* The {{Parameter|baseString$}} is a literal or variable [[STRING]] value to be searched for an exact match including [[UCASE$|letter cases]].
* The {{Parameter|subString$}} is a literal or variable [[STRING]] value being searched.
{{PageDescription}}
* The function returns the {{Parameter|position%}} in the {{Parameter|baseString$}} where the {{Parameter|subString$}} was found, from right to left.
* {{Parameter|position%}} will be 0 if the search found no matches in the base string.
* [[_INSTRREV]] returns 0 if an empty {{Parameter|baseString$}} is passed, and returns [[LEN]]({{Parameter|baseString$}}) with an empty {{Parameter|subString$}}.
* The {{Parameter|start%}} position is useful when making multiple searches in the same string. See the example below.
* The {{Parameter|subString$}} should be smaller or equal in [[LEN|length]] to the {{Parameter|baseString$}}, or 0 is returned.
* A {{Parameter|start%}} value of 0 or less starts search from the end of the {{Parameter|baseString$}} (same as not passing a {{Parameter|start%}} parameter).
{{PageExamples}}
''Example 1:'' Separating a file name from a full path.
{{CodeStart}}
fullPath$ = "C:\Documents and Settings\Administrator\Desktop\qb64\internal\c\libqb\os\win\libqb_1_2_000000000000.o"
file$ = {{Cl|MID$}}(fullPath$, {{Cl|_INSTRREV}}(fullPath$, "\") + 1)
{{Cl|PRINT}} file$
{{CodeEnd}}
{{OutputStart}}
libqb_1_2_000000000000.o
{{OutputEnd}}
''Example 2:'' Searching for multiple instances of a substring inside a base string, going from the end to the start.
{{CodeStart}}
sentence$ = " This is a string full of spaces, including at start and end... "
{{Cl|PRINT}} sentence$
{{Cl|DO}}
findPrevSpace% = {{Cl|_INSTRREV}}(findPrevSpace% - 1, sentence$, {{Cl|SPACE$}}(1))
{{Cl|IF}} findPrevSpace% = 0 {{Cl|THEN}}
{{Cl|LOCATE}} 4, 1
{{Cl|PRINT}} "No more spaces"
{{Cl|EXIT}} {{Cl|DO}}
{{Cl|END IF}}
{{Cl|LOCATE}} 2, findPrevSpace%
{{Cl|PRINT}} "^"
totalSpaces = totalSpaces + 1
{{Cl|IF}} findPrevSpace% = 1 {{Cl|THEN}}
{{Cl|LOCATE}} 4, 1
{{Cl|PRINT}} "Last space found at position 1"
{{Cl|EXIT}} {{Cl|DO}}
{{Cl|END IF}}
{{Cl|LOOP}}
{{Cl|PRINT}} "Total spaces found: "; totalSpaces
{{CodeEnd}}
{{OutputStart}}
This is a string full of spaces, including at start and end...
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
Last space found at position 1
Total spaces found: 13
{{OutputEnd}}
{{PageSeeAlso}}
* [[MID$]], [[INSTR]]
* [[SPACE$]]
{{PageNavigation}}

67
internal/help/_SHL.txt Normal file
View file

@ -0,0 +1,67 @@
{{DISPLAYTITLE:_SHL}}
The [[_SHL]] function is used to shift the bits of a numerical value to the left.
{{PageSyntax}}
:{{Parameter|result}} = [[_SHL]]({{Parameter|numericalVariable}}, {{Parameter|numericalValue}})
{{Parameters}}
* {{Parameter|numericalVariable}} is the variable to shift the bits of and can be of the following types: [[INTEGER]], [[LONG]],[[_INTEGER64]], or [[_BYTE]].
* Integer values can be signed or [[_UNSIGNED]].
* {{Parameter|numericalValue}} is the number of places to shift the bits.
* While 0 is a valid value it will have no affect on the variable being shifted.
{{PageDescription}}
* Allows for multiplication of a value by 2 faster than normal multiplication (see example 2 below).
* Bits that reach the end of a variable's bit count are dropped (when using a variable of the same type - otherwise they will carry over).
* The type of variable used to store the results should match the type of the variable being shifted.
==Availability==
* '''Version 1.3 and up'''.
{{PageExamples}}
''Example 1:''
{{CodeStart}}A~%% = 1 'set right most bit of an{{Cl|_UNSIGNED}} {{Cl|_BYTE}}
{{Cl|PRINT}} A~%%
{{Cl|PRINT}} {{Cl|_SHL}}(A~%%,7)
B~%% = {{Cl|_SHL}}(A~%%,8) 'shift the bit off the left 'edge'
{{Cl|PRINT}} B~%%
{{CodeEnd}}
{{OutputStart}}
1
128
0
{{OutputEnd}}
''Example 2:''
{{CodeStart}}
A~%% = 1
{{Cl|FOR}} I%% = 0 {{Cl|TO}} 8
{{Cl|PRINT}} {{Cl|_SHL}}(A~%%, I%%)
{{Cl|NEXT I%%}}
{{CodeEnd}}
{{OutputStart}}
1
2
4
8
16
32
64
128
256
{{OutputEnd}}
* Note: When directly [[PRINT]]ing to screen, the result is calculated internally using a larger variable type so the left most bit is carried to the next value.
** To avoid this store the result in a variable of the same type before printing.
{{PageSeeAlso}}
* [[_SHR]], [[INTEGER]], [[LONG]]
* [[_BYTE]], [[_INTEGER64]]
{{PageNavigation}}

64
internal/help/_SHR.txt Normal file
View file

@ -0,0 +1,64 @@
{{DISPLAYTITLE:_SHR}}
The [[_SHR]] function is used to shift the bits of a numerical value to the right.
{{PageSyntax}}
:{{Parameter|result}} = [[_SHR]]({{Parameter|numericalVariable}}, {{Parameter|numericalValue}})
{{Parameters}}
* {{Parameter|numericalVariable}} is the variable to shift the bits of and can be of the following types: [[INTEGER]], [[LONG]], [[_INTEGER64]], or [[_BYTE]].
* Integer values can be signed or [[_UNSIGNED]].
* {{Parameter|numericalValue}} the number of places to shift the bits.
* While 0 is a valid value it will have no affect on the variable being shifted.
{{PageDescription}}
* Allows for division of a value by 2 faster than normal division (see example 2 below).
* Bits that reach the end of a variables bit count are dropped.
* The type of variable used to store the results should match the type of the variable being shifted.
==Availability==
* '''Version 1.3 and up'''.
{{PageExamples}}
''Example 1:''
{{CodeStart}}A~%% = 128 'set left most bit of an{{Cl|_UNSIGNED}} {{Cl|_BYTE}}
{{Cl|PRINT}} A~%%
{{Cl|PRINT}} {{Cl|_SHR}}(A~%%,7)
{{Cl|PRINT}} {{Cl|_SHR}}(A~%%,8) 'shift the bit off the right 'edge'
{{CodeEnd}}
{{OutputStart}}
128
1
0
{{OutputEnd}}
''Example 2:''
{{CodeStart}}
A~%% = 128
{{Cl|FOR}} I%% = 0 {{Cl|TO}} 8
{{Cl|PRINT}} {{Cl|_SHR}}(A~%%, I%%)
{{Cl|NEXT I%%}}
{{CodeEnd}}
{{OutputStart}}
128
64
32
16
8
4
2
1
0
{{OutputEnd}}
{{PageSeeAlso}}
* [[_SHL]], [[INTEGER]], [[LONG]]
* [[_BYTE]], [[_INTEGER64]]
{{PageNavigation}}

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

@ -0,0 +1,22 @@
{{DISPLAYTITLE:_TITLE$}}
The [[_TITLE$]] function returns the program title last set by the [[_TITLE]] statement.
{{PageSyntax}}
: {{Parameter|currentTitle$}} = [[_TITLE$]]
{{PageDescription}}
* If no title has been set, the title bar will say "Untitled" and this function will return an empty [[STRING|string]] ("").
==Availability==
* '''Build 20170924/68.'''
{{PageSeeAlso}}
* [[_TITLE]]
* [[_CONSOLETITLE]]
{{PageNavigation}}

View file

@ -0,0 +1,29 @@
{{DISPLAYTITLE:_TOTALDROPPEDFILES}}
The [[_TOTALDROPPEDFILES]] function returns the number of items (files or folders) dropped in a program's window after [[_ACCEPTFILEDROP]] is enabled.
{{PageSyntax}}
: {{Parameter|totalFilesReceived&}} = [[_TOTALDROPPEDFILES]]
{{PageDescription}}
* After [[_ACCEPTFILEDROP]] is enabled, [[_TOTALDROPPEDFILES]] will return 0 until the user drops files or folders into the program's window.
* When using [[_DROPPEDFILE]] to read the list sequentially, [[_TOTALDROPPEDFILES]] will be reset to 0 after the last item is retrieved (after [[_DROPPEDFILE]] returns an empty string "").
* If using [[_DROPPEDFILE]] with an index, you must call [[_FINISHDROP]] after you finish working with the list.
* When using [[_DROPPEDFILE]] to read the list with an index, [[_TOTALDROPPEDFILES]] will '''not''' be reset (and the list of items won't be cleared) until [[_FINISHDROP]] is called.
* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''.
==Availability==
* '''Version 1.3 and up'''.
{{PageExamples}}
* See example for [[_ACCEPTFILEDROP]]
{{PageSeeAlso}}
* [[_ACCEPTFILEDROP]], [[_DROPPEDFILE]], [[_FINISHDROP]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
{{PageNavigation}}

View file

@ -0,0 +1,96 @@
{{DISPLAYTITLE:_WINDOWHANDLE}}
The [[_WINDOWHANDLE]] function returns the window handle assigned to the current program by the OS. Windows-only.
{{PageSyntax}}
: {{Parameter|hwnd~&}} = [[_WINDOWHANDLE]]
{{PageDescription}}
* The result is an [[_UNSIGNED]] [[LONG]] number assigned by Windows to your running program.
* Use it to make [[Windows Libraries|API calls]] that require a window handle to be passed.
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]].
==Availability==
* '''Build 20170924/68'''.
{{PageExamples}}
''Example:'' Showing the system-default message box in Windows.
{{CodeStart}} '' ''
'Message Box Constant values as defined by Microsoft (MBType)
{{Cl|CONST}} MB_OK& = 0 'OK button only
{{Cl|CONST}} MB_OKCANCEL& = 1 'OK & Cancel
{{Cl|CONST}} MB_ABORTRETRYIGNORE& = 2 'Abort, Retry & Ignore
{{Cl|CONST}} MB_YESNOCANCEL& = 3 'Yes, No & Cancel
{{Cl|CONST}} MB_YESNO& = 4 'Yes & No
{{Cl|CONST}} MB_RETRYCANCEL& = 5 'Retry & Cancel
{{Cl|CONST}} MB_CANCELTRYCONTINUE& = 6 'Cancel, Try Again & Continue
{{Cl|CONST}} MB_ICONSTOP& = 16 'Error stop sign icon
{{Cl|CONST}} MB_ICONQUESTION& = 32 'Question-mark icon
{{Cl|CONST}} MB_ICONEXCLAMATION& = 48 'Exclamation-point icon
{{Cl|CONST}} MB_ICONINFORMATION& = 64 'Letter i in a circle icon
{{Cl|CONST}} MB_DEFBUTTON1& = 0 '1st button default(left)
{{Cl|CONST}} MB_DEFBUTTON2& = 256 '2nd button default
{{Cl|CONST}} MB_DEFBUTTON3& = 512 '3rd button default(right)
{{Cl|CONST}} MB_APPLMODAL& = 0 'Message box applies to application only
{{Cl|CONST}} MB_SYSTEMMODAL& = 4096 'Message box on top of all other windows
{{Cl|CONST}} MB_SETFOCUS& = 65536 'Set message box as focus
{{Cl|CONST}} IDOK& = 1 'OK button pressed
{{Cl|CONST}} IDCANCEL& = 2 'Cancel button pressed
{{Cl|CONST}} IDABORT& = 3 'Abort button pressed
{{Cl|CONST}} IDRETRY& = 4 'Retry button pressed
{{Cl|CONST}} IDIGNORE& = 5 'Ignore button pressed
{{Cl|CONST}} IDYES& = 6 'Yes button pressed
{{Cl|CONST}} IDNO& = 7 'No button pressed
{{Cl|CONST}} IDTRYAGAIN& = 10 'Try again button pressed
{{Cl|CONST}} IDCONTINUE& = 1 'Continue button pressed
'----------------------------------------------------------------------------------------
{{Cl|DECLARE LIBRARY|DECLARE DYNAMIC LIBRARY}} "user32"
{{Cl|FUNCTION}} MessageBoxA& ({{Cl|BYVAL}} hwnd {{Cl|AS}} {{Cl|LONG}}, Message {{Cl|AS}} {{Cl|STRING}}, Title {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} MBType {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}})
{{Cl|DECLARE LIBRARY|END DECLARE}}
DO
msg& = 0: icon& = 0: DB& = 0
{{Cl|INPUT}} "Enter Message Box type(0 to 6 other Quits): ", BOX&
{{Cl|IF...THEN|IF}} BOX& < 0 {{Cl|OR (boolean)|OR}} BOX& > 6 {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|INPUT}} "Enter Icon&(0=none, 1=stop, 2=?, 3=!, 4=info): ", Icon&
{{Cl|IF...THEN|IF}} BOX& {{Cl|THEN}} {{Cl|INPUT (file mode)|INPUT}} "Enter Default Button(1st, 2nd or 3rd): ", DB&
{{Cl|IF...THEN|IF}} DB& {{Cl|THEN}} DB& = DB& - 1 'adjust value to 0, 1, or 2
msg& = MsgBox&("Box Title", "Box text message", BOX&, Icon&, DB&, 4096) 'on top of all windows
{{Cl|PRINT}} "Button ="; msg&
{{Cl|LOOP}}
{{Cl|END}}
{{Cl|FUNCTION}} MsgBox& (Title$, Message$, BoxType&, Icon&, DBtn&, Mode&)
{{Cl|SELECT CASE}} Icon&
{{Cl|CASE}} 1: Icon& = MB_ICONSTOP& 'warning X-sign icon
{{Cl|CASE}} 2: Icon& = MB_ICONQUESTION& 'question-mark icon
{{Cl|CASE}} 3: Icon& = MB_ICONEXCLAMATION& 'exclamation-point icon
{{Cl|CASE}} 4: Icon& = MB_ICONINFORMATION& 'lowercase letter i in circle
{{Cl|CASE ELSE}}: Icon& = 0 'no icon
{{Cl|END SELECT}}
{{Cl|IF...THEN|IF}} BoxType& > 0 {{Cl|AND (boolean)|AND}} DBtn& > 0 {{Cl|THEN}} 'set default button as 2nd(256) or 3rd(512)
{{Cl|SELECT CASE}} BoxType&
{{Cl|CASE}} 2, 3, 6
{{Cl|IF...THEN|IF}} DBtn& = 2 {{Cl|THEN}} Icon& = Icon& + MB_DEFBUTTON3& {{Cl|ELSE}} Icon& = Icon& + MB_DEFBUTTON2& '3 button
{{Cl|CASE ELSE}}: Icon& = Icon& + MB_DEFBUTTON2& '2nd button default
{{Cl|END SELECT}}
{{Cl|END IF}}
Focus& = MB_SetFocus&
MsgBox& = MessageBoxA&({{Cl|_WINDOWHANDLE}}, Message$, Title$, BoxType& + Icon& + Mode& + Focus&) 'focus on button
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
:''Explanation:'' Notice how the call to the external dynamic library function MessageBoxA& passes _WINDOWHANDLE to the API and how the message box shown is created as a child of your program's window, not allowing the main window to be manipulated while the message box is open.
{{PageSeeAlso}}
* [[_WINDOWHASFOCUS]]
* [[Windows Libraries]]
{{PageNavigation}}

View file

@ -0,0 +1,42 @@
{{DISPLAYTITLE:_WINDOWHASFOCUS}}
The [[_WINDOWHASFOCUS]] function returns true (-1) if the current program's window has focus. Windows-only.
{{PageSyntax}}
: {{Parameter|hasFocus%%}} = [[_WINDOWHASFOCUS]]
{{PageDescription}}
* The function returns true (-1) if the current program is the topmost window on the user's desktop and has focus. If the current program is running behind another window, the function returns false (0).
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]].
==Availability==
* '''Build 20170924/68'''.
{{PageExamples}}
''Example:'' Detecting if the current program has focus. Windows-only.
{{CodeStart}} '' ''
DO
{{Cl|IF}} {{Cl|_WINDOWHASFOCUS}} THEN
{{Cl|COLOR}} 15, 6
{{Cl|CLS}}
{{Cl|PRINT}} "*** Hi there! ***"
{{Cl|ELSE}}
{{Cl|COLOR}} 0, 7
CLS
PRINT "(ain't nobody looking...)"
{{Cl|END IF}}
{{Cl|_DISPLAY}}
{{Cl|_LIMIT}} 30
{{Cl|LOOP}}
{{CodeEnd}}
: ''Explanation:'' The program will display ''"*** Hi There! ***"'' while the window is the topmost and is being manipulated by the user. If another window, the taskbar or the desktop are clicked, the program window loses focus and the message ''"(ain't nobody looking...)"'' is displayed.
{{PageSeeAlso}}
* [[_SCREENEXISTS]]
{{PageNavigation}}

24
internal/help/radians.txt Normal file
View file

@ -0,0 +1,24 @@
'''Radians''' are units of measure based on the value of 2 * PI. There are '''6.283185307179586''' radians in a '''360º''' rotation.
* To convert from radians to degrees: '''degrees = radians * 180 / π''' = radians * 57.2958
* To convert from degrees to radians: '''radians = degrees * π / 180''' = degrees * .017453
* For other formulas and a radian chart go to the following link: [http://en.wikipedia.org/wiki/Radian Radian WIKI]
* Angle values sent to [[SIN]], [[COS]], [[TAN]], [[ATN]] are measured in radians.
* A program can calculate PI for you using the ATN function: '''π = 4 * ATN(1#)'''
''See also:''
* [http://qb64.net/wiki/index.php?title=Mathematical_Operations#Derived_Mathematical_Functions Derived Mathematical Functions]
{{PageNavigation}}

29
internal/help/segment.txt Normal file
View file

@ -0,0 +1,29 @@
The memory '''segment''' is the hexadecimal byte address in relation to a segment register.
The value in a Segment register is multiplied by 16 or shifted one hexadecimal byte to the left(this adds an extra 0 to the end of the hex number). The value in the Offset register is added to it. So, the Absolute address for any combination of Segment and Offset is found using the formula:
:::AbsoluteMemoryAddress = (Segment value * 16) + Offset value
''Example:''
{{WhiteStart}} '' ''
Segment Address = F000{{text|0 ← shifted left|red}}
Offset Address = + FACE
------
FFACE or 1,047,246 '' ''
{{WhiteEnd}}
The Offset value is the position of a value after the segment address. Many pairs can be used to refer to the same memory position.
''See also:''
* [[DEF SEG]], [[DEF SEG = 0]]
* [[PEEK]], [[POKE]]
* [[VARSEG]], [[VARPTR]]
* [[SADD]]
{{PageNavigation}}