BytePTR
BytePointer = BytePTR(Pointer)
 
Parameters:

    Pointer = The Pointer Data Type you wish to recast
Returns:

    BytePointer = Returns the recast input value as a new pointer
 

     BytePTR will explicitly recast the supplied pointer to that of a Byte pointer.



FACTS:


      * Typed pointers like Byte/Word/Integer and Float can only read/write values of matching data type.

      * Additions / Subtraction to typed pointers with be automatically scale to the pointers data width.




Mini Tutorial:


      This Example declares an generic integer pointer, then dynamically recasts it to read different data types from memory.


  
; Allocate a new bank and get it's address in memory
  BufferAddress=GetBankPtr(NewBank(1000))
  
  
  Dim GenericPointer As Pointer
  
; Write sopme data into this memory
  GenericPointer=BUfferAddress
  *GenericPointer = $12345678
  GenericPointer=GenericPointer+4
  *GenericPointer = 123.456
  
; Reset pointer to buffer address (Address of our bank)
  GenericPointer=BUfferAddress
  
; read the typed values from this generic pointer by recasting them
  Print Hex$(*BytePtr(GenericPOinter))
  Print Hex$(*WordPtr(GenericPOinter))
  Print Hex$(*IntPtr(GenericPOinter))
  Print *FloatPtr(GenericPOinter+4)
  
  Sync
  WaitKey
  




This example would output.

  
  $00000078
  $00005678
  $12345678
  123.456
  

 
Related Info: Dim | Float | FloatPTR | Int | IntPTR | Pointer | types | WordPTR :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com