|
|
|
Find out how to use DDE for making custom Data Sheets printed from Word for Windows, or how to retrieve data from an Excel spread sheet for an APG for Windows test program.
Dynamic Data Exchange (DDE) permits one Windows application to share data with another Windows application. The following is a list of the applications this note will discuss:
DDE deals with the exchange of individual data elements. The data elements are uniquely identified by a multi-level name scheme. The hierarchy of this scheme is shown below:
NAME ALSO CALLED EXAMPLES
Application Channel Number WinWord
Name or Service Name Excel
Chklim
Parser
File Name Topic Name c:\winword\document.doc
or Item c:\excel\spreadst.xls
Result
Globaldata
Item Name Data Location bookmark
or Data cell address
Link Name
APG for WindowsVariable
Data Contents of
Item above or
APG for Windows Variables
or literal text
DDE Commands in APG for Windows
APG for Windows uses the following commands for DDE. Any of the location names can be variablized to aid in program execution. The term "Variable Name" can represent the actual data or a variable in APG for Windows that contains the data.
It is required that both applications involved in a DDE be open and running in Windows. The following command in APG for Windows allows another application to be opened:
If IsVar(FirstTime)
Define Variable(FirstTime)
Run an Application
EndIf
Passing APG Data to Other Applications
Data to be passed to other applications from APG for Windows can come from direct calculation or function evaluation. For example, an operators response to a message box can be saved as "PASS" or "FAIL" in a string variable which in turn can be passed to another application in a DDE poke.
Message Box(is the LED lit?,LED Visual Check,2,4)
If(_MBRET==_YES)
Format String(<string variable>,PASS)
else
Format String(<string variable>,FAIL)
EndIf
Poke DDE Data(application name,file name,item name,%<string variable>%)
Another example would be taking the result of the system function LineV, formatting it to have 1 decimal place, converting it into a string and passing it to another application by DDE poke.
Format String(<string variable>,%1(LineV)%)
Poke DDE Data (application name,file name,%<string variable>%)
Data acquired and stored by test procedures using the function Check Test Limits (within APG for Windows test programs) is available under the DDE application name CHKLIM. The data location information is outlined in the table below. For data logged by test procedures, the link name entered in the test is used as the Item Name.
Application Name Topic Name Item Name Variable Name (type)
CHKLIM NAME Link Name 30 character string
ULIMIT Link Name floating point numeric
RESLUT Link Name floating point numeric
LLIMIT Link Name floating point numeric
PASSFAIL Link Name 5 character string
UUT Model 80 character string
SERIALNUM 30 character string
To pass CHKLIM data to another application it must first be extracted from the CHKLIM application using the Request DDE Data function. The following example extracts the contents of the RESULT field from CHKLIM and stores it temporarily in <string variable> before passing it to the item name in the other application.
Request DDE Data(CHKLIM, RESULT, %Link Name%,<string variable>)
Poke DDE Data (application name,file name,item name,%<string variable>%)
Custom APG data sheets can best be handled through DDE with Word for Windows.
You can have APG for Windows open Word by using the Run An Application function and once the test is complete close Word using the Execute DDE Cmd function. However, because Word is slow to load, it is recommended that Word be opened before running APG for Windows. This can be done manually or automatically by Windows at start-up.
For a growing number of power supply manufacturers, modular supplies are becoming more common. In this arrangement various output modules may be configured in a single chassis to provide a wide variety of choices to the customer. However, the mix and match nature of these units can create a near infinite combination of modules. The cost for the test system programmer to write individual programs for each of these combinations would be very high.
The solution is to write a single program that identifies the modules and accesses the appropriate data to test that combination. The cataloging of the various modules is easily done in an Excel spreadsheet. Using string evaluation in the test program to decipher the unit configuration, DDE can then be used to extract the needed data from the spreadsheet and a variablized parameter test program can test any combination.
Specific data elements can be extracted from an Excel spreadsheet in much the same manner as the CHKLIM application.
Request DDE Data(Excel,C;\\pathname\\filename.xls,cell name,<string variable>)
Where the contents of the cell named "cell name" are copied into the contents
of the "variable string" in
APG for Windows.
The cells can be accessed either by naming them in the spread sheet or by referring to their row and column designation (i.e., R1C2). In the latter case a For/Next or nested For/Next loop could be utilized to automatically extract arrays of data from Excel. The Temp variable could alternatively be an array deep enough to store all the "xy" combinations.
For(x=1,x<6,x++)
For(y=1,y<6,y++)
Request DDE Data(Excel,c:\\pathname\\filename.xls,R%x%C%y%,Temp)
Next
Next
Excel can be started from APG for Windows using the Run An Application function.
Run An Application(c:\\excel\\excel.exe /r c:\\excel\\sheet\\filename.xls,v,0)
Where "/r" indicates open the file "filename.xls"
read only. The "\\" is not a mistake. Because
the "\" character is reserved in APG for Windows, an additional
"\" is required get the literal character.
See the attached APG for Windows program and Word Document for a working example of the Custom Data Sheet.
To obtain or download a
self-extracting file containing the complete application, contact Autotest
Technical Service.
Copyright © 1995 - 2001, Autotest Company, All Rights Reserved.