PBArrayStruct_size
 

     The PBArrayStruct_size constant is the array header size in bytes. If you intend upon manipulating array data directly, then we highly recommended that you use PBArrayStruct_size when calculating element zero to ensure the future compatibility.




FACTS:


      * NOTE: The GetArrayPtr function has an optional parameter to return the pointer to element zero in the array for you. Meaning you shouldn't need this constant in modern PlayBASIC programs. It only remains for backward compatibility reasons.






Mini Tutorial:


      This example demonstrates how the programmer can manually access the elements within an array.


  
  
; Create a 2d array called MyArray()
  Dim MyArray(100,200)
  
; read the value at 25,70 within MyArray()
  Print "Value:"+Str$(MyArray(25,70))
  
; Tell PB to calc the element address of this array() access
; rather than the retrieve that value at of this element.
  Print "Element Address:"+Str$([MyArray(25,70)])
  
  
; The following shows how you can calc the raw address (in memory)
; of any element within an array, then write data into.
  
; Get the Address of the first byte of this array in memory
  ArrayAddress=GetArrayPtr(MyArray())
  
; Skip Pass the Header structure of in the array data
  ArrayAddress=ArrayAddress+pbarraystruct_size
  
; Get the Element address at index (25,70) within MyArray()
  ElementAddress = [MyArray(25,70)] * 4
  
; Poke the value 123456 into this cell
  PokeInt ArrayAddress+ElementAddress, 123456
  
  
; display this element using the normal array index method
  Print "Value:"+Str$(MyArray(25,70))
  
  
  Sync
  WaitKey
  


This example would output.

  
  Value:0
  Element Address:7095
  Value:123456
  

 
Related Info: Dim | GetArrayPtr | PeekInt | Pointer | PokeInt :
 


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