Length of a string variable

Questions about MultiCharts and user contributed studies.
RS
Posts: 39
Joined: 28 Sep 2007

Length of a string variable

Postby RS » 09 Apr 2008

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.

RS
Posts: 39
Joined: 28 Sep 2007

Postby RS » 14 Apr 2008

Marina,

Maybe because of the Beta 3 release these topic is missed :wink: Can you answer it please.

Thanks,
Rob.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Postby ABC » 14 Apr 2008

RS,

if I understand
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.
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.

Regarding:
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?
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).

Best regards,
ABC

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 18 Apr 2008

Marina,

Maybe because of the Beta 3 release these topic is missed :wink: Can you answer it please.

Thanks,
Rob.
Hi Rob,

As soon as the answer is ready I'll send you an e-mail and will also post the answer here.

RS
Posts: 39
Joined: 28 Sep 2007

Postby RS » 21 Apr 2008

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.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 23 Apr 2008

Hi Rob,

If you need any help in future, please let us know.


Return to “MultiCharts”