Won't n be 0 by the default compiler initialization behavior? It may not be
what's wanted, but it's probably consistent run to run....



  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Walter Prins
Sent: Wednesday, November 15, 2006 4:44 PM
To: [email protected]
Subject: Re: [delphi-en] Crystal 8 UDF's



Hello Paul,

At the risk of belaboring this too much... :-) I think you might maybe 
(?) still be making the same mistake I made (which prompted me to chip 
in earlier on as well.) Notice, there are *2* PostMessage lines in your 
code. The first one, happens **before** the line where n is assigned a 
value. Thus, n is undefined for the first PostMessage, and as Rob's 
pointed out, the compiler should've warned you about it. :-)

Eg (quoting original code again, see lines marked with <<<<<<<<<<) :

function LaunchApplication (ParamBlock : PUFParamBlock) : UFError;
var
...Param1 : PUFParamListElement; //a pointer to the first parameter
...n : integer;
...fWakeup : Cardinal;
...MyWakeup: PChar;
begin
...//the first param is the AppID to launch
...Param1 := GetParam (ParamBlock, 1);

...//check if the correct number of parameters is passed to our function
...if (Param1 = nil) then
...begin
......MyWakeup := Error;
......fWakeup := RegisterWindowMessage(MyWakeup);
......If fWakeup <> 0 Then
.........nResult := PostMessage(hWnd_BROADCAST, fWakeUp, n, n); 
//<<<<<<<< n is undefined!
......Result := UFNotEnoughParameters;
......EXIT;
...end;

...n := Param1.Parameter.ParamInteger;
...MyWakeup := Wakeup;
...fWakeup := RegisterWindowMessage(MyWakeup);
...If fWakeup <> 0 Then
......nResult := PostMessage(hWnd_BROADCAST, fWakeUp, n, n) // <<<<<< n 
is defined here!
...Else
......nResult := False;

...ParamBlock^.ReturnValue.ReturnNumber := Param1.Parameter.ParamInteger;
...Result := UFNoError;
end;

Cheers

Walter

Paul Bennett wrote:
>
>
> > Rob Kennedy wrote
> > That's what the value of n is supposed to represent, but that's not 
> what I
> > asked. I asked what value n actually has. Put a breakpoint there and 
> look
> > at the value of n.
> >
> > Next I asked how n gets the value you expect it to have. N is a local
> > variable, not passed in as a parameter. Point me to the line where n 
> gets
> > the value you say it has. Where is the assignment statement that changes
> > the value of n? (Here's a hint: You won't be able to point to such a 
> line.
> > The compiler should have warned you about it.)
> >
> > --
> > Rob
>
> >
>
> Param1 := GetParam (ParamBlock, 1);
> ...
> n := Param1.Parameter.ParamInteger;
>
> The code is based on the Example of how to write Crystal UDFs in 
> Delphi. Parameters are passed from Crystal to the dll using a 
> ParameterBlock, the call to GetParam(ParamBlock, 1) returns the first 
> Parameter in ParameterBlock (as a variable of Type 
> PUFParamListElement, this is then passed to n by the 
> Parameter.ParamInteger method.
> The dll I am writing is used as an out of process dll called by 
> Crystal Reports, I don't know how to set a breakpoint for OOP dlls!
> I have changed to code slightly to Post the Error Message if n = 0 and 
> MyWakeup Message otherwise, and I am only receiving the Error Message, 
> so Param1 appears to be 0 (not null as that is check for).
>
> Paul Bennett
>


.
 
<http://geo.yahoo.com/serv?s=97359714/grpId=1997149/grpspId=1705115362/msgId
=16254/stime=1163638521/nc1=3848644/nc2=3848533/nc3=3> 
 



[Non-text portions of this message have been removed]

Reply via email to