Now we will change the Add function so that it sets a APW variable. Make sure that the code.pas file is showing in the code editor. Change the declaration of the Add function to this:
procedure Add( wnd : hWnd ) ; export ; {$ifdef WIN32} stdcall ; {$endif}
The new Add function won't return anything, so we had to make it into a procedure. Change the Add function so it looks like this:
procedure Add( wnd : hWnd );
var
num1 , num2 : LongInt;
begin
if GetApwNumber( 'num1' , num1 , wnd ) = true then
if GetApwNumber( 'num2' , num2 , wnd ) = true then
SetApwNumber( 'res' , num1 + num2 , wnd );
end;
Now let's test the changed function. Compile the UCD, then
start a new APW file.
Load the Add function.
Function name: Add
Arguments: word
Return: void
In a calc icon add this code:
res := 0 num1 := 3 num2 := 4 Add( WindowHandle )
Run the file. Res should now equal 7.
On to: The Set and GetApwString functions
Back to: The SetApwNumber function Start