mirror of
https://github.com/QB64Official/qb64.git
synced 2024-09-16 05:03:52 +00:00
b586eafd3b
LINE INPUT will now use the faster method if passed a file handle that has been opened FOR BINARY. As such, the _BLINEINPUT command has been removed. qb64.bas now takes advantage of this for reading from '$include files, at least in Include Manager 1. Some tweaking of internal/source/main.txt was required to get things into a sane state, so I'm holing off changing the compiler any further so the auto-builder can make sure everything's smoothed over. Note: Everything should still compile as normal; I'm just being overcautious.
67 lines
No EOL
2.5 KiB
Text
67 lines
No EOL
2.5 KiB
Text
'''DEF SEG''' is used to define the area in memory to access QB64's emulated conventional memory.
|
|
|
|
|
|
{{PageSyntax}}
|
|
:: DEF SEG [=][{segment|VARSEG(variable}]
|
|
|
|
|
|
* 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 to reset the segment to Qbasic's default value!
|
|
* '''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.'''
|
|
|
|
|
|
''Example:'' In a Qbasic(ONLY) file delete, '''SEG''' forces the parameter to be passed as a far pointer.
|
|
{{CodeStart}} '' ''
|
|
{{Cl|CONST}} file = "trashme.tmp" 'example temporary file name to delete
|
|
{{Cl|DEFINT}} A-Z
|
|
{{Cl|DIM}} filename {{Cl|AS}} {{Cl|STRING}}
|
|
{{Cl|DIM}} result {{Cl|AS}} {{Cl|LONG}}
|
|
{{Cl|DIM}} t {{Cl|AS}} {{Cl|STRING}}
|
|
{{Cl|DIM}} i {{Cl|AS}} {{Cl|INTEGER}}
|
|
{{Cl|CONST}} codelen = 48
|
|
{{Cl|DIM}} code {{Cl|AS}} {{Cl|STRING}} * codelen
|
|
|
|
{{Cl|CLS}}
|
|
|
|
t = "5589E51E8B560C8EDA8B5E0A8B5702B441CD218B56088EDA8B5E06720B6631C0"
|
|
t = t + "6689071F5DCA0800660D0000FFFFEBF0"
|
|
|
|
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} codelen - 1
|
|
{{Cl|MID$}}(code, i + 1, 1) = {{Cl|CHR$}}({{Cl|VAL}}("&h" + {{Cl|MID$}}(t, i + i + 1, 2)))
|
|
{{Cl|NEXT}}
|
|
|
|
{{Cl|OPEN}} file {{Cl|FOR...NEXT|FOR}} {{Cl|APPEND}} {{Cl|AS}} 1 'create temporary file
|
|
{{Cl|PRINT (file statement)|PRINT}} #1, "I am doomed! :-("
|
|
{{Cl|CLOSE}}
|
|
|
|
{{Cl|PRINT}} "now you see it:"
|
|
{{Cl|SHELL}} "dir " + file
|
|
K$ = {{Cl|INPUT$}}(1)
|
|
|
|
filename = file + {{Cl|CHR$}}(0) 'create zero string name for DOS
|
|
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(code)
|
|
{{Cl|CALL}} absolute('''SEG''' filename, '''SEG''' result, {{Cl|VARPTR}}(code))
|
|
|
|
{{Cl|IF...THEN|IF}} result {{Cl|THEN}} 'check results
|
|
{{Cl|PRINT}} "oops. error: 0x"; {{Cl|HEX$}}(result {{Cl|AND (boolean)|AND}} {{Cl|&H}}FFFF&)
|
|
{{Cl|ELSE}}
|
|
{{Cl|PRINT}} "now you don't:"
|
|
{{Cl|END IF}}
|
|
{{Cl|SHELL}} "dir " + file
|
|
{{Cl|END}} '' ''
|
|
{{CodeEnd}}
|
|
{{small|Code by Michael Calkins as Public Domain(2011)}}
|
|
|
|
|
|
''See also:''
|
|
* [[DEF SEG = 0]]
|
|
* [[VARPTR]], [[VARSEG]]
|
|
* [[PEEK]], [[POKE]]
|
|
* [[BSAVE]], [[BLOAD]]
|
|
|
|
|
|
{{PageNavigation}} |