Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Util/Memory Copy test
Function:
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Memory Copy test
This example is the version from Sun, 17th Mar 2012.
Project "Memory Copy test.rbp"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
EventHandler Sub Open() dim m1,m2,m3 as MemoryBlock dim t1,t2,t3,t4,t5,t6 as integer t1=ticks m1=NewMemoryBlock(40000000) t2=ticks m1.FillBytesMBS 0,m1.Size,123 t3=ticks //m2=MetMemDouble(m1,257) 'm2=MetMemDouble2(m1,257) m2=MetMemDouble3(m1,257) t4=ticks //m3=MetMemHalf(m2,257) 'm3=MetMemHalf2(m2,257) m3=MetMemHalf3(m2,257) t5=ticks if m3.BytesEqualMBS(0,m1.Size,m1,0) then Title="equal" else Title="not equal" end if t6=ticks ListBox1.AddRow Format(t2-t1,"0")+" new" ListBox1.AddRow Format(t3-t2,"0")+" fill" ListBox1.AddRow Format(t4-t3,"0")+" double" ListBox1.AddRow Format(t5-t4,"0")+" half" ListBox1.AddRow Format(t6-t5,"0")+" equal" End EventHandler
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Module MetMem
Function MetMemDouble(minput As memoryBlock, values As integer) As MemoryBlock dim moutput As memoryBlock dim bytepos As integer dim memsize1, memsize2 As integer //Var memsize1=minput.size memsize2=memsize1*2 //Neuer Memoryblock moutput=NewMemoryBlock(memsize2) if moutput=nil then MsgBox "Fehler: Beim doppeln des Speicherabbildes (Eingabe) ist ein Fehler aufgetreten!" return nil end if //Block doppeln for bytepos=0 to memsize1-1 moutput.UShort(bytepos*2)=minput.byte(bytepos)*values //256 next //Zurück return moutput End Function
Function MetMemDouble2(minput As memoryBlock, values As integer) As memoryBlock #pragma DisableAutoWaitCursor #pragma DisableBackgroundTasks #pragma DisableBoundsChecking dim moutput As memoryBlock dim bytepos As integer dim n, memsize1, memsize2 As integer //Var memsize1=minput.size memsize2=memsize1*2 //Neuer Memoryblock moutput=NewMemoryBlock(memsize2) if moutput=nil then MsgBox "Fehler: Beim doppeln des Speicherabbildes (Eingabe) ist ein Fehler aufgetreten!" return nil end if //Block doppeln n=memsize1-1 for bytepos=0 to n moutput.UShort(bytepos*2)=minput.byte(bytepos)*values //256 next //Zurück return moutput End Function
Function MetMemDouble3(minput As memoryBlock, values As integer) As memoryBlock #pragma DisableAutoWaitCursor #pragma DisableBackgroundTasks #pragma DisableBoundsChecking dim moutput As memoryBlock dim bytepos As integer dim n, memsize1, memsize2 As integer //Var memsize1=minput.size memsize2=memsize1*2 //Neuer Memoryblock moutput=NewMemoryBlock(memsize2) if moutput=nil then MsgBox "Fehler: Beim doppeln des Speicherabbildes (Eingabe) ist ein Fehler aufgetreten!" return nil end if minput.CopyByteToUShortMBS(moutput,0,0,memsize1,values) //Zurück return moutput End Function
Function MetMemHalf(minput As memoryBlock, values As integer) As MemoryBlock dim moutput As memoryBlock dim bytepos As integer dim memsize1, memsize2 As integer //Var memsize1=minput.size memsize2=memsize1/2 //Neuer Memoryblock moutput=NewMemoryBlock(memsize2) if moutput=nil then MsgBox "Fehler: Beim doppeln des Speicherabbildes (Ausgabe) ist ein Fehler aufgetreten!" return nil end if //Block doppeln for bytepos=0 to memsize1-2 step 2 moutput.Byte(bytepos/2)=minput.Ushort(bytepos)/values //257 next //Zurück return moutput End Function
Function MetMemHalf2(minput As memoryBlock, values As integer) As memoryBlock #pragma DisableAutoWaitCursor #pragma DisableBackgroundTasks #pragma DisableBoundsChecking dim moutput As memoryBlock dim bytepos As integer dim n,memsize1, memsize2 As integer //Var memsize1=minput.size memsize2=memsize1\2 //Neuer Memoryblock moutput=NewMemoryBlock(memsize2) if moutput=nil then MsgBox "Fehler: Beim doppeln des Speicherabbildes (Ausgabe) ist ein Fehler aufgetreten!" return nil end if //Block doppeln n=memsize1-2 for bytepos=0 to n step 2 moutput.Byte(bytepos/2)=minput.Ushort(bytepos)\values //257 next //Zurück return moutput End Function
Function MetMemHalf3(minput As memoryBlock, values As integer) As memoryBlock #pragma DisableAutoWaitCursor #pragma DisableBackgroundTasks #pragma DisableBoundsChecking dim moutput As memoryBlock dim bytepos As integer dim n,memsize1, memsize2 As integer //Var memsize1=minput.size memsize2=memsize1\2 //Neuer Memoryblock moutput=NewMemoryBlock(memsize2) if moutput=nil then MsgBox "Fehler: Beim doppeln des Speicherabbildes (Ausgabe) ist ein Fehler aufgetreten!" return nil end if minput.CopyUShortToByteMBS(moutput,0,0,memsize2,values) //Zurück return moutput End Function
End Module
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Util Plugin.




Links
MBS FileMaker blog