CompareMemory
Result = CompareMemory(SrcAddress, DestAddress, NumberOfBytes)
 
Parameters:

    SrcAddress = The Starting address in memory to compare
    DestAddress = The destination address to compare
    NumberOfBytes = The Number of bytes to compare
Returns:

    Result = The if the two chunks of memory are the same then the function will return a True(1), it not, it'll return false(0)
 

      The CompareMemory function compares if two sections of the memory are the same or not.



FACTS:


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

      * CompareMemory is the fastest way of comparing runs of bytes in PlayBASIC.




Mini Tutorial:


      This sample creates two banks of memory, fills one bank then copies that data to the second bank then uses CompareMemory to validate it.


  
  
; 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
  
  
; Compare two banks of memory ?
  
  If CompareMemory(SrcAddress,DestAddress,Size)=true
     Print "Memory is the same"
  Else
     Print "Memory is not the same"
  EndIf
  
  
  
;refresh the screen and wait for a key press
  Sync
  WaitKey
  
  



This example should output.

  
  Memory is the same
  

 
Related Info: CopyMemory | FillMemory | FindMemoryRunLength | PeekByte | PokeByte :
 


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