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

Update help file [ci-skip]

This commit is contained in:
FellippeHeitor 2021-10-09 14:06:54 -03:00
parent 37b7a7248c
commit 11a6422926
24 changed files with 348 additions and 43 deletions

View file

@ -8,7 +8,8 @@ The [[$CONSOLE]] [[metacommand]] creates a console window that can be used throu
{{Description}}
* [[_CONSOLE]] '''ON''' or '''OFF''' may be used to show or hide the console window at run time.
* The ''':ONLY''' option can be used when only a console window is desired without a program window.
* [[_DEST]] [[_CONSOLE]] may be used to send screen output to the console window.
* [[_DEST]] and [[_SOURCE]] are automatically set to [[_CONSOLE]] when the ''':ONLY''' option is used, in order to send screen output to the console window and get input from it too.
** In normal [[$CONSOLE]] mode (dual screen) you have to manually set [[_DEST]] and [[_SOURCE]] to [[_CONSOLE]] in order to work with the console window.
* [[_SCREENHIDE]] and [[_SCREENSHOW]] can be used to hide or show the main program window.
* [[_DELAY]] or [[SLEEP]] can be used to allow the console window to be set in front of the main program window.
* [[_CONSOLETITLE]] can be used to change the title of the console window.

41
internal/help/$DEBUG.txt Normal file
View file

@ -0,0 +1,41 @@
{{DISPLAYTITLE:$DEBUG}}
'''$DEBUG''' is precompiler [[Metacommand|metacommand]], which enables debugging features, allowing you to step through your code running line by line and to inspect variables and change their values in real time.
{{PageSyntax}}
:[[$DEBUG]]
{{PageDescription}}
* $DEBUG injects extra code in the resulting binary, allowing the IDE to control the execution flow of your program.
* When $DEBUG is used, the IDE will connect to your running program using a local TCP/IP connection.
** You may get a prompt from your Operating System regarding this, so it may be necessary to allow the IDE to receive connections.
** No external connections are created, and your running program will only attempt to connect locally to the IDE.
* The default TCP/IP port starts at 9001. Multiple running instances of the IDE will attempt to open ports 9002 and up.
** You can change the base port in the Debug menu.
* The metacommand is supposed to be removed once your program is ready for release, although leaving it in won't have any effect if your program isn't run from the IDE.
** The only drawback of leaving the metacommand in is that your binary will end up being larger than required.
== $DEBUG Mode Operation ==
* To start execution in pause mode, you can use F7 or F8.
* There will be an arrow next to the line number where execution is paused, indicating the next line that will be run.
* When you enable $DEBUG mode, you can set breakpoints by clicking the line number at which you wish to stop execution. This can also be achieved by using the F9 key.
** Breakpoints are indicated by a red dot next to the line number.
** To clear all breakpoints, hit F10.
* To skip a line during execution, shift-click a line number
** Lines marked for skipping are indicated by an exclamation mark next to the line number.
* F4 opens the Variable List dialog, which allows you to add variables to the Watch List.
* During execution, the Variable List dialog also allows you to set the values of variables and also to create Watchpoints.
* Watchpoints halt execution, similarly to breakpoints, but do so when a variable matches the condition you specify.
** You can use relational operators (=, <>, >=, <=, >, <) to create watchpoint conditions.
* F6 can be used when the execution pointer is inside a sub/function. When used, execution will proceed until the procedure is ended.
* F7 can be used to run line by line (Step Into).
* F8 can be used to run line by line without entering sub/function calls (Step Over).
* F12 can be used to show the current call stack (which procedure calls led to the current line).
{{PageSeeAlso}}
* [[Metacommand]]s
{{PageNavigation}}

View file

@ -7,10 +7,16 @@
{{PageDescription}}
* Unlike [[LET]], [[$LET]] is not optional.
* $LET a = 12 sets a precompiler variable "a" to the value of 12. This variable is only valid for the precompiler itself and does nothing to affect the values of any variable/constant which might also be called "a" in the program.
* Variable names can contain numbers, letters, and periods in any order. [[$LET]] '''3.2 = TRUE''' is a perfectly valid variable and expression.
* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters, and periods, in any order. [[$LET]] '''3.2 = "TRUE"''' is also perfectly valid, but [[$LET]] '''3.2 = ""TRUE""''' will error because of the double quotes.
* $LET A = 12 sets a precompiler variable "a" to the value of 12. This variable is only valid for the precompiler itself and does nothing to affect the values of any variable/constant which might also be called "a" in the program.
* Variable names must follow QB64's variable naming conventions.
* You can check a precompiler variable against special values '''DEFINED''' and '''UNDEFINED''', in order to assess whether the variable has already been assigned a value. Useful for code in libraries which may be repeated.
* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude. These are:
** '''WIN''' or '''WINDOWS''' if the user is running QB64 in a Windows environment.
** '''LINUX''' if the user is running QB64 in a Linux environment.
** '''MAC''' or '''MACOSX''' if the user is running QB64 in a macOS environment.
** '''32BIT''' if the user is running a 32-bit version of QB64.
** '''64BIT''' if the user is running a 64-bit version of QB64.
** '''VERSION''', which is set to the version of the QB64 compiler.
{{PageExamples}}

