vb6 CopyMemory replacement

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
axisdj
Posts: 19
Joined: Saturday 8th April 2023 8:27pm

vb6 CopyMemory replacement

Post by axisdj »

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
User avatar
BruceSteers
Posts: 1569
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: vb6 CopyMemory replacement

Post by BruceSteers »

axisdj wrote: Friday 14th April 2023 2:57pm 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.
If at first you don't succeed , try doing something differently.
BruceS
axisdj
Posts: 19
Joined: Saturday 8th April 2023 8:27pm

Re: vb6 CopyMemory replacement

Post by axisdj »

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/previ ... 5(v=vs.85)
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: vb6 CopyMemory replacement

Post by vuott »

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:
https://www.tutorialspoint.com/c_standa ... memcpy.htm

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:

1) call the external C function "memcpy()" directly with the keyword "Extern".
https://www.gambas-it.org/wiki/index.php/Memcpy_()

2) emulate the "memcpy()" function of C by using Gambas resources:
https://www.gambas-it.org/wiki/index.ph ... cpy()_di_C
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
axisdj
Posts: 19
Joined: Saturday 8th April 2023 8:27pm

Re: vb6 CopyMemory replacement

Post by axisdj »

Thank you vuott!
Post Reply