Announcement

Collapse
No announcement yet.

Convert to BYTE PTR

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

  • Jay Straffer
    replied
    Thanks a bunch, guys.

    Leave a comment:


  • John Gleason
    replied
    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

    Leave a comment:


  • Paul Squires
    replied
    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.

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • Jay Straffer
    started a topic Convert to BYTE PTR

    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.
Working...
X