[comp.windows.ms.programmer] DDE-problems Knowledge Pro <---> DynaComm

corne@aie.uucp (Corne Brouwers) (04/16/91)

Desperately help needed ...

	I'm implementing a MS-Windows Application using the language
Knowledge Pro for Windows (version 1.1 by Knowledge Garden).
The application uses DynaComm
(version 3.0, asynchronous edition by Future Soft). The Knowledge Pro
application creates a communication channel using the DDE_protocol.

Here's my problem:
Knowledge Pro is the client application.
DynaComm is the server application.
Knowledge Pro wants to be informed about the values of several variables in
the Dynacomm application. This is the point where I need a DDE_channel for
conversation between client and server.
	Initiating this DDE_channel causes no problems, but after DynaComm
tries to send values of variables to Knowledge Pro things start to go wrong.

	In the script language of DynaComm there is a statement "WAIT SIGNAL",
which waits for a DDE_message. Problem is that DynaComm indeed resumes execu-
tion of the scriptfile whenever a DDE_advise, DDE_request, DDE_initiate message
arrives, but it doesn't resume execution after a WM_DDE_ACK message arrives.
Future Soft states in it's DynaComm manual (Script Reference p. 3-236):
  "The TABLE REPLY command sends the contents of the specified table in
   response to a DDE request for data from the client, either an ADVISE
   or a REQUEST, and then waits for acknowledgement."
Has anyone ever met the same problem? I'd like to hear from you a.s.a.p.
(deadline problems). I'm also sending this problem description to the guys at
Future Soft.

Thank you for your help.


Here below I submit the source-files:
easy01.kb 	(Knowledge Pro)
easy01.dcp	(DynaComm)
spy01.out	(SDK Spy without me intervening)
spy01a.out	(SDK Spy with me intervening)
easy01.dcp stops right at the WAIT SIGNAL statement in the second
WHEN ADVISE on variable "klaar".

easy02.kb 	(Knowledge Pro)
easy02.dcp	(DynaComm)
spy02.out	(SDK Spy without me intervening)
spy02a.out	(SDK Spy with me intervening)
easy02.dcp stops right at WAIT SIGNAL statement after the TABLE REPLY on
variable "$step" in "loepje".



(*     File:   easy01.kb                                     *)
(*     Date:   12/4/1991                                     *)
(*     Author: Corne                                         *)
(*     Purpose:   This Knowledge Pro knowledge base is a demonstration of   *)
(*        the workings the DDE-protocol between Knowledge Pro (client) and  *)
(*        Dynacomm (server). The Dynacomm-scriptfile is easy01.dcp          *) 

dialog_window is window (,20,10,50,2,,[popup,showChildren,siblings,DialogFrame]).
start_dde ().

topic start_dde.
  show_window (?dialog_window).
  set_text(?dialog_window, '  Starting Dynacomm ... ').

  :prog is load_program ('d:\dynacomm.30a\dynacomm.exe',2).
  :channel is dde_open (dde_handler, 'DYNACOMM', 'd:\dynacomm.30a\dcp\easy01.dct').
  set_text(?dialog_window, '  Communication with Dyanacomm accomplished ... ').
  dde_advise (?channel, step, 1).
  dde_advise (?channel, klaar, 1).
  set_text(?dialog_window, '  After the DDE_advise statements ... ').

  topic dde_handler (info, event, handle).
    do (?event).

    topic dde_fail_event.
      window().
      text (' DDE_FAIL_EVENT !!').
    end.

    topic dde_data_event.
      do (element (?info, 2)).

      topic 'step'.
         set_text (?dialog_window, concat ('#y1Process is performing step ', element (?info, 1), ' of 4 steps')).
      end. (* step *)

      topic 'klaar'.
        set_text (?dialog_window, '#y1topic $klaar is now being executed').
      end.
    end. (* dde_data_event *)

    topic dde_ok_event.
    end. (* dde_ok_event *)
  end. (* dde_handler *)
end. (* start_dde *)

(*	END OF FILE   *)



; File:	easy01.dcp

; %step is a variabele (int), functioning as a counter
SET %step 0

