CopyMemory and VarPtr in Lotus Script

I searched the forum and did not find the solution for my problem. in Visual Basic I use the API function “CopyMemory” to enter a value in a string-array at any position not loosing the following/next elements:

the vb-code:

CopyMemory ByVal VarPtr(arr(iPos + 1)), ByVal VarPtr(arr(iPos)), (iUBound - iPos) * 4

in LotusScript I can not get the pointer of the array item by VarPtr. if I just call CopyMemory with string-parameters ("CopyMemory arr(iPos + 1)), arr(iPos)), (iUBound - iPos) * 4) the function will not work.

any ideas how to add to this and pass the CopyMemory function a pointer-value ?

thanks in advance

@lex

Subject: CopyMemory and VarPtr in Lotus Script

See the help file for the declare function w.r.t. string handling and external functions.

However, if you just need to update parts of a string you can do that natively in LotusScript using the Mid statement (not function – see the designer help file for this).

e.g:

s="ABCDEFGHIJKLM"	

Print s	

Mid(s, 4, 2)="de"	

Print s

cheers,

Bram

Subject: RE: CopyMemory and VarPtr in Lotus Script

unfortunately it´s not as trivial as you see it: I have an ARRAY of strings not a string value itself:

e.g. (“sting1”, “string3”, “string4”)

and want to insert “string2” after “string1” with the helpd of the CopyMemory mehtod. it would be possible to insert also by shifting each element 1 position at the end, but with thousands of elements this would be a long-time operation.

CopyMemory will do this very elegant !

any ideas ?

Subject: RE: CopyMemory and VarPtr in Lotus Script

Alex,

Arrays in Lotusscript are not C-style arrays, so it’s not just a string of pointers. There’s a header which contains the size of the array (amongst other stuff like types IIRC). Therefore the CopyMemory approach (which is just bulk-shifting bytes instead of one pointer at a time) won’t work that easily.

If you need frequent inserts into the array, you should make sure that there’s no better data structure for the job.

cheers,

Bram

Subject: RE: CopyMemory and VarPtr in Lotus Script

all right, thanks.I will try to work with a list or extend the array for my needs…

regards

@lex