PDA

View Full Version : possible bug in Call DLL?



NewsArchive
06-18-2011, 02:03 AM
Hi Friedrich,

I have a situation where I am calling RunDLL and one of the paramters is
*CSTRING.
I passed %LOGFILENAME% for this parameter. I had not yet declared variable
%LOGFILENAME%. I thought it would pass an empty string to the dll.
Instead it passed the text "%LOGFILENAME%" without the quotes.

Once I set %LOGFILENAME% to an empty string in the beginning of the script
it correctly passed an empty string to the called DLL.

Is this expected behavior?

TIA,
Rick

NewsArchive
06-18-2011, 02:03 AM
Hi Rick,

> I have a situation where I am calling RunDLL and one of the paramters is
> *CSTRING.
> I passed %LOGFILENAME% for this parameter. I had not yet declared variable
> %LOGFILENAME%. I thought it would pass an empty string to the dll.
> Instead it passed the text "%LOGFILENAME%" without the quotes.
>
> Once I set %LOGFILENAME% to an empty string in the beginning of the script
> it correctly passed an empty string to the called DLL.
>
> Is this expected behavior?

I can't reproduce this here :-(

I have uploaded my test script and the DLL source codes to:

www.lindersoft.com/projects/rick_20110617a.zip

I compiled and launched "DLLTest.sb7" and it did not display anything for
the first DLL call and displayed "mytest.log" in the 2nd call.

Can you modify the example so that it "fails"?

BTW, if you do not declare %LOGFILENAME% then the compiler gives the
following error for the "Call DLL" function:

DLLTest.sb7(28): error GEN1006: Reference to variable %LOGFILENAME% has not
been previously defined.

Friedrich

NewsArchive
06-18-2011, 02:04 AM
BTW, if a variable is declared (at compile time) before its use but the
installer does not declare it at runtime then the variable name (not the
value) will be passed. This is the expected behavior in all functions.

For example:

Set Variable %TRUE% to "0"
If %TRUE% Equals "1" Then
Set Variable %LOGFILENAME% to ""
End
Call DLL "sbdll.dll" -- Function "TEST" (*cstring) (%LOGFILENAME%)

At runtime, the "Set Variable" action is never executed (If 0 Equals 1 is
FALSE) and so the variable is not defined.

Friedrich

NewsArchive
06-18-2011, 02:04 AM
Hi Friedrich,
This was definitely the case.
I had
If %_SB_RESUME% Equals "1" Then
Set %LOGFILENAME% to saved value
Else
all the other stuff which include the Call Dll code.

I had fixed the issue by initializing the variable before the If

thanks,
Rick