; %klaar is a variabele (str), originally ment to inform Knowledge Pro
; of the fact that execution of the Dynacomm script is about to end.
SET $klaar "FALSE"
TABLE DEFINE 0 FIELDS CHAR 10
@R0.1 = $klaar
RECORD WRITE 0

SET $step "0"
TABLE DEFINE 1 FIELDS CHAR 10
@R1.1 = $step
RECORD WRITE 1
GOTO dde_setup

; "loepje" is a loop in which the counter "$step" is incremented after a delay period of one second.
; After the value of "$step" is incremented it's value is sent to Knowledge Pro over
; the DDE_channel.
; In this test-script the value of "$klaar" is also sent to Knowledge Pro.
*loepje
%step = %step + 1
$step = STR (%step)
@R1.1 = $step
RECORD WRITE 1
TABLE REPLY 1 TO "step"
WAIT SIGNAL

WAIT DELAY "1"

@R0.1 = $klaar
RECORD WRITE 0
TABLE REPLY 0 TO "klaar"
WAIT SIGNAL

IF %step = 4 GOTO stop
GOTO loepje

; "stop" again sends the (new) value of "$klaar" to Knowledge Pro.
*stop
$klaar = "TRUE"
@R0.1 = $klaar
RECORD WRITE 0
TABLE REPLY 0 TO "klaar"
WAIT SIGNAL
CANCEL

; "dde_setup" sets up the dde_conversation, which is initiated by Knowledge Pro
*dde_setup
WHEN INITIATE GOTO dde_setup

WHEN ADVISE 0 "klaar"
BEGIN
  @R0.1 = $klaar
  RECORD WRITE 0
  TABLE REPLY 0 TO "klaar"
  WAIT SIGNAL   ; <--- THIS IS THE POINT WHERE THE SCRIPT HUNG
  GOTO loepje
END

WHEN ADVISE 1 "step"
BEGIN
  $step = STR (%step)
  @R1.1 = $step
  RECORD WRITE 1
  TABLE REPLY 1 TO "step"
  WAIT SIGNAL
  GOTO dde_setup
END

; WAIT SIGNAL waits for a DDE-message.
WAIT SIGNAL

;  END OF FILE


File:	SPY01.out
I've chosen to spy on all the windows so there are more WM_DDE_INITIATE
messages than I really needed to be displayed.
This file contains the output of SPY during the execution of Knowledge Pro
with knowledgebase "easy01.kb".
Everytime Knowledge Pro receives data, it sends a WM_DDE_ACK message back
to Dynacomm. The statement "WAIT SIGNAL" in the DynaComm scriptfile "easy01.dcp"
doesn't react properly to this WM_DDE_ACK message because it hangs until I 
choose the option Script-Resume in the menu (see file SPY01a.out).

2830	WM_DDE_INITIATE     	2830	C572C4F6
39D0	WM_DDE_INITIATE     	2830	C572C4F6
2830	WM_DDE_ACK          	2878	C57CC4F6
38F0	WM_DDE_INITIATE     	2830	C572C4F6
38A8	WM_DDE_INITIATE     	2830	C572C4F6
221C	WM_DDE_INITIATE     	2830	C572C4F6
11A4	WM_DDE_INITIATE     	2830	C572C4F6
2878	WM_DDE_ADVISE       	2830	C5720E36
2830	WM_DDE_ACK          	2878	C5728000
2878	WM_DDE_ADVISE       	2830	C5760E76
2830	WM_DDE_DATA         	2878	C572124E
2878	WM_DDE_ACK          	2830	C5728000
2830	WM_DDE_ACK          	2878	C5768000
2830	WM_DDE_DATA         	2878	C572124E
2878	WM_DDE_ACK          	2830	C5728000

The way I see it "2830" is the handle of the Knowledge Pro Window,
                 "2878" is the handle of the DynaComm Window.
So DynaComm should resume script execution after it receives the
WM_DDE_ACK message from Knowledge Pro.



File:	SPY01a.out

This file is the same as SPY01.out, only after dynacomm hangs (WAIT SIGNAL)
I choose the option Script-Resume and the script resumes execution until
the next TABLE REPLY - WAIT SIGNAL combination

