Announcement

Collapse
No announcement yet.

Convert to BYTE PTR

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert to BYTE PTR

    Code:
    LOCAL dwOffset AS DWORD
    LOCAL pData As BYTE PTR
    dwOffset = &H654321
    @pData = CBYT PTR(dwOffset)
    See where I have it doing "CBYT PTR(...)" ? I want to convert dwOffset to a BYTE PTR, but I know of only CBYT(...). Is there a way?

    Thanks.
    Last edited by Jay Straffer; 13 Feb 2009, 07:59 PM.

  • #2
    Insufficient code shown.

    As written, pData is zero, meaning this will GPF (or ERR 9, but ON ERROR is not in use).

    What do you want to do, take the byte value at 'dwoffset' and put it somewhere? (Like, into a byte variable?) Then you need a byte variable to store it in.

    Maybe you mean something like ...
    Code:
    LOCAL data as BYTE
    LOCAL pData AS BYTE PTR 
    
       pData  = (ADDRESS of the base of whatever dwOffset is from) + dwoffset 
       data     = @pData


    .. something like that?

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Jay,

      If you are not comfortable using pointers then you could always use PB's PEEK and POKE statements. IIRC, the new versions of those statements are extremely fast.
      Paul Squires
      FireFly Visual Designer (for PowerBASIC Windows 10+)
      Version 3 now available.
      http://www.planetsquires.com

      Comment


      • #4
        Maybe something like this?
        Code:
        #COMPILE EXE
        #DIM ALL
        
        FUNCTION PBMAIN () AS LONG
        
            LOCAL dwOffset AS DWORD
            LOCAL pData AS BYTE PTR
            LOCAL myData AS STRING
            dwOffset = &H654321
            myData = REPEAT$(1400000, CHR$(3,123,33,51,66,211,92,244))  'any data string
            pData = STRPTR(myData) + dwOffset
            ? MKBYT$(@pData)        'this shows you the byte at offset &H654321
            ? STR$(@pData)          'this shows you the value of the byte at offset &H654321
        
        END FUNCTION

        Comment


        • #5
          Thanks a bunch, guys.

          Comment

          Working...
          X