View file

@ -11,7 +11,7 @@ The [[$NOPREFIX]] metacommand allows all QB64 functions and statements to be use
* If you are writing new code with QB64, and not importing code from QBasic/QuickBASIC 4.5, [[$NOPREFIX]] allows you to reduce typing by not having to use underscores in modern keywords.
* '''SUB _GL''' still must be prefixed.
* When [[$NOPREFIX]] is used, QB64 keywords can be used both with or without the leading underscore, so that both [[_DISPLAY]] and [[_DISPLAY|DISPLAY]] are valid in the same program, for example.
* [[$NOPREFIX]] must be the first non-comment and non-whitespace line in a program.
* [[$NOPREFIX]] can be placed anywhere in a program.
{{PageAvailability}}

View file

@ -14,6 +14,7 @@ The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resul
{{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).
* A manifest file is automatically embedded into the resulting .exe file so that Common Controls v6.0 gets linked at runtime, if required.
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]].

View file

@ -7,7 +7,7 @@ The [[_DIR$]] function returns common paths in '''Windows''' only such as My Doc
{{PageParameters}}
* ''folderspecification'' may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data".
* ''folderspecification'' may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data", "program files", "program files (x86)", "temp".
* Some variation is accepted for the folder specification:
:: MY DOCUMENTS, TEXT, DOCUMENT, DOCUMENTS, DOWNLOAD, DOWNLOADS
:: MY MUSIC, MUSIC, AUDIO, SOUND, SOUNDS

View file

@ -1,4 +1,4 @@
The [[ENVIRON$]] function returns a [[STRING]] environmental value from '''Windows'''' environmental settings list.
The [[ENVIRON$]] function returns a [[STRING]] environmental value from the Operating System's environmental settings list.
{{PageSyntax}}
@ -8,7 +8,7 @@ The [[ENVIRON$]] function returns a [[STRING]] environmental value from '''Windo
{{PageDescription}}
* The function can use an [[INTEGER]] {{Parameter|listIndex%}} value or [[STRING]] {{Parameter|systemID$}} parameter.
* {{Parameter|listIndex%}} refers to the number order of the environmental list. Returns are not in any particular numerical order.
* {{Parameter|systemID$}} is the specific [[STRING]] parameter requested. Returns only the specified environmental [[STRING]] setting:
* {{Parameter|systemID$}} is the specific [[STRING]] parameter requested. Returns only the specified environmental [[STRING]] setting (examples based on Windows):
** "BLASTER" = current Sound Blaster settings if installed.
** "COMPUTERNAME" or "USERDOMAIN" = OEM PC serial number or the computer name assigned by owner.
** "HOMEDRIVE" or "SystemDrive" = Windows root drive, normally C: on single partition drives.
@ -117,7 +117,7 @@ Q$ = {{Cl|CHR$}}(34) '=== Write URL Shortcut file info.
''See also:''
* [[ENVIRON]] (statement)
* [[ENVIRON]] (statement), [[_ENVIRONCOUNT]]
* [[_DEVICES]], [[_DEVICE$]]
* [[_LASTBUTTON]], [[_OS$]]
* [[Windows Environment]]

View file

@ -11,11 +11,12 @@ The [[ENVIRON]] statement is used to temporarily set or change an environmental
** Using a space: [[ENVIRON]] "parameterID setting"
* If the parameter ID did not previously exist in the environmental string table, it is appended to the end of the table.
* If a parameter ID did exist, it is deleted and the new value is appended to end of the list.
* The [[_ENVIRONCOUNT]] function returns the number of key/value pairs that currently exist.
* Any changes made at runtime are discarded when your program ends.
{{PageSeeAlso}}
* [[ENVIRON$]]
* [[ENVIRON$]], [[_ENVIRONCOUNT]]
* [[Windows Environment]]

View file

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

View file

@ -112,6 +112,7 @@ __NOTOC__
* [[_D2R]] (function) {{text|converts degrees to radian angle values.}}
* [[DECLARE LIBRARY|DECLARE LIBRARY (QB64 statement block)]] {{text|declares a C++, SDL or Operating System [[SUB]] or [[FUNCTION]] to be used.}}
* [[DECLARE DYNAMIC LIBRARY|DECLARE DYNAMIC LIBRARY (QB64 statement)]] {{text|declares DYNAMIC, CUSTOMTYPE or STATIC library (DLL) [[SUB]] or [[FUNCTION]].}}
* [[$DEBUG]] (precompiler [[metacommand]]) {{text|enables debugging features allowing you to step through your code running line by line and to inspect variables and change their values in real time.}}
* [[_DEFAULTCOLOR]] (function) {{text|returns the current default text color for an image handle or page.}}
* [[_DEFINE]] (statement) {{text|defines a range of variable names according to their first character as a data type.}}
* [[_DEFLATE$]] (function) {{text|compresses a string}}
@ -142,6 +143,7 @@ __NOTOC__
* [[$ELSE]] (precompiler [[metacommand]]) {{text|used in conjunction with $IF for the precompiler.}}
* [[$ELSEIF]] (precompiler [[metacommand]]) {{text|used in conjunction with $IF for the precompiler.}}
* [[$END IF]] (precompiler [[metacommand]]) {{text|used in conjunction with $IF for the precompiler.}}
* [[_ENVIRONCOUNT]] (function) {{text|returns the number of key/value pairs currently exist in the environment table.}}
* [[$ERROR]] (precompiler [[metacommand]]) {{text|used to trigger compiler errors.}}
* [[_ERRORLINE]] (function) {{text|returns the source code line number that caused the most recent runtime error.}}
* [[_ERRORMESSAGE$]] (function) {{text|returns a human-readable message describing the most recent runtime error.}}
@ -207,8 +209,8 @@ __NOTOC__
<div id = "uK">_K</div>
*[[_KEYCLEAR]] (statement) {{text|clears the keyboard buffers for INKEY$, _KEYHIT, and INP.}}
*[[_KEYHIT]] (function) {{text|returns [[ASCII]] one and two byte, SDL Virtual Key and [[Unicode]] keyboard key press codes.}}
*[[_KEYDOWN]] (function) {{text|returns whether CTRL, ALT, SHIFT, combinations and other keys are pressed.}}
*[[_KEYHIT]] (function) {{text|returns [[ASCII]] one and two byte, Virtual Key and [[Unicode]] keyboard key press codes.}}
----
@ -521,7 +523,7 @@ __NOTOC__
* [[ELSEIF]] ([[IF...THEN]] statement) {{text|is used with [[THEN]] to set alternate conditional evaluations.}}
* [[END]] (statement) {{text|sets the end of a program, sub-procedure, statement block, [[DECLARE LIBRARY]] or [[TYPE]] definition.}}
* [[IF...THEN|END IF]] (statement) {{text|[[END]]s an IF...THEN conditional block statement using more than one line of code.}}
* [[ENVIRON]] (statement) {{text|temporarily sets an environmental key/pair value.}}
* [[ENVIRON]] (statement) {{text|temporarily sets an environmental key/value pair.}}
* [[ENVIRON$]] (function) {{text|returns a specified string setting or numerical position as an environmental [[STRING]] value.}}
* [[EOF]] (file function) {{text|returns -1 when a file [[INPUT (file statement)|INPUT]] or [[GET]] has reached the end of a file.}}
* [[EQV]] (logic operator) {{text|is used to compare two numerical values bitwise.}}

View file

@ -186,8 +186,9 @@
* [[CHDIR]] (statement) {{text|changes the program path to a new path.}}
* [[COMMAND$]] (function) {{text|returns command line parameters sent when a program is started.}}
* [[ENVIRON]] (statement) {{text|temporarily sets an environmental key/pair value.}}
* [[ENVIRON]] (statement) {{text|temporarily sets an environmental key/value pairs.}}
* [[ENVIRON$]] (function) {{text|returns the environmental settings of the computer.}}
* [[_ENVIRONCOUNT]] (function) {{text|returns the number of key/value pairs currently exist in the environment table.}}
* [[FILES]] (statement) {{text|displays a specified list of files.}}
* [[MKDIR]] (statement) {{text|creates a new directory folder in the designated path.}}
* [[NAME]] (statement) {{text|renames a file.}}
@ -333,12 +334,13 @@ The following table describes the error codes that are reported by the '''QB64''
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
== Error Trapping ==
== Error Trapping/Debugging ==
* [[_ASSERT]] (statement) {{text|performs debug tests.}}
* [[$ASSERTS]] ([[Metacommand]]) {{text|enables the [[_ASSERT]] macro.}}
* [[$CHECKING]] ([[Metacommand]]) {{text|turns off or on error event checking and strips error code from compiled programs.}}
* [[$DEBUG]] (precompiler [[metacommand]]) {{text|enables debugging features allowing you to step through your code running line by line and to inspect variables and change their values in real time.}}
* [[_ERRORLINE]] (function) {{text|returns the actual text code line where a program error occurred.}}
* [[_INCLERRORFILE$]] (function) {{text|returns the name of the original source code $INCLUDE module that caused the most recent error.}}
* [[_INCLERRORLINE]] (function) {{text|returns the line number in an included file that caused the most recent error.}}

