Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Screeen Scraping like DDE or hllapi

Status
Not open for further replies.

Ati2ude

Programmer
Dec 11, 2001
79
US
Does Procomm not support a screen scrape type interface to allow a connection from a seperate app to read and write to the terminal emulator?? I need to be able to read and write to this emulator to automate some task. I have found several examples of reading and writing, but no examples on establishing the connection. Any help would be greatly appreciated.
 
You can use DDE to allow another application to communicate with Procomm. There is an example script in the discussion of the ddeadvise command in the ASPECT help file that will hopefully get you started.
 
I searched for the example and was not able to locate it. I see some small snippets of the DDE ref info. But nothing that establishes the connection or communication between the app and the term app.
 
That's strange, I have an example script when I look at the ddeadvise command in the help file. Are you using version 4.8 or an earlier version of Procomm? If you are using version 4.8, you can also look in the Samples\ASPECT\DDE directory on the Procomm CD - you'll find a couple examples that interface with an Excel spreadsheet.
 
I am using 4.7. This may be why. I will search the CD to see if it contains anything. Thanks for your help.

Brian Goad
 
I don't think that the samples from the 4.8 CD will be on the 4.7 CD (I think Symantec added the extra material only to the 4.8CD). If they are not there, let me know and I can make the samples available to you somehow. However, the example script should be part of the ddeadvise command discussion in the ASPECT help file. Strange that it is not showing up.
 
The samples are not on my CD. However I did find a white paper detailing the DDE connection. If you could make the samples avaliable I would appreciate it.

Brian
 
I zipped up the samples from the 4.8 CD and placed them at
Also, here is the text of the ddeadvise discussion from the ASPECT help file, including the example script:

Allows Procomm Plus to request both the initial value of a variable and any subsequent changes to that variable from a Windows Dynamic Data Exchange (DDE) server. Each time the value of the specified variable changes in the server application, Procomm Plus is informed of the change.

long Specifies the DDE channel number returned by the ddeinit command.
string The name of the server variable to be monitored.
gdatavar The name of the Procomm Plus global data variable that will be changed each time the server sends a new value for the specified variable.
integer An optional identifier, indicating when a specific variable among multiple ddeadvise commands has been updated. The value is used in conjunction with the $DDEADVISE system variable to indicate which ddeadvise command has been updated. The value must be a positive, non-zero value. If not specified, events associated with the server variable will return -1 in $DDEADVISE.

Example

string szText ; Text read from DDE link to Excel.
proc main
long LinkVar, SystemVar ; Variables containing DDE Id's.

; Set up DDE links to Excel's system and a spreadsheet. Excel
; must be running in order for this script to work properly.
if ddeinit SystemVar "excel" "system"
ddeexecute SystemVar "[FULL(TRUE)]" ; Maximize the spreadsheet.
if ddeinit LinkVar "excel" "sheet1" ; Set up link to spreadsheet.

ddepoke LinkVar "R1C1" "Procomm Plus DDE example!"
dderequest LinkVar "R1C1" szText ; Read info from DDEPOKE.
usermsg szText ; Display text on status line.
ddeadvise LinkVar "R1C1" szText ; Make hot link to row 1,
; col 1 of the spreadsheet.
while 1 ; Loop forever.
if $DDEADVISE
; See if row 1 and col 1 of spreadsheet

; changed, if so read it and evaluate.
if stricmp szText "exit`r`n"
exitwhile ; Exit the while loop.
else
usermsg szText ; Display cell contents.
endif
endif
endwhile
ddeunadvise LinkVar "R1C1" ; Break hot link to spreadsheet.
ddeterminate LinkVar ; Break DDE link to spreadsheet.
ddeterminate SystemVar ; Break DDE link to Excel.

else
errormsg "Couldn't establish DDE link to spreadsheet!"
endif
else
errormsg "Couldn't establish DDE link to Excel!"
endif
endproc

Comments

A ddeadvise operation can be tested with the if SUCCESS statement, returning true if the operation was successful and false if it failed.

The DDE manager only maintains one advise loop per item per conversation. More than one ddeadvise can be established on the same item, and each can be uniquely identified by using the optional ID. A ddeunadvise, however, will terminate all active advisements on that item.
 
Thanks for all of your help. I am now able to write to the emulator but not able to read from it. But have some ideas. Without those files would not have gotten as far as I did. Thanks
 
I finally finished the code and found it very difficult to complete, considering Symantec offerszero support. Had it not been for Knob I would have never completed this code. Below you will find the code I used to allow Visual C++ to work with Procomm. It is not perfect but has been working thus far. Thanks again Knob for all of your help.

Setting up the link to the server:

DdeInitialize ((LPDWORD) &m_DDE_INSTANCE, (PFNCALLBACK) m_DDE_PROC, APPCMD_CLIENTONLY, 0L);
m_SERVER = DdeCreateStringHandle(m_DDE_INSTANCE, szServer, CP_WINANSI);


Opening the connection:

m_TOPIC = DdeCreateStringHandle(m_DDE_INSTANCE, SessionName, CP_WINANSI);

m_DDE_CONV = DdeConnect(m_DDE_INSTANCE, m_SERVER, m_TOPIC, NULL);


Read Function:
RequestCmd = "ASPECTCMD termreads s1 " + LongToString(Length );
//Call to fill variable
DdeClientTransaction ((unsigned char *) pBuf, RequestCmd.GetLength() + 1, m_DDE_CONV, 0, 0, XTYP_EXECUTE, 5000, &dwResult);

//Call to get value of variable set in earlier line.
m_hDATA = DdeClientTransaction (NULL, -1, m_DDE_CONV, hszItem2, CF_TEXT, XTYP_REQUEST, 60000, &dwResult);


Write Function:
//setup the command
RequestCmd = "transmit " + sValue;
//make the call
DdeClientTransaction ((unsigned char *) pBuf, strlen(pBuf) + 1, m_DDE_CONV, 0, 0, XTYP_EXECUTE, 5000, NULL);


Set Cusror Position:
//setup the command
RequestCmd = "ASPECTCMD locate " + LongToString(lLine - 1) + " " + LongToString(lStart - 1);
//make the call
DdeClientTransaction ((unsigned char *)pBuf, strlen(pBuf) + 1, m_DDE_CONV, 0, 0, XTYP_EXECUTE, TIMEOUT_ASYNC, &dwResult);


Get Cursor Position:
//setup the command
RequestCmd = "ASPECTCMD getcur i0 i1";
//make the call
m_hDATA =DdeClientTransaction ((unsigned char *) pBuf, strlen(pBuf) + 1, m_DDE_CONV, 0, 0, XTYP_EXECUTE, 5000, &dwResult);
//query for the results of row position
m_hDATA1 = DdeClientTransaction (NULL, -1, m_DDE_CONV, hszItem1, CF_TEXT, XTYP_REQUEST, 60000, &dwResult1 );
//query for the results of col position
m_hDATA2 = DdeClientTransaction (NULL, -1, m_DDE_CONV, hszItem2, CF_TEXT, XTYP_REQUEST, 60000, &dwResult2 );



If you have any questions on this please post here and I will try to help you understand.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top