Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- LanMan Library Reference Guide - <b>ll_offset()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 LL_OFFSET()
 Get the offset of a protected mode memory selector
------------------------------------------------------------------------------

 Syntax

      LL_Offset( <nSelector> ) -> nOffset

 Arguments

     <nSelector> is a protected mode memory selector for which the
     offset part of the memory address is wanted

 Returns

     <nOffset>, which is the offset part of the memory address to which
     the memory selector is pointing

 Description

     LL_Offset() is used to find out where in RAM a character string is
     located. The string must first be copied to memory with LL_Str2Mem().
     To get the complete memory address, a call to LL_Segment() is also
     needed.

     In real mode, it would be possible to find out where a character
     variable is located by passing the variable by reference to an assembly
     or C function which would then return the address. However, Clipper's
     virtual memory manager could then move the variable somewhere else, and
     the address would no longer be valid. In protected mode, a similar
     approach would not find a valid address at all.

     An approach which works in both real and protected mode is to copy the
     character variable to a static memory location using LL_Str2Mem() and
     then use LL_Segment() and LL_Offset() to retrive the segment and offset
     parts of the memory address of the copy.

 Examples

     local cString1 := 'Hello world'
     local nSelector,nSegment,nOffset,nLength,cString2
     nSelector := LL_Str2Mem(cString1)
     if nSelector > 0
        nSegment := LL_Segment(nSelector)
        nOffset := LL_Offset(nSelector)
        nLength := len(cString1)
        cString2 := LL_Mem2Str(nSegment,nOffset,nLength)
        ? 'The original string was "' + cString1 + '"'
        ? 'The string read from memory was "' + cString2 + '"'
     else
        ? 'Could not copy the string to memory'
     endif

 Source: OFFSET.ASM

 Author: Klas Engwall <klas.engwall@engwall.com>

See Also: LL_Str2Mem() LL_Segment()

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