145
internal/help/MEM.txt Normal file
View file

@ -0,0 +1,145 @@
{{DISPLAYTITLE:_MEM}}
The [[_MEM]] variable type can be used when working with memory blocks. It has no variable [[Variable Types|type]] suffix.
{{PageSyntax}}
: [[DIM]] m [[AS]] [[_MEM]]
{{PageDescription}}
''Variable TYPE:''
* Memory DOT values are actually part of the built in memory variable [[Variable Types|type]] in QB64. The following [[TYPE]] is built in:
{{WhiteStart}}TYPE memory_type
OFFSET AS _OFFSET 'start location of block(changes with byte position)
SIZE AS _OFFSET 'size of block remaining at offset(changes with position)
TYPE AS _OFFSET 'type description of variable used(never changes)
ELEMENTSIZE AS _OFFSET 'byte size of values inside the block(never changes)
IMAGE AS LONG 'the image handle used when _MEMIMAGE(handle) is used
SOUND AS LONG 'the sound handle used when _MEMSOUND(handle) is used
END TYPE
{{text|The above [[TYPE]] is for clarification purposes only. It '''doesn't need''' to be pasted in a program to use _MEM.|red}}
{{WhiteEnd}}
===Usage===
* The _MEM type contains the following '''read-only''' elements where ''name'' is the _MEM variable name:
:: ''name'''''.OFFSET''' is the current start position in the memory block AS [[_OFFSET]]. Add bytes to change position.
:: ''name'''''.SIZE''' is the remaining size of the block at current position in bytes AS [[_OFFSET]]
:: ''name'''''.TYPE''' is the type (represented as bits combined to form a value) AS [[_OFFSET]]:
==.TYPE values ==
:::* [bit 0] 1* byte types (_BYTE)
:::* [bit 1] 2* byte types (INTEGER)
:::* [bit 2] 4* byte types (LONG or SINGLE)
:::* [bit 3] 8* byte types (DOUBLE or _INTEGER64)
:::* [bit 4] 16* byte types (reserved for future use)
:::* [bit 5] 32* byte types (_FLOAT)
:::* [bit 6] 64* byte types (reserved for future use)
:::* [bit 7] 128 = integer types (_BYTE, INTEGER, LONG, _INTEGER64) (added to *)
:::* [bit 8] 256 = floating point types (SINGLE, DOUBLE, _FLOAT) (added to *)
:::* [bit 9] 512 = STRING types (fixed length or variable length)
:::* [bit 10] 1024 = _UNSIGNED types (added to *+128)
:::* [bit 11] 2048 = pixel data usually from _MEMIMAGE (added to 1+128+1024 for 256 color screens, or 2+128+1024 for text screens, or 4+128+1024 for 32-bit color screens)
:::* [bit 12] 4096 = _MEM TYPE structure (NOT added to 32768)
:::* [bit 13] 8192 = _OFFSET type (added to 4+128+[1024] or 8+128+[1024] or future_size+128+[1024])
:::* [bit 14] 16384 = data created/defined by _MEMNEW(size) or _MEMNEW(offset,size)
:::* [bit 15] 32768 = a custom, user defined type (ie. created with TYPE name ... END TYPE)
:::* [bit 16] 65536 = an array of data (added to other type values defining the array's data type)
''Note: If a future integer, float or other type doesn't have a size that is 1,2,4,8,16,32,64,128 or 256 it won't have a size-bit set.''
* '''Note: [[_OFFSET]] values cannot be cast to other variable [[Variable Types|type]]s reliably. _MEM is a reserved custom variable [[Variable Types|type]].'''
* '''[[_MEM (function)|_MEM]] cannot reference variable length [[STRING]] variable values. String values must be designated as a fixed-[[LEN|length]] string.'''
{{PageExamples}}
''Example 1:'' Demonstration of .IMAGE to determine an image's dimensions, .TYPE to verify the type and [[_MEMEXISTS]] to check image has not been freed
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(500, 500, 32)
i = {{Cl|_LOADIMAGE}}("qb64_trans.png", 32)
{{Cl|_PUTIMAGE}} (0, 0), i
{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}}
m = {{Cl|_MEMIMAGE}}(i)
'try uncommenting the following line and see what happens
'{{Cl|_MEMFREE}} m
t = m.{{Cl|TYPE}}
{{Cl|IF...THEN|IF}} t {{Cl|AND (boolean)|AND}} 2048 {{Cl|THEN}}
{{Cl|PRINT}} "this is/was an image"
{{Cl|IF...THEN|IF}} {{Cl|_MEMEXISTS}}(m) {{Cl|THEN}} 'check if memory m is still available
{{Cl|PRINT}} t {{Cl|AND (boolean)|AND}} 7; "bytes per pixel"
{{Cl|PRINT}} "image handle "; m.IMAGE
{{Cl|PRINT}} "image width"; {{Cl|_WIDTH (function)|_WIDTH}}(m.IMAGE)
{{Cl|PRINT}} "image height"; {{Cl|_HEIGHT}}(m.IMAGE)
{{Cl|ELSE}} {{Cl|PRINT}} "Memory already freed!"
{{Cl|END IF}}
{{Cl|END IF}} '' ''
{{CodeEnd}}
''Example 2:'' Converts the current [[_DEST|destination]] [[SCREEN]] 13 image memory altered by [[PSET]] to a [[STRING]] value. SCREEN 13 only.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 13
{{Cl|PSET}} (0, 0), {{Cl|ASC}}("H") 'top left corner of screen
{{Cl|PSET}} (1, 0), {{Cl|ASC}}("E")
{{Cl|PSET}} (2, 0), {{Cl|ASC}}("L")
{{Cl|PSET}} (3, 0), {{Cl|ASC}}("L")
{{Cl|PSET}} (4, 0), {{Cl|ASC}}("O")
{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}}
m = {{Cl|_MEMIMAGE}}(0) 'copy the screen memory to m
x1$ = {{Cl|_MEMGET (function)|_MEMGET}}(m, m.OFFSET, {{Cl|STRING}} * 5) 'get at block start position
{{Cl|LOCATE}} 2, 1:{{Cl|PRINT}} {{Cl|LEN}}(x1$) 'prints 5 bytes as size is STRING * 5
{{Cl|PRINT}} x1$ 'prints HELLO as ASCII character values
{{Cl|PRINT}} m.OFFSET; m.SIZE; m.ELEMENTSIZE
{{Cl|_MEMFREE}} m '' ''
{{CodeEnd}}
{{OutputStart}}
5
HELLO
5448320 6400 1
{{OutputEnd}}
: ''Explanation:'' When a numerical [[_BYTE]] value is converted to a [[STRING]], each byte is converted to an [[ASCII]] character. The QB64 IDE will capitalize _MEM dot values.
{{WhiteStart}} m.SIZE = 320 * 200 = 6400 bytes
m.ELEMENTSIZE = 1 byte
{{WhiteEnd}}
''Example 3:'' Using _MEM to convert _OFFSET to _INTEGER64.
{{CodeStart}} '' ''
DIM x AS INTEGER
DIM m AS _MEM
m = _MEM(x)
PRINT m.OFFSET
PRINT ConvertOffset(m.OFFSET)
FUNCTION ConvertOffset&& (value AS _OFFSET)
$CHECKING:OFF
DIM m AS _MEM 'Define a memblock
m = _MEM(value) 'Point it to use value
$IF 64BIT THEN
'On 64 bit OSes, an OFFSET is 8 bytes in size. We can put it directly into an Integer64
_MEMGET m, m.OFFSET, ConvertOffset&& 'Get the contents of the memblock and put the values there directly into ConvertOffset&&
$ELSE
'However, on 32 bit OSes, an OFFSET is only 4 bytes. We need to put it into a LONG variable first
_MEMGET m, m.OFFSET, temp& 'Like this
ConvertOffset&& = temp& 'And then assign that long value to ConvertOffset&&
$END IF
_MEMFREE m 'Free the memblock
$CHECKING:ON
END FUNCTION
{{CodeEnd}}
''Explanation:'' The above will print two numbers which should match. These numbers will vary, as they're representations of where X is stored in memory, and that position is going to vary every time the program is run. What it should illustrate, however, is a way to convert _OFFSET to _INTEGER64 values, which can sometimes be useful when trying to run calculations involving mem.SIZE, mem.TYPE, or mem.ELEMENTSIZE.
{{PageSeeAlso}}
* [[_MEM (function)]]
* [[_MEMELEMENT]], [[_MEMCOPY]]
* [[_MEMIMAGE]], [[_MEMNEW]]
* [[_MEMSOUND]]
* [[_MEMGET]], [[_MEMPUT]]
* [[_MEMFILL]], [[_MEMFREE]]
{{PageNavigation}}

