×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

returning the current segment

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

RE: returning the current segment

I don't think there is a way to retrieve that value with QB (Toshi will probably prove me wrong and I hope he does.)

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.


RE: returning the current segment

(OP)
well, it's actually not for me, but someone who was asking me for help. He's apparently putting together a set of routines that he wants the programmer to be able to use without having to worry about the fact that many of his routines work in other segments. So he wanted to make a routine that stores the current segment when one of his routines is called and then resets it when the routine is done.

Mag

RE: returning the current segment

Hi,

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

(OP)
nope

RE: returning the current segment

"There are two internal variables BASIC maintains that you will find useful.
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

"The same holds true for a routine that changes the
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

You may also want to check out this thread:

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

ok thx. that really helps out.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close