VARSEG: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
(Created page with "The '''VARSEG''' function returns an INTEGER value that is the segment part of a variable or array memory address. {{PageSyntax}} :: DEF SEG = VARSEG(variable_name[(start_index)]) * If variablename is not defined before VARPTR or VARSEG is called, the variable is created and its address is returned. * The start index is the lowest index of an array variable when used. * When a string variable, VARSEG returns the segment location address of the first by...") |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
The '''VARSEG''' function returns an [[INTEGER]] value that is the segment part of a variable or array memory address. | The '''VARSEG''' function returns an [[INTEGER]] value that is the segment part of a variable or array memory address. | ||
Line 8: | Line 7: | ||
* If variablename is not defined before [[VARPTR]] or VARSEG is called, the variable is created and its address is returned. | * If variablename is not defined before [[VARPTR]] or VARSEG is called, the variable is created and its address is returned. | ||
* The start index is the lowest index of an array variable when used. | * The start index is the lowest index of an array variable when used. | ||
* When a string variable, VARSEG returns the segment location address of the first byte of the string. | * When a string variable, VARSEG returns the segment location address of the first byte of the string. | ||
* Because many | * Because many QBasic statements change the locations of variables in memory, use the values returned by VARPTR and VARSEG immediately after the functions are used! | ||
* Integer array sizes are limited to 32767 elements when using [[VARSEG]] in QB and '''QB64'''!. Create a larger array using [[_BYTE]]. Example: [[DIM]] [[SHARED]] Memory (65535) AS [[_UNSIGNED]] [[_BYTE]] | * Integer array sizes are limited to 32767 elements when using [[VARSEG]] in QB and '''QB64'''!. Create a larger array using [[_BYTE]]. Example: [[DIM]] [[SHARED]] Memory (65535) AS [[_UNSIGNED]] [[_BYTE]] | ||
* '''Warning: DEF SEG, VARSEG , VARPTR, PEEK or POKE access QB64's emulated 16 bit conventional memory block!''' | * '''Warning: DEF SEG, VARSEG , VARPTR, PEEK or POKE access QB64's emulated 16 bit conventional memory block!''' | ||
: '''It is highly recommended that QB64's [[_MEM]] memory system be used to avoid running out of memory.''' | : '''It is highly recommended that QB64's [[_MEM]] memory system be used to avoid running out of memory.''' | ||
{{PageSeeAlso}} | |||
* [[BSAVE]], [[BLOAD]] | * [[BSAVE]], [[BLOAD]] | ||
* [[SADD]], [[DEF SEG]] | * [[SADD]], [[DEF SEG]] | ||
* [[VARPTR]], [[VARPTR$]] | * [[VARPTR]], [[VARPTR$]] | ||
* [[POKE]], [[PEEK]] | * [[POKE]], [[PEEK]] | ||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 01:20, 29 January 2023
The VARSEG function returns an INTEGER value that is the segment part of a variable or array memory address.
Syntax
- DEF SEG = VARSEG(variable_name[(start_index)])
- If variablename is not defined before VARPTR or VARSEG is called, the variable is created and its address is returned.
- The start index is the lowest index of an array variable when used.
- When a string variable, VARSEG returns the segment location address of the first byte of the string.
- Because many QBasic statements change the locations of variables in memory, use the values returned by VARPTR and VARSEG immediately after the functions are used!
- Integer array sizes are limited to 32767 elements when using VARSEG in QB and QB64!. Create a larger array using _BYTE. Example: DIM SHARED Memory (65535) AS _UNSIGNED _BYTE
- Warning: DEF SEG, VARSEG , VARPTR, PEEK or POKE access QB64's emulated 16 bit conventional memory block!
- It is highly recommended that QB64's _MEM memory system be used to avoid running out of memory.
See also