52
internal/help/MEMGET.txt Normal file
View file

@ -0,0 +1,52 @@
{{DISPLAYTITLE:_MEMGET}}
The [[_MEMGET]] statement reads a portion of a memory block at an OFFSET position into a variable, array or user defined type.
{{PageSyntax}}
: [[_MEMGET]] {{Parameter|memoryBlock}}, {{Parameter|bytePosition}}, {{Parameter|destinationVariable}}
* {{Parameter|memoryBlock}} is a [[_MEM]] variable type memory block name created by [[_MEMNEW]] or the [[_MEM (function)|_MEM]] function.
* {{Parameter|bytePosition}} is the {{Parameter|memoryBlock}}.[[OFFSET]] memory start position plus any bytes to move into the block.
* {{Parameter|destinationVariable}} is the variable assigned to hold the data. The number of bytes read is determined by the variable [[Variable Types|type]] used.
{{PageDescription}}
* The [[_MEMGET]] statement is similar to the [[GET]] statement used in files, but the position is required.
* The memory block name.[[OFFSET]] returns the starting byte position of the block. Add bytes to move into the block.
* The variable type held in the memory block can determine the next {{Parameter|bytePosition}} to read.
* [[LEN]] can be used to determine the byte size of numerical or user defined variable [[Variable Types|type]]s regardless of the value held.
* [[STRING]] values should be of a defined length. Variable length strings can actually move around in memory and not be found.
{{PageExamples}}
''Example:'' Shows how to read the PSET color values from a program's [[SCREEN]] memory to an array.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 13
{{Cl|PSET}} (0, 0), 123
{{Cl|PSET}} (1, 0), 222 'create screen image
'here is an array
{{Cl|DIM}} screen_array(319, 199) {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} 'use screen dimensions from 0
'here's how we can copy the screen to our array
{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}}
m = {{Cl|_MEMIMAGE}} '0 or no handle necessary when accessing the current program screen
{{Cl|_MEMGET}} m, m.OFFSET, screen_array()
'here's the proof
{{Cl|PRINT}} screen_array(0, 0) 'print 123
{{Cl|PRINT}} screen_array(1, 0) 'print 222
{{Cl|END}} '' ''
{{CodeEnd}}
{{PageSeeAlso}}
* [[_MEMGET (function)]]
* [[_MEMPUT]]
* [[_MEM]]
* [[_MEMIMAGE]]
* [[_MEMFREE]]
{{PageNavigation}}