2954	WM_DDE_INITIATE     	2954	C5AAC488
2844	WM_DDE_INITIATE     	2954	C5AAC488
2954	WM_DDE_ACK          	299C	C459C488
2734	WM_DDE_INITIATE     	2954	C5AAC488
38A8	WM_DDE_INITIATE     	2954	C5AAC488
21F0	WM_DDE_INITIATE     	2954	C5AAC488
11A4	WM_DDE_INITIATE     	2954	C5AAC488
299C	WM_DDE_ADVISE       	2954	C532105E
2954	WM_DDE_ACK          	299C	C5328000
299C	WM_DDE_ADVISE       	2954	C5AA1076
2954	WM_DDE_DATA         	299C	C5320E9E
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_ACK          	299C	C5AA8000
2954	WM_DDE_DATA         	299C	C5320E9E
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_DATA         	299C	C5321076
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_DATA         	299C	C5321076
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_DATA         	299C	C5321076
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_DATA         	299C	C5321076
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_DATA         	299C	C5321076
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_DATA         	299C	C5321076
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_DATA         	299C	C5321076
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_DATA         	299C	C5321076
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_DATA         	299C	C5321076
299C	WM_DDE_ACK          	2954	C5328000
2954	WM_DDE_TERMINATE    	299C	00000000
299C	WM_DDE_TERMINATE    	2954	00000000

Actually this whole script worked properly if only I shouldn't have to push
it through the WAIT SIGNAL statement. (Script-Resume menu option).



(*     File:   easy02.kb                             *)
(*     Date:   12/4/1991                             *)
(*     Author: Corne                                 *)
(*     Purpose:   This Knowledge Pro knowledge base is a demonstration of   *)
(*        the workings the DDE-protocol between Knowledge Pro (client) and  *)
(*        Dynacomm (server). The Dynacomm-scriptfile is easy02.dcp          *) 

dialog_window is window (,20,10,50,2,,[popup,showChildren,siblings,DialogFrame]).
start_dde ().

topic start_dde.
  show_window (?dialog_window).
  set_text(?dialog_window, '  Starting Dynacomm ... ').

  :prog is load_program ('d:\dynacomm.30a\dynacomm.exe',2).
  :channel is dde_open (dde_handler, 'DYNACOMM', 'd:\dynacomm.30a\dcp\easy02.dct').
  set_text(?dialog_window, '  Communication with Dyanacomm accomplished ... ').
  dde_advise (?channel, step, 1).
  dde_advise (?channel, klaar, 1).
  set_text(?dialog_window, '  After the DDE_advise statements ... ').

  topic dde_handler (info, event, handle).
    do (?event).

    topic dde_fail_event.
      window().
      text (' DDE_FAIL_EVENT !!').
    end.

    topic dde_data_event.
      do (element (?info, 2)).

      topic 'step'.
         set_text (?dialog_window, concat ('#y1Process is performing step ', element (?info, 1), ' of 4 steps')).
      end. (* step *)

      topic 'klaar'.
        set_text (?dialog_window, '#y1topic $klaar is now being executed').
      end.
    end. (* dde_data_event *)

    topic dde_ok_event.
    end. (* dde_ok_event *)
  end. (* dde_handler *)

end. (* start_dde *)

(*	END OF FILE  	*)




; File: easy02.dcp

SET %step 0

SET $klaar "FALSE"
TABLE DEFINE 0 FIELDS CHAR 10
@R0.1 = $klaar
RECORD WRITE 0

SET $step "0"
TABLE DEFINE 1 FIELDS CHAR 10
@R1.1 = $step
RECORD WRITE 1
GOTO dde_setup

*loepje
%step = %step + 1
$step = STR (%step)
@R1.1 = $step
RECORD WRITE 1
TABLE REPLY 1 TO "step"
WAIT SIGNAL   ; <--- THIS IS THE POINT WHERE THE SCRIPT HUNG

WAIT DELAY "1"

@R0.1 = $klaar
RECORD WRITE 0
TABLE REPLY 0 TO "klaar"
WAIT SIGNAL

IF %step = 4 GOTO stop
GOTO loepje

