1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 09:20:38 +00:00

Update help files.

This commit is contained in:
Fellippe Heitor 2021-01-26 21:58:17 -03:00
parent 9e92d13f70
commit fe4c4996c9
4 changed files with 61 additions and 27 deletions

View file

@ -2,11 +2,15 @@ The [[DIM]] statement is used to declare a variable or a list of variables as a
{{PageSyntax}}
::''Syntax 1:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} ''type''}] [, ''variable2''...]]
::''To declare variables:''
:::[[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]]
::''Syntax 2:'' [[DIM]] [{{KW|SHARED}}] ''array(lowest% [{{KW|TO}}) highest%])''[{suffix| {{KW|AS}} ''type''}] [, ''variable2''...]
::''To declare arrays:''
:::[[DIM]] [{{KW|SHARED}}] ''array([lowest% {{KW|TO}}] highest%])''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]
:'' '''QB64''' Syntax:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]
::'' '''QB64''' Alternative Syntax:''
:::[[DIM]] [{{KW|SHARED}}] {{KW|AS}} [{{KW|_UNSIGNED}}] ''type'' ''variable'' [, ''variable2''...]
:::[[DIM]] [{{KW|SHARED}}] {{KW|AS}} [{{KW|_UNSIGNED}}] ''type'' ''array([lowest% {{KW|TO}}] highest%])'' [, ''array2(elements)''...]
{{PageDescription}}
@ -26,7 +30,8 @@ The [[DIM]] statement is used to declare a variable or a list of variables as a
** [[_FLOAT]] (or use variable suffix '''##''')
** [[_OFFSET]] (or use variable suffix '''%&''')
** DIM AS [[_MEM]] (the _MEM type has no type suffix).
* '''Note: When a variable has not been defined or has no type suffix, the value defaults to [[SINGLE]].'''
* '''Note: When a variable has not been defined or has no type suffix, the type defaults to [[SINGLE]].'''
* When using the '''AS type variable-list''' syntax, type symbols cannot be used.
* When the [[$DYNAMIC]] metacommand or [[REDIM]] is used, array element sizes are changeable (not [[$STATIC]]).
* Use [[REDIM]] instead of DIM to dimension arrays as dynamic without the {{KW|$DYNAMIC}} metacommand.
* Use [[REDIM]] [[_PRESERVE]] in '''QB64''' to retain previous array values when changing the size of an array.
@ -84,6 +89,13 @@ x = 1 'x is a {{Cl|SINGLE}} variable
: ''Explanation:'' QB64 gives an error because the creation of the new variable would make referring to the existing one impossible.
''Example 8:'' Using QB64's alternative syntax to declare multiple variables/arrays of the same type.
{{CodeStart}} '' ''
{{Cl|DIM}} {{Cl|AS}} {{Cl|LONG}} w, h, id, weight, index 'all of these variables are created as type LONG
{{Cl|DIM}} {{Cl|AS}} {{Cl|SINGLE}} x, y, z ' all of these variables are created as type SINGLE
{{CodeEnd}} '' ''
{{PageSeeAlso}}
* [[_DEFINE]], [[_PRESERVE]]
* [[REDIM]], [[TYPE]]

View file

@ -3,23 +3,24 @@ A {{KW|REDIM}} statement can re-dimension one [[$DYNAMIC|dynamic]](flexible) [[A
{{PageSyntax}}
:[[REDIM]] [{{KW|_PRESERVE}}] [{{KW|SHARED}}] ArrayName[''typesuffix''] ({''max_element''|low_element[{{KW|TO}} ''upper_element'', ...]}) [{{KW|AS}} {{KW|TYPE|Type}}]
:[[REDIM]] [{{KW|_PRESERVE}}] [{{KW|SHARED}}] [{{KW|AS}} {{KW|TYPE|Type}}] ArrayName({''max_element''|low_element[{{KW|TO}} ''upper_element'', ...]})
{{PageDescription}}
* Can change the number of elements in an array (the present array data is lost unless [[_PRESERVE]] is used).
* Dynamic array elements can also be sized or resized by a program user's entry.
* The [[_PRESERVE]] option also allows the ''element'' range values to be moved upward or downward in '''QB64 only!'''
* The [[_PRESERVE]] option also allows the ''element'' range values to be moved upward or downward.
* {{Parameter|Array}} is the name of the array to be dimensioned or re-dimensioned.
* {{Parameter|elements}} is the number of elements the array should hold. Use the optional [[TO]] {{Parameter|elements2}} to set a range.
* '''Always use the same array [[TYPE]] suffix ([[AS]] type) or a new array type with the same name may be created.'''
* REDIM cannot change [[$STATIC]] arrays created with a [[DIM]] statement unless the [[$DYNAMIC]] [[Metacommand]] is used!
* REDIM cannot change [[$STATIC]] arrays created with a [[DIM]] statement unless the [[$DYNAMIC]] [[Metacommand]] is used.
* To create a dynamic array use the [[$DYNAMIC]] metacommand or use [[REDIM]] rather than [[DIM]] when first creating the array.
* Use REDIM [[_PRESERVE]] to change the range or number of array elements without losing the remaining elements. Data may move up or down to accommodate those boundary changes.
* '''REDIM [[_PRESERVE]] cannot change the number of array dimensions or type!'''
* '''REDIM [[_PRESERVE]] cannot change the number of array dimensions or type.'''
* [[$DYNAMIC|Dynamic]] arrays MUST be [[REDIM]]ensioned if [[ERASE]] or [[CLEAR]] are used to clear the arrays as they no longer exist.
* When [[AS]] is used to declare the type, use [[AS]] to retain that type or it will change to [[SINGLE]]!
* '''NOTE: Many Qbasic keyword variable names CAN be used with a [[STRING]] suffix($) ONLY! You CANNOT use them without the suffix, use a numerical suffix or use [[DIM]], [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements!'''
* '''Warning! Do not use negative array upper bound index values as OS access or "Out of Memory" [[ERROR Codes|errors]] will occur!'''
* '''Warning! Do not use negative array upper bound index values as OS access or "Out of Memory" [[ERROR Codes|errors]] will occur.'''
* When using the '''AS type variable-list''' syntax, type symbols cannot be used.
''Example 1:'' The [[$DYNAMIC]] Metacommand allows an array to be re-sized using [[DIM]] and REDIM.

View file

@ -4,12 +4,14 @@ The '''SHARED''' statement allows variables to be passed automatically to any [[
{{PageSyntax}}
:: DIM SHARED Qt AS STRING * 1
:: DIM SHARED AS STRING * 1 Qt
* [[DIM]]ensioned variables are shared with all procedures in the program module.
* When used with [[DIM]] in the main module, it eliminates the need to pass a parameter variable to a [[SUB]] or [[FUNCTION]].
* Use [[COMMON SHARED]] to share a list of variable values with sub-procedures or other modules. See also: [[COMMON]]
* SHARED ('''without [[DIM]]''') can share a list of variables inside of [[SUB]] or [[FUNCTION]] procedures with the main module only.
* When using the '''AS type variable-list''' syntax, type symbols cannot be used.
:'''Note: SHARED variables in sub-procedures will not be passed to other sub-procedures, only the main module.'''

View file

@ -1,31 +1,40 @@
'''TYPE''' definitions are used to create variables that can hold more than one variable type of a fixed byte length.
'''TYPE''' definitions are used to create variables that can hold more than one element.
{{PageSyntax}}
::'''TYPE''' typename
::: element-name1 AS type
::: element-name2 AS type
::: .
::: .
::: .
::: element-nameN AS type
::'''END TYPE'''
::.
::. variable(s) AS type
::.
::'''TYPE''' typename
::: AS type element-list1
::: AS type element-list2
::: .
::: .
::: .
::: AS type element-listN
::'''END TYPE'''
* Typename is an undefined type name holder as it can hold any variable types.
* TYPE definitions should be placed in the main module before the start of the program code execution.
* TYPE definitions CAN be placed in [[SUB]] or [[FUNCTION]] procedures using QB64 only!
* TYPE definitions cannot contain Array variables! Arrays can be [[DIM]]ensioned as a TYPE definition.
* TYPE definitions cannot be inside of another TYPE definition, but variables can be defined AS another type.(See Example 3)
* TYPE definitions are usually placed in the main module before the start of the program code execution.
* TYPE definitions cam also be placed in [[SUB]] or [[FUNCTION]] procedures.
* TYPE definitions cannot contain Array variables. Arrays can be [[DIM]]ensioned as a TYPE definition.
* TYPE definitions cannot be inside of another TYPE definition, but variables can be defined AS another type.(See Example 4)
* TYPE definitions must be ended with [[END TYPE]].
* A TYPE variable MUST be assigned to the type after it is defined. Array variables are allowed.
* A TYPE variable must be assigned to the type after it is defined. Array variables are allowed.
* Type variables must be defined in every SUB or FUNCTION unless the type variable is [[DIM]]ensioned as [[SHARED]].
* Type variables use DOT variable names to read or write specific values. They do not use type suffixes as they can hold ANY variable type values! The name before the dot is the one you defined after the type definition and the name after is the variable name used inside of the TYPE. The name of the dimensioned type variable alone can be used to [[PUT]] # or [[GET]] # all of the data at once!
* Once the TYPE variable is created you can find the record or byte size by using [[LEN]](typevariable).
* TYPE definitions can also be placed in [[$INCLUDE]] .BI text files such as [[QB.BI]] is used by [[INTERRUPT]] and [[INTERRUPTX]].
* '''[[_BIT]] is not currently supported in User Defined [[TYPE]]s'''.
* '''NOTE: Many Qbasic keyword variable names CAN be used with a [[STRING]] suffix($) ONLY! You CANNOT use them without the suffix, use a numerical suffix or use [[DIM]], [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements!'''
* You can mix the '''element-name AS type''' syntax with the '''AS type element-list''' syntax in the same TYPE block.
* '''[[_BIT]] is not supported in User Defined [[TYPE]]s'''.
{{DataTypeTable}}
@ -58,11 +67,20 @@
::::Each TYPE variable is designated as the DOT variable's suffix.
'''* Note: Omitting variables in the RegType definition can change other program variable values!'''
'''* Note: Omitting variables in the RegType definition can change other program variable values.'''
''Example 2:'' Simplifying the TYPE from Example 1 using the alternative TYPE syntax.
{{CodeStart}}
TYPE RegType
AS INTEGER AX, BX, CX, DX, BP, SI, DI, Flags, FS, ES
END TYPE
{{CodeEnd}}
:''Explanation:'' By using '''AS type element-list''' you reduce typing in your TYPE definition, while achieving the same results.
''Example 2:'' Creating an addressbook database for a [[RANDOM]] file.
''Example 4:'' Creating an addressbook database for a [[RANDOM]] file.
{{CodeStart}}
TYPE ContactInfo
First AS STRING * 10
@ -85,10 +103,10 @@
{{CodeEnd}}
:''Explanation:'' Use the assigned type variable to find the RANDOM record length which is 118 bytes.
::::The DOT variable names consist of Contact as the prefix:
''Example 3:'' Defining a TYPE variable as another variable type from a previous TYPE definition in QB64.
''Example 4:'' Defining a TYPE variable as another variable type from a previous TYPE definition in QB64.
{{CodeStart}}
{{Cl|TYPE}} bar
b {{Cl|AS}} {{Cl|STRING}} * 10
@ -108,7 +126,7 @@ PRINT foobar.a, foobar.c.b
{{CodeEnd}}
''Example 4:'' A bitmap header information TYPE [[$INCLUDE]] File.
''Example 5:'' A bitmap header information TYPE [[$INCLUDE]] File.
{{TextStart}}
' ********
'Bitmap.BI can be included at start of program
@ -153,6 +171,7 @@ PRINT foobar.a, foobar.c.b
''See also:''
* [[DIM]], [[REDIM]]
* [[INTEGER]], [[SINGLE]], [[DOUBLE]]
* [[LONG]], [[_INTEGER64]], [[_FLOAT]]
* [[STRING]], [[_BYTE]], [[_BIT]], [[_OFFSET]]