CopyMemory
CopyMemory SrcAddress, DestAddress, Size
 
Parameters:

    SrcAddress = The source address we'll copy from
    DestAddress = The destination address we'll copy the data to
    Size = The number of bytes to copy
Returns: NONE
 

      CopyMemory will copy a section of memory from one location to another.




FACTS:


      * CopyMemory is dealing with raw memory, as such, PB can not protect you from making mistakes. Thus CopyMemory assumes the memory addresses you give it are valid, if not, you should expect the program to crash !

      * CopyMemory does not support copying overlapping address areas.

      * CopyMemory is the fastest way to duplicate blocks of memory in PlayBASIC.




Mini Tutorial:


      This example fills a bank with some values, then copies this to second bank via CopyMemory.

  
  
; The bank of the banks
  Size=10
  
; create src bank
  SrcBank=NewBank(Size)
  
; Fill this bank with values zero to size
  For lp=0 To Size-1
     PokeBankByte SrcBank,lp,lp
  Next
  
  
; create a second bank
  DestBank=NewBank(Size)
  
  
  
; Calc the Src Address of the memory to copy
  SrcAddress=GetBankPtr(SrcBank)
  
; Calc tyhe destination address
  DestAddress=GetBankPtr(DestBank)
  
; Copy the Memory from the SRC bank to the DEST Bank
  CopyMemory SrcAddress,DestAddress,Size
  
  
; Display the bytes from the Dest Bank
  For lp=0 To Size-1
     Print PeekBankByte(DestBank,lp)
  Next
  
;refresh the screen and wait for a key press
  Sync
  WaitKey
  




This example would output.

  
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
  

 
Related Info: FillMemory | GetArrayPtr | PeekByte | PeekFloat | PeekInt | PeekString | PeekWord | PokeByte | PokeFloat | PokeInt | PokeString | PokeWord :
 


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