*stop
$klaar = "TRUE"
@R0.1 = $klaar
RECORD WRITE 0
TABLE REPLY 0 TO "klaar"
WAIT SIGNAL
CANCEL

*dde_setup
WHEN INITIATE GOTO dde_setup

WHEN ADVISE 0 "klaar" GOTO loepje

WHEN ADVISE 1 "step" GOTO dde_setup

WAIT SIGNAL

;   END OF FILE



File:	SPY02.out

This file contains the output of SPY when executing Knowledge Pro knowledge
base "easy02.kb". This knowledge base is more or less the same as "easy02.kb".
The only difference is that it loads DynaComm with the script "easy02.dcp".
Now DynaComm hangs right after the two advise statements.

2B88	WM_DDE_INITIATE     	2B88	C5AAC488
295C	WM_DDE_INITIATE     	2B88	C5AAC488
2B88	WM_DDE_ACK          	2BD0	C4A9C488
288C	WM_DDE_INITIATE     	2B88	C5AAC488
26D4	WM_DDE_INITIATE     	2B88	C5AAC488
21F0	WM_DDE_INITIATE     	2B88	C5AAC488
11A4	WM_DDE_INITIATE     	2B88	C5AAC488
2BD0	WM_DDE_ADVISE       	2B88	C5320E3E
2B88	WM_DDE_ACK          	2BD0	C5328000
2BD0	WM_DDE_ADVISE       	2B88	C5AA0E4E
2B88	WM_DDE_ACK          	2BD0	C5AA8000



File:	SPY02a.out

This file contains the same output as the file "SPY02.out". The difference is
that I choose Script-Resume after the script hung. I discovered that the script
didn't hung after the WHEN ADVISE statements, but in the first WAIT SIGNAL
statement in "loepje". The strange thing however was that the value of "$step"
didn't even reach Knowledge Pro, not even when the loop "loepje" was executed
for the second, third and fouth time. (the execution was forced by me by
choosing the menu option Script-Resume). As you will see, Dynacomm only sends
five WM_DDE_DATA messages (only the ones for variable klaar), while according 
spy01a.out DynaComm sent eleven WM_DDE_DATA messages (six for variable "$klaar"
and five for variable "$step").

62F8	WM_DDE_INITIATE     	62F8	C5AAC488
2830	WM_DDE_INITIATE     	62F8	C5AAC488
62F8	WM_DDE_ACK          	6340	C4A9C488
2734	WM_DDE_INITIATE     	62F8	C5AAC488
38A8	WM_DDE_INITIATE     	62F8	C5AAC488
21F0	WM_DDE_INITIATE     	62F8	C5AAC488
11A4	WM_DDE_INITIATE     	62F8	C5AAC488
6340	WM_DDE_ADVISE       	62F8	C5320E76
62F8	WM_DDE_ACK          	6340	C5328000
6340	WM_DDE_ADVISE       	62F8	C5AA0E9E
62F8	WM_DDE_ACK          	6340	C5AA8000
62F8	WM_DDE_DATA         	6340	C532131E
6340	WM_DDE_ACK          	62F8	C5328000
62F8	WM_DDE_DATA         	6340	C532131E
6340	WM_DDE_ACK          	62F8	C5328000
62F8	WM_DDE_DATA         	6340	C532131E
6340	WM_DDE_ACK          	62F8	C5328000
62F8	WM_DDE_DATA         	6340	C532131E
6340	WM_DDE_ACK          	62F8	C5328000
62F8	WM_DDE_DATA         	6340	C532131E
6340	WM_DDE_ACK          	62F8	C5328000
62F8	WM_DDE_TERMINATE    	6340	00000000
6340	WM_DDE_TERMINATE    	62F8	00000000


				Corne Brouwers
				AI-Engineering BV
				Prins Hendriklaan 23
				1075 AZ  Amsterdam
				Holland
				hp4nl.nlung.nl!aie!corne

--
|	       Corne Brouwers, A.I. Engineering BV,  Amsterdam		      |
|			    corne@aie.UUCP				      |
-- 
--
|	       Corne Brouwers, A.I. Engineering BV,  Amsterdam		      |
|			    corne@aie.UUCP				      |