Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Tom Rettigs Library - off(<c memvar name>) http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 OFF(<C memvar name>)
 Evaluates the offset portion of a variable's memory address.
 Returns <expC> variable's offset address as hexadecimal string.

 Our OFF() function is used in Summer '87 only.  SEG() and OFF() do
 not work in Clipper 5.0 because of Clipper's virtual memory manager.
 Memory storage that you can refer to by a segment and offset address
 is usually used only in conjunction with the DOSFUNC or ROMBIOS
 procedures where a pointer address must be specified.  Instead of
 initializing a variable and getting its address with SEG() and
 OFF(), use the ALLOCATE() function to provide the memory space
 needed, initialize it with the POKE...() functions, and read it with
 the PEEK...() functions.

 Old example (Summer '87 only):

    m_greeting = "Hello, how are you?$"  && output string
    m_ds       = SEG("m_greeting")       && output string segment address
    m_dx       = OFF("m_greeting")       && output string offset address
    m_ax       = "0900"                  && DOS INT 21 output function
    * Set up other registers (see DOSFUNC for example).
    CALL DOSFUNC WITH m_regs, m_flags    && DOS INT 21 function call

 New example (Both 5.0 and Summer '87):

    m_greeting = "Hello, how are you?$"  && output string
    m_address  = ALLOCATE(LEN(m_greeting)+1)  && new storage with address
    m_ds       = LEFT(m_address,4)       && new storage SEGment address
    m_dx       = RIGHT(m_address,4)      && new storage OFFset address
    POKESTR(m_ds, m_dx, m_greeting)      && place greeting in new storage
    m_ax       = "0900"                  && DOS INT 21 output function
    * Set up other registers (see DOSFUNC for example).
    CALL DOSFUNC WITH m_regs, m_flags    && DOS INT 21 function call

 To initialize a variable from a value stored in an ALLOCATEd area:

    * Read new storage value.
    new_var = PEEKSTR(m_ds, m_dx, m_greeting)

 OFF() calls the _OFFSET procedure, which can be called directly.
 OFF() function provides the value-returning convenience of a
 function call.

 m_greeting = "Hi, how are you?$"   && $ for DOS function 9

 * Set up call to DOSFUNC with registers DS:DX pointing
 * to m_greeting.

 * Will call DOS function 9 (print string).
 m_ax = "0900"
 m_ds = SEG( "m_greeting" )
 m_dx = OFF( "m_greeting" )

 <Set up other registers, m_regs, and m_flags.>
 <See example under DOSFUNC procedure.>

 CALL DOSFUNC WITH m_regs, m_flags

 Hazard
    If <memvar name> is not passed as a string, this function
    does not return the address of the actual variable, only of
    a temporary location in memory.


             Placed in the Public Domain by Tom Rettig Assoc.

See Also: DOSFUNC SEG() _OFFSET _SEGMENT

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson