Marina,
I'm using output parameters in external dll function calls. The documentation of EL describes:
Text strings are passed by address as a default when the LPSTR parameter type is used. Do not change the size of the passed string within your DLL, as this can cause unpredictable results.
How can I get in EL the size of a string variable? The reserved word VarSize() doesn't seem to work.
Is the size of a string variable the size of the initial string in the declaration? Will the size change when I assign an other value to it?
Thanks in advance,
Rob.
Length of a string variable
- ABC
- Posts: 721
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 408 times
- Contact:
RS,
if I understand
Regarding:
Best regards,
ABC
if I understand
correctly, this is referring to the actual string expression i.e. the number of characters your string has got. For this you can just use "StrLen" in EL to check the size of your string.Text strings are passed by address as a default when the LPSTR parameter type is used. Do not change the size of the passed string within your DLL, as this can cause unpredictable results.
Regarding:
My assumption would be that you reserve a fixed size amount with each variable once you define it (this would correspond to the maximum string length). During your program the only thing that can change is how much of your reserved size you are using with your string (i.e. size of string length).Is the size of a string variable the size of the initial string in the declaration? Will the size change when I assign an other value to it?
Best regards,
ABC
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007
Marina,
I'm not sure but maybe I found the problem. The strReply buffer used with CallNamedPipe(gstrPipename, strBuf, intLen, strReply, intLen2, ... is always given a (fixed) length of 255 (intLen2) chars. I'm not sure how the OS handles this buffer within the CallNamedPipe function but I suspect that internally (occasionally) 255 chars are used, even when the reply string is (much) shorter. In my case the reply is always <= 20 chars.
I changed the declaration of my LPSTR variable to 255 chars ("01234567890123456789..."). Maybe you know an easier way to declare a 255 char variable in EL? I'm testing it know. Let you know of the results.
Rrgds,
Rob.
I'm not sure but maybe I found the problem. The strReply buffer used with CallNamedPipe(gstrPipename, strBuf, intLen, strReply, intLen2, ... is always given a (fixed) length of 255 (intLen2) chars. I'm not sure how the OS handles this buffer within the CallNamedPipe function but I suspect that internally (occasionally) 255 chars are used, even when the reply string is (much) shorter. In my case the reply is always <= 20 chars.
I changed the declaration of my LPSTR variable to 255 chars ("01234567890123456789..."). Maybe you know an easier way to declare a 255 char variable in EL? I'm testing it know. Let you know of the results.
Rrgds,
Rob.
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007