vb6 CopyMemory replacement

Post

Posted
Rating:
#1 (In Topic #1026)
Trainee
 I use this extensively in my code, has anyone made a copymemory replacement in Gambas?

I assume it will require an opem .. then a read and write

thanks
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’

axisdj said

I use this extensively in my code, has anyone made a copymemory replacement in Gambas?

I assume it will require an opem .. then a read and write

thanks

you may need to wrap your head around the fact that despite gambas being similar to vb it really is not vb and it works quite differently.

what exactly does copymemory do?  (except of course what it obviously sounds like)  it's not a function i think i have ever needed in gambas so my guess is we do it differently.
Most likely the gambas alternative is simpler than vb requirements.

If you can post some example code it might help.
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
hello,

I definitely see how Gambas does things very elegantly, and I do understand they are different…

here is how its used, its a windows call that copies raw bytes in memory from one location to another

CopyMemory byBuffer(0), array, Len(array)

https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366535(v=vs.85)
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
From what I see, the VB6 function "CopyMemory()" is basically analogous to C language function "memcpy()".
Indeed this C function copies n characters from source memory area to destination memory area:
   C library - memcpy() function

Therefore, if you want to emulate VB6 "CopyMemory()" function in Gambas, you have - in my opinion - at least two possibilities, adopting the solutions proposed in these pages of Gambas Italian forum Wiki:

<COLOR color="#BF0000">1</COLOR>) call the external C function "memcpy()" directly with the keyword "Extern".
    https://www.gambas-it.org/wiki/index.php/Memcpy_()

<COLOR color="#BF0000">2</COLOR>) emulate the "memcpy()" function of C by using Gambas resources:
    https://www.gambas-it.org/wiki/index.php/Emulare_in_Gambas_la_funzione_memcpy()_di_C

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Trainee
Thank you vuott!
Online now: No Back to the top
1 guest and 0 members have just viewed this.