DEF SEG: 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
No edit summary |
No edit summary |
||
Line 21: | Line 21: | ||
{{PageExamples}} | {{PageExamples}} | ||
''Example:'' In a Qbasic(ONLY) file delete, '''SEG''' forces the parameter to be passed as a far pointer. | ''Example:'' In a Qbasic(ONLY) file delete, '''SEG''' forces the parameter to be passed as a far pointer. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|CONST}} file = "trashme.tmp" 'example temporary file name to delete | {{Cl|CONST}} file = "trashme.tmp" 'example temporary file name to delete | ||
{{Cl|DEFINT}} A-Z | {{Cl|DEFINT}} A-Z | ||
Line 58: | Line 58: | ||
{{Cl|END IF}} | {{Cl|END IF}} | ||
{{Cl|SHELL}} "dir " + file | {{Cl|SHELL}} "dir " + file | ||
{{Cl|END}} | {{Cl|END}} | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{small|Code by Michael Calkins as Public Domain(2011)}} | {{small|Code by Michael Calkins as Public Domain(2011)}} | ||
--> | --> | ||
''See also:'' | ''See also:'' | ||
* [[DEF SEG = 0]] | * [[DEF SEG = 0]] | ||
* [[VARPTR]], [[VARSEG]] | * [[VARPTR]], [[VARSEG]] | ||
* [[PEEK]], [[POKE]] | * [[PEEK]], [[POKE]] | ||
* [[BSAVE]], [[BLOAD]] | * [[BSAVE]], [[BLOAD]] |
Revision as of 01:27, 23 January 2023
DEF SEG is used to define the area in memory to access QB64's emulated conventional memory.
Syntax
- DEF SEG [=][{segment|VARSEG(variable}]
Legacy support
- QB64 implements memory access using _MEM and related functions. For that reason, DEF SEG isn't recommended practice anymore and is supported to maintain compatibility with legacy code.
Description
- Used to set the pointer to a memory area of a variable/array or register.
- PEEK and POKE require a segment memory address (often just 0) without using VARSEG.
- Important segments using PEEK and POKE include &HB800 (text segment) and &HA000 (graphics segment).
- BSAVE and BLOAD require a VARSEG reference to the grahic array(0 index) used.
- Always use DEF SEG when the procedure is completed, in order to reset the segment to QBasic's default value.
- DEF SEG, VARSEG, VARPTR, PEEK and POKE access QB64's emulated 16 bit conventional memory block. It is highly recommended to use QB64's _MEM memory system to avoid running out of memory.
See also: