Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

string

72 views
Skip to first unread message

aurora baccio

unread,
Oct 18, 2021, 9:52:31 AM10/18/21
to
good morning.
unknown grammar
My habit in creating string variables is as follows :
local cVariable := "" as string
You always propose me instead of string string2psz.
I would like to know the difference and the usefulness in using one or the other.
If I search in the help I don't understand the differences.
thanks
Aurora Baccio

Wolfgang Riedmann

unread,
Oct 19, 2021, 3:09:35 AM10/19/21
to
Buon giorno Aurora,

the "normal" variable type to use in VO is "string".

C/C++, the language in which Windows is written, does not knows that
datatype.
In these languages (and some more) a string is defined as a sequence of
bytes terminated by a byte with the value of 0 (zero).
This datatype exists also in VO, and is called "PSZ" - a Pointer to a
String terminated with Zero.

So, if you have to interface with the Windows API you cannot use a
string, but you have to use a PSZ.

The function "String2PSZ()" does exactly what it says:
a memory part is allocated, and string content is copied there, and
terminated with a zero byte. The a pointer to this memory allocation is
returned, and this can be passed to the Windows API call.
If the function/method ends, the memory is released to the OS.

Wolfgang
--

Karl-Heinz

unread,
Oct 19, 2021, 10:15:16 AM10/19/21
to
Hi Aurora,

in addition to what Wolfgang wrote: I´m using 2.8 SP3 where some VO
functions use a PSZ instead of a STRING declaration.

e.g.

_DLL FUNCTION DirMake (pszDir AS PSZ) AS INT PASCAL:VO28RUN.DirMake


To make the compiler happy you should use String2Psz() in such cases.

DirMake ( String2Psz ( cDirName) )

regards
Karl-Heinz

aurora baccio

unread,
Oct 19, 2021, 12:48:21 PM10/19/21
to
thanks
0 new messages