returning the current segment
returning the current segment
(OP)
I think I might have covered the entire breadth of my question in the subject line :)
obviously the current segment has to be stored in memory somewhere, but where? and once the location is known, how could you read it without changing the current segment to the segment in which the value resides?
Am I making a snip of sense here? :)
Mag
obviously the current segment has to be stored in memory somewhere, but where? and once the location is known, how could you read it without changing the current segment to the segment in which the value resides?
Am I making a snip of sense here? :)
Mag
RE: returning the current segment
In my mind, the best way to get the current segment is to store the value in a variable before you do a DEF SEG and then get it from the variable. Aside from that, as long as you haven't set a segment, you can assume the current segment is the default segment for QB.
That probably didn't help much. Under what conditions would your app forget the segment it has set with DEF SEG? Maybe we can work this out.
Alt255@Vorpalcom.Intranets.com
RE: returning the current segment
Mag
RE: returning the current segment
The QB45 help states that if you omit the address whe using DEF SEG the BASIC segment is used.
Does this help?
Pappy
RE: returning the current segment
RE: returning the current segment
One is the current DEF SEG setting, and it is stored in the integer
variable named B$SEG." (Ethan Winer, BASIC Techniques and Utilities, pp.448)
This will only work when compiled on the command line, as far as I know.
RE: returning the current segment
current DEF SEG setting, perhaps before loading or saving a file using
BLOAD or BSAVE. If you cannot return that to its original value, extra
work is needed in the main program each time the routine is used.
Access to B$SEG requires a single assembler instruction, as shown in the
complete GetSeg function shown following. Declare and use GetSeg like
this:
DECLARE FUNCTION GetSeg%()
SavedSeg = GetSeg%
.
.
DEF SEG = SavedSeg
.Model Medium, Basic
.Data
Extrn B$Seg:Word
.Code
GetSeg Proc
Mov AX,B$Seg ;load the value from B$Seg
Ret ;return with the function output in AX
GetSeg Endp
End
..." (Ethan Winer pp.448-449)
RE: returning the current segment
Thread314-34793 a few pages back dealing with VarSegs, SADDs, etc. It may prove useful to you in your quest.
--MiggyD
"It's mind over matter. They don't mind so you don't matter to them."
RE: returning the current segment