VARPTR: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "The '''VARPTR''' function returns an INTEGER value that is the offset part of the variable or array memory address within it's segment. {{PageSyntax}} :: offset% = VARPTR(variable_name[(reference_index%)]) * If variablename is not defined before VARPTR or VARSEG is called, the variable is created and it's address is returned. * Reference index is used to set the offset address of an array index, not necessarily the lowest index. * When a string variable, VAR...")
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The '''VARPTR''' function returns an [[INTEGER]] value that is the offset part of the variable or array memory address within it's segment.  
The '''VARPTR''' function returns an [[INTEGER]] value that is the offset part of the variable or array memory address within it's segment.




Line 9: Line 9:
* Reference index is used to set the offset address of an array index, not necessarily the lowest index.
* Reference index is used to set the offset address of an array index, not necessarily the lowest index.
* When a string variable, VARPTR returns the offset address location of the first byte of the string.
* When a string variable, VARPTR returns the offset address location 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!
* 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 [[VARPTR]] 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 [[VARPTR]] 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.'''




''See also:''
{{PageSeeAlso}}
* [[BSAVE]], [[BLOAD]]
* [[BSAVE]], [[BLOAD]]
* [[SADD]],  [[DEF SEG]]
* [[SADD]],  [[DEF SEG]]
* [[VARPTR$]], [[VARSEG]],
* [[VARPTR$]], [[VARSEG]]
* [[POKE]], [[PEEK]]
* [[POKE]], [[PEEK]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 21:39, 2 February 2023

The VARPTR function returns an INTEGER value that is the offset part of the variable or array memory address within it's segment.


Syntax

offset% = VARPTR(variable_name[(reference_index%)])


  • If variablename is not defined before VARPTR or VARSEG is called, the variable is created and it's address is returned.
  • Reference index is used to set the offset address of an array index, not necessarily the lowest index.
  • When a string variable, VARPTR returns the offset address location 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 VARPTR 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



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link