View file

@ -29,6 +29,8 @@
:[[$CONSOLE]][:ONLY] 'creates a QB64 console window throughout the program
:[[$DEBUG]] 'enables debugging features
:[[$ERROR]] message 'triggers a compilation error, useful inside $IF blocks
:[[$EXEICON]]:'iconfile.ico' 'embeds an .ICO file into the final executable (Windows only)
@ -56,6 +58,7 @@
* [[$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.
* [[$COLOR]] includes named color constants in a program.
* [[$CONSOLE]] creates a console window which can be turned off later with [[_CONSOLE]] OFF.
* [[$DEBUG]] enables debugging features allowing you to step through your code running line by line and to inspect variables and change their values in real time.
* [[$EXEICON]] embeds a designated icon file into the compiled EXE file. (Windows ONLY)
* [[$ERROR]] MESSAGE causes a compilation error whenever QB64 attempts to compile it, displaying MESSAGE to the user. This is useful if inside a $IF block, as the error can be conditional.
* [[$IF]]...[[$END IF]] allows selective inclusion of code in the final program.

View file

@ -0,0 +1,43 @@
{{DISPLAYTITLE:_OFFSET (function)}}
The [[_OFFSET]] function returns the memory offset of/within a given variable.
{{PageSyntax}}
: {{Parameter|offset%&}} = [[_OFFSET]]({{Parameter|variable}})
{{PageDescription}}
* The {{Parameter|variable}} parameter can be any type of numerical or [[STRING|string]] variable name.
* API [[DECLARE LIBRARY|LIBRARY]] parameter or [[TYPE|type]] names may include '''lp, ptr''' or '''p''' which designates them as a pointer type.
* _OFFSET function return values should be stored in [[_OFFSET]] type variables. As no other variable type is 'elastic' like [[_OFFSET]], there can be no guarantee that any other variable type can hold the value of an _OFFSET.
* Returns the memory offset of variables, user-defined-types & elements, arrays & indices and the base offset of [[STRING]]s.
* Offset values are currently only useful when used in conjunction with [[_MEM]] or [[DECLARE LIBRARY]] procedures.
* OFFSET values are used as a part of the [[_MEM]] variable [[Variable Types|type]] in QB64; {{Parameter|variable}}.OFFSET returns or sets the current position in memory.
* '''Warning:''' QB64 variable length strings can move about in memory at any time. If you get the _OFFSET of a variable length sting on one line and use it on the next it may not be there anymore.''' To be safe, move variable length strings into fixed length strings first.'''
{{PageExamples}}
''Example:'' Using memcpy with the _OFFSET function values as parameters.
{{CodeStart}} '' ''
{{Cl|DECLARE DYNAMIC LIBRARY|DECLARE CUSTOMTYPE LIBRARY}}
{{Cl|SUB}} memcpy ({{Cl|BYVAL}} dest {{Cl|AS}} {{Cl|_OFFSET}}, {{Cl|BYVAL}} source {{Cl|AS}} {{Cl|_OFFSET}}, {{Cl|BYVAL}} bytes {{Cl|AS}} {{Cl|LONG}})
{{Cl|DECLARE LIBRARY|END DECLARE}}
a$ = "1234567890"
b$ = "ABCDEFGHIJ"
memcpy {{Cl|_OFFSET (function)|_OFFSET}}(a$) + 5, {{Cl|_OFFSET (function)|_OFFSET}}(b$) + 5, 5
{{Cl|PRINT}} a$ '' ''
{{CodeEnd}}
{{OutputStart}}12345FGHIJ
{{OutputEnd}}
{{PageSeeAlso}}
* [[_OFFSET]] {{text|(variable type)}}
* [[DECLARE LIBRARY]]
* [[DECLARE DYNAMIC LIBRARY]]
* [[Using _OFFSET]]
{{PageNavigation}}

View file

@ -12,8 +12,7 @@
{{PageErrors}}
* If used, [[OPTION _EXPLICIT]] must be the very first statement in your program. No other statements can precede it (except for [[$NOPREFIX]] or comment lines started with an [[Apostrophe|apostrophe]] or [[REM]]).
* Do not use [[OPTION _EXPLICIT]] in [[$INCLUDE]]d modules.
* It's not advisable to use [[OPTION _EXPLICIT]] in [[$INCLUDE]]d modules.
{{PageExamples}}

View file

@ -10,8 +10,7 @@
* Unlike [[OPTION _EXPLICIT]], simple variables can still be used without a declaration. Example: {{InlineCode}}i = 1{{InlineCodeEnd}}
{{PageErrors}}
* If used, [[OPTION _EXPLICITARRAY]] must be the very first statement in your program. No other statements can precede it (except for [[$NOPREFIX]] or comment lines started with an [[Apostrophe|apostrophe]] or [[REM]]).
* Do not use [[OPTION _EXPLICITARRAY]] in [[$INCLUDE]]d modules.
* It's not advisable to use [[OPTION _EXPLICITARRAY]] in [[$INCLUDE]]d modules.
{{PageExamples}}

View file

@ -19,7 +19,7 @@ The '''WHILE''' condition is used in [[WHILE...WEND]] or [[DO...LOOP]] loops to
{{Template:RelationalTable}}
''See also:''
{{PageSeeAlso}}
*[[UNTIL]]
*[[DO...LOOP]]
*[[WHILE...WEND]]

View file

@ -7,7 +7,7 @@ The [[_CV]] function is used to convert [[_MK$]], [[ASCII]], [[STRING]] values t
{{PageParameters}}
* {{Parameter|numericalType}} is any number type: [[INTEGER]], [[LONG]], [[SINGLE]], [[DOUBLE]], [[_INTEGER64]], [[_FLOAT]], [[_BYTE]] or [[_BIT]].
* {{Parameter|numericalType}} is any number type: [[INTEGER]], [[LONG]], [[SINGLE]], [[DOUBLE]], [[_INTEGER64]], [[_FLOAT]], [[_BYTE]] or [[_OFFSET]].
* Integer, Long, Byte and Bit values can be signed or [[_UNSIGNED]].
* The {{Parameter|MKstringvalue$}} parameter must be a string value generated by [[_MK$]]

View file

@ -7,7 +7,7 @@ The [[_DIR$]] function returns common paths in '''Windows''' only such as My Doc
{{PageParameters}}
* ''folderspecification'' may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data".
* ''folderspecification'' may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data", "program files", "program files (x86)", "temp".
* Some variation is accepted for the folder specification:
:: MY DOCUMENTS, TEXT, DOCUMENT, DOCUMENTS, DOWNLOAD, DOWNLOADS
:: MY MUSIC, MUSIC, AUDIO, SOUND, SOUNDS

View file

@ -0,0 +1,21 @@
{{DISPLAYTITLE:_ENVIRONCOUNT}}
The [[_ENVIRONCOUNT]] function returns the number of items (key/value pairs) currently stored in the system environment variables table.
{{PageSyntax}}
: {{Parameter|totalKeys&}} = [[_ENVIRONCOUNT]]
{{PageDescription}}
* Any changes made at runtime to the environment table are discarded when your program ends
{{PageAvailability}}
* Version 2.0 and up.
{{PageSeeAlso}}
* [[ENVIRON$]], [[ENVIRON]]
{{PageNavigation}}

View file

@ -7,7 +7,7 @@ The [[_MK$]] function can convert any numerical type into an [[ASCII]] [[STRING]
{{PageParameters}}
* {{Parameter|numericalType}} is any QB64 numerical type: [[INTEGER]], [[LONG]], [[SINGLE]], [[DOUBLE]], [[_INTEGER64]], [[_BYTE]] or [[_BIT]].
* {{Parameter|numericalType}} is any QB64 numerical type: [[INTEGER]], [[LONG]], [[SINGLE]], [[DOUBLE]], [[_INTEGER64]], [[_BYTE]] and [[_OFFSET]].
* Whole integer values can be signed or [[_UNSIGNED]].
* {{Parameter|numericalValue}} must match the {{Parameter|numericalType}} used.

View file

@ -1,13 +1,17 @@
{{DISPLAYTITLE:_STARTDIR$}}
The [[_STARTDIR$]] function returns the path a user called a QB64 program from.
The [[_STARTDIR$]] function returns the user's working directory when the program was started.
{{PageSyntax}}
: {{Parameter|callPath$}} = [[_STARTDIR$]]
{{PageDescription}}
* Returns a [[STRING]] representing the user's program calling path.
The user's working directory depends on how the program was launched. Note that these are ultimately controlled by the launching environment, so might differ in non-standard setups.
* If the program was run from a graphical file manager, _STARTDIR$ will be the path to the directory of the binary file.
* If launched from the command line, _STARTDIR$ is the shell's current working directory, as manipulated by the 'cd' command.
* If launched via a shortcut on Windows _STARTDIR$ will be the "Start in" property, which defaults to the location of the shortcut's target file.
The value of [[_STARTDIR$]] may differ from [[_CWD$]] even at program start, because QB64 program change their current directory to the binary's location. _STARTDIR$ is the directory inherited from the user's environment, while [[_CWD$]] will start off as the location of the program binary file. Because files are opened relative to [[_CWD$]], this can be useful for programs that expect to open e.g. graphical or sound assets, but problematic for programs that want to interpret paths supplied by the user as relative to the user's current directory. In the latter case, add a 'CHDIR _STARTDIR$' to the top of the program. This will change back to the working directory inherited from the environment.
{{PageAvailability}}
* Version 1.000 and up.

View file

@ -63,6 +63,7 @@ _D2G,_D2G
_D2R,_D2R
DECLARE,DECLARE LIBRARY
DECLARE,DECLARE DYNAMIC LIBRARY
$DEBUG,$DEBUG
_DEFAULTCOLOR,_DEFAULTCOLOR
_DEFINE,_DEFINE
_DEFLATE$,_DEFLATE$
@ -87,6 +88,7 @@ _ECHO,_ECHO
$ELSE,$ELSE
$ELSEIF,$ELSEIF
$END,$END IF
_ENVIRONCOUNT,_ENVIRONCOUNT
$ERROR,$ERROR
_ERRORLINE,_ERRORLINE
_ERRORMESSAGE$,_ERRORMESSAGE$
@ -119,8 +121,8 @@ _INFLATE$,_INFLATE$
_INSTRREV,_INSTRREV
_INTEGER64,_INTEGER64
_KEYCLEAR,_KEYCLEAR
_KEYHIT,_KEYHIT
_KEYDOWN,_KEYDOWN
_KEYHIT,_KEYHIT
$LET,$LET
_LASTAXIS,_LASTAXIS
_LASTBUTTON,_LASTBUTTON