CWinA V0.9
(c) IMSL Software 1996

CWinA: CASIF/Win for Applications

CWinA consists of the Casio communications core of CASIF/Win packaged with a 
simplified file drag-and-drop user interface and a new API supporting data exchange with 
other applications using Windows DDE links. CWinA is less than 1/2 the size of 
CASIF/Win.

CWinAs drag-and-drop file operation is ideal for quickly backing up and restoring Casio 
diary data, and for transferring data to and from other applications in the form of text 
files.

You can use the Paste Link function of CWinA and other Windows other applications to 
create links between CWinA and these applications for sending and receiving Casio data. 
For users who want to create more sophisticated data management functions, CWinA 
also provides a DDE interface to applications programs.

CWinA Functions

Receive -	opens a Receive window to receive data from the Casio diary (same as 
CASIF/Win Receive window

Transmit -	opens a Transmit window to transmit data to the Casio diary (same as 
CASIF/Win Transmit window

Paste Link -	pastes a hot link from a source application into CWinA to transmit data to 
the Casio diary

COM Port -	opens a COM Port Settings window (same as the COM Port Settings 
window in CASIF/Win)

Model -	opens a Digital Diary Model selection window (same as the Digital Diary 
Model selection window in CASIF/Win)

Format -	opens a Data Format settings window (same as the Data Format settings 
window in CASIF/Win)

Help -	opens the associated Help file

CWinA provides no functions for viewing or editing data.

Differences from CASIF/Win

The data management features of CASIF/Win are not present in CWinA, such as:

n Tables
n Forms
n Databases
n Agenda
n Printing
n Macros
n Import/Export

The standard functions to set the COM port, Digital Diary Model, and Data Format are 
present on the CWinA toolbar.

CWinA requires the file CASIFW.INI to store its settings. Like CASIF/Win, it will create 
a default INI file if it doesnt find one. CWinA can use the same CASIFW.INI file as 
CASIF/Win.

Drag and Drop File Operation

Receive:

You can click the Receive button on the CWinA toolbar to open a Receive window and 
receive data from the Casio diary. Data is saved to a CAS file, and optionally converted 
and saved to CSV text files if Convert to Text is selected. The text files have the same 
data type extensions as CASIF/Win: TEL, BCD, MEM. SCH, TDO, EXP, FRE.

Casio Folder:

Files created and saved by the Receive function will automatically appear in the Casio 
folder (Windows95) or program group (Windows 3.1) as they are created. The Casio 
folder or program group will be created if it does not yet exist. In Win 3.1, the Casio 
program group will appear in the Program Manager and contain document file icons for 
the CAS file and text files. In Win95 the Casio folder will appear under Windows/Start 
Menu/Programs/Casio, and the icons will be shortcuts to the CAS file and text files. You 
can create a shortcut to the Casio folder on the desktop if you want.

Under Win95, you can assign the icon associated with each Casio file type, and the 
application to Open and view each file type, by selecting View/Options/File Type from 
the Explorer or My Computer menu. Under Win 3.1, you must use the CVIEW program 
(see below) to assign the appropriate icon to each Casio data file type.

Transmit:

You can click the Transmit button on the CWinA toolbar to open a Transmit window and 
transmit files to the Casio diary. As with CASIF/Win, you can enter or select a CAS file 
to transmit in the From File box, and you can click the Convert button to convert text 
files to CAS format.

In CWinA you can drag any CAS file or CSV text file or group of CSV text files onto the 
CWinA icon to send them to the Casio diary. Text files are automatically converted to 
CAS format before sending.

You can also drag files into the CWinA window while it is open to convert and send 
them.

Backup/restore operation:

To do a simple back up:
  start CWinA
  click the Receive button to open the Receive window
  select the Backup Only option and click Receive to start
  send data from the Casio diary
  CAS file appears as an icon in the Casio folder/program group

To do a simple restore:
  drag the CAS file icon onto the CWinA program icon (program starts if inactive)
 click Start when ready to send the file to the Casio diary

CVIEW:

Under Win95 you can set the icon individually for each file type, but under Win 3.1 
document files automatically take on the icon of their associated application. Since you 
will probably prefer Casio data files to appear with the icon corresponding to their data 
type, you must associate a different application with each data type. The CVIEW 
program is provided for this purpose.

There is one version of CVIEW for each Casio data type, named CVIEWxxx.EXE, where 
xxx is the 3-letter Casio data type. The default icon of each EXE file is the standard icon 
for the associated data type. Otherwise, each copy of CVIEW is identical. You can use 
the Program Manager Associate function to associate each Casio file type with the 
appropriate copy of CVIEWxxx.EXE. Any new files created will then appear with the 
correct icon.

All the CVIEW program does is to run a single Windows command line to start the 
associated data viewer if you double-click on a the associated text file icon to open it. 
The built-in command line is: C:\VB3\CASIF\CASIFW. You can change this command 
line in each copy of CVIEWxxx.EXE by editing the EXE file, for example using DOS 
DEBUG as follows:

	> COPY CVIEWTEL.EXE CVIEWTEL.TMP
	> DEBUG CVIEWTEL.TMP
	- e A12 C:\EXCEL\EXCEL
	- w
	Writing xxxx bytes
	- q
	> COPY CVIEWTEL.TMP CVIEWTEL.EXE

DDE Interface

Quick overview of DDE:

DDE (Direct Data Exchange) is a Windows message-passing protocol which allows two 
applications to communicate data and commands. One application is the source of the 
data, and the other application is the destination.

The DDE link is always originated by the destination application, specifying the data it 
wants from the source application. The linked data can then be updated by an automatic 
message from the source to the destination application whenever it changes (an 
automatic or hot link), or only on request from the destination application (a 
manual or warm link).

The originator of the link (the destination application) can send commands to the source 
application using a DDE Execute function. The actual commands recognized depend on 
the source application. The originator of the link (the destination application) can also 
send data to the source application, i.e. the reverse of the normal direction, using a DDE 
Poke function.

How CWinA uses DDE:

You can paste a link from CWinA into any application which supports Paste Link, and it 
will automatically copy data received from the Casio diary record-by-record to the  
linked fields in the destination application.

You can paste a link from any application which supports DDE into CWinA, and CWinA 
will automatically transmit the linked data.

An application can initiate a DDE link to CWinA to send or receive data records under 
application control. Examples macros are provided using the Visual Basic for 
Applications (VBA) macro language for Microsoft Excel. This example can be used with 
minor changes in Microsoft Word and Microsoft Access, and provides a guideline for 
how to use the CWinA DDE interface in any programming language or application 
script/macro language which supports DDE functions.

An application can direct CWinA to Receive or Transmit data over the DDE link by 
sending the DDE Execute commands described below.

Paste Link Operation

DDE is encountered at the user level of many applications in the form of the Paste Link 
function or Paste Special/Paste Link function on the Edit Menu. This commands pastes 
source DDE link information from the clipboard into a destination application, normally 
creating an automatic link.

To use Paste Link, you must previously have placed the source DDE link information on 
the clipboard, for example by selecting data in the source application and entering the 
Copy command. Most destination applications save link information with the document 
containing the link, and will automatically attempt to re-establish the link when you open 
that document again. If the source application is not running, they will attempt to run the 
source application and have it open the source document. Microsoft Word and Microsoft 
Excel are examples of applications which can be both source and destination applications 
for DDE links.

Example using Microsoft Excel:

1. Start CWinA and Excel.

2. In Excel, select a range of records which you want to transmit to the Casio diary (see 
the example format on the SendData sheet of DDEEXMPL.XLS.

3. Select Copy or enter Ctrl-C in Excel to copy the selected range and link information to 
the Windows Clipboard.

3. Switch to CWinA and click the Paste Link button.

CWinA will switch to Transmit mode, establish a link to Excel, request the selected 
records, convert them to Casio format, and prompt you to press Start when ready to 
transmit them to the Casio diary. The link will remain in effect until you terminate Excel 
or CWinA. If you change the data in the selected range in Excel, the entire range will be 
transmitted again.

Receiving Data via Paste Link:

When you open a Receive window in CWinA, it automatically copies a link to 
CWinA|xcv!DDERecord to the Windows Clipboard. This link can be pasted into any 
other Windows application which supports the Paste Link function. The linked field will 
contain the latest record received (initially null), in the format:

	<datatype><tab><field1><tab><field2><tab><fieldn><cr><lf>

The data type is indicated by the leading <datatype> field, one of:

	TEL - Telephone (4-9 fields)
	BCD - Business Card (10-15 fields)
	MEM - Memo (1-2 fields)
	SCH - Schedule (6 fields)
	TDO - To Do (5-6 fields)
	EXP - Expense (8 fields)
	FRE - Free file (2 fields)

Example using Excel:

1. Start CWinA and Excel

2. Click Receive in CWinA to open the Receive window

3. Switch to Excel, select a row, and then select the function Paste Special/Paste Link

4. Switch back to CWinA and begin receiving data from the Casio diary

The linked row in Excel will update automatically as records are received from the Casio 
diary.

The linked field in the destination application will always contain only one record, the 
latest record. The DDE link is to a fixed field in the destination application; CWinA is 
not able to direct incoming records to different fields in the destination application, such 
as sequential rows in a spreadsheet or sequential lines in a document - this must be done 
under application control by copying the data from the linked field as it changes (see the 
example in DDEEMPL.XLS).

Note that many applications, such as Excel, will save DDE links with the current 
document, and prompt you to re-establish them when the document is opened. 
Attempting to open a DDE link to an application which is not already running will cause 
Windows to start the application (if Windows can find it in the current path; otherwise 
you will get a could not start xxx.EXE message). If your application contains functions 
to start the linked application on demand, as DDEEXMPL.XLS does for CWinA, then 
you can respond No when asked to re-establish automatic links at the time the 
document is opened. However, note that responding No to this question in Excel 
disables all links until you explicitly re-enable them (as the Start Receive function does 
in DDEEXMPL.XLS).

DDE Execute Command: ReceiveDirect

The ReceiveDirect command directs CWinA to receive data and copy it record-by-
record to the DDE link field. Upon receiving this command via DDE Execute, CWinA 
will switch to Receive mode and copy a link to the xcv!DDERecord field  to the 
clipboard. The destination application is responsible for establishing a link to the 
xcv!DDERecord field, usually using a PasteLink function (the specific name and format 
of this function varies in each application - see the Excel example in 
DDEEXMPL.XLS).

CWinA will not actually start tranferring data until you press the Receive button in the 
Receive window, and then start sending data from the Casio diary. The default receive 
mode selected will be Link Only, meaning that no CAS file or CSV text files will be 
created (actually, a CAS file is created, and deleted after the data has been received). 
You can change the receive mode to Backup Only or Convert to Text before starting to 
receive if you prefer to create files as well as transferring the data to the linked 
application.

The destination application is responsible for responding to the data records as they are 
received. See the example of responding to new data in Excel using the OnData function 
in DDEEXMPL.XLS, which copies each new record to the end of the.separate 
worksheet for its data type.

Transmitting Data via DDE Link

You can transmit data records from your application to the Casio diary via DDE link to 
CWinA.

Step 1: Create the Link:

You can create a DDE transmit link to CWinA in one of two ways:

1)  Manual Paste Link into CWinA from any application which supports DDE

2)  Open a DDE link using the Open Link function of the application 
programming/macro language, then send the TransmitDirect command

If CWinA is not already running, opening a DDE link will start it.

Manual Paste Link:

In the source application (e.g. Excel) select the data range containing the data to transmit, 
and copy it to the Windows clipboard. This data must be in the format:

	<datatype><tab><field1><tab><field2><tab><fieldn><cr>[<lf>]
	<datatype><tab><field1><tab><field2><tab><fieldn>[<cr><lf>]
	

or the equivalent column or field format of the application which will cause the fields to 
be separated by tabs and the  records by  <carriage-return> or <carriage-
return><linefeed> when copied to the DDE link (e.g. columns and rows in Excel).

The data type is indicated by the leading 3-character <datatype> field, followed by the 
number of fields required for the data type:

	TEL - Telephone (4-9 fields)
	BCD - Business Card (10-15 fields)
	MEM - Memo (1-2 fields)
	SCH - Schedule (6 fields)
	TDO - To Do (5-6 fields)
	EXP - Expense (8 fields)
	FRE - Free file (2 fields)

The leading data type field must be present to tell CWinA what type of data the record 
contains. CWinA will fill trailing fields with null strings if the expected number of fields 
are not present. If the leading data type field is empty, CWinA will assume that the data 
type is the same as the previous record.

Create link using application program/macro language:

n create a link to CWinA using the applications program/macro language Open DDE 
Link function. Use source application: CWinA, topic xcv; use field DDEOK as 
the item if an item is also required.
n use the applications program/macro language DDE Execute function to send the 
command TransmitDirect,application|topic!item to CWinA, where application is 
the the Windows name of the application (normally the EXE file name with no 
extension, e.g. Excel), topic is usually the name of the open document in the 
application (e.g. Sheet1 in Excel), and item is the data range to be copied over 
the DDE link (e.g. R1C1:R1C7 in Excel). This creates a link from the source data 
to the DDERecord field in CWinA
n If there are no link parameters following the TransmitDirect command, CWinA 
looks on the Windows clipboard for the link information. This allows you to Copy a 
link to the clipboard manually before sending the TransmitDirect command if you 
do not want to determine these parameters in your program/macro.

Step 2: Send the data:

n The initial contents of the linked field will be transmitted when the link is created. 
Change the source data in the linked field of the application program to cause the 
new data to be copied to CWinA over the DDE link. CWinA will convert and 
transmit each record or group of records as it is received. [Note: many interactive 
applications, such as Excel and Word, have a built-in delay of a few seconds before 
they update the DDE link with changed data to allow you to finish making changes]
n Alternatively, use the applications program/macro language DDE Poke function to 
transfer single records or groups of records to the DDERecord field of CWinA using 
the DDE channel created by the Open DDE Link function (an example of this is 
given in DDEEXMPL.XLS)

Avoiding data overrun:

The Casio diary can only accept data at a maximum rate of 9600 baud, so it takes some 
time for CWinA to transmit data. Your application should avoid sending new data before 
CWinA has finished sending the last set of data. CWinA provides the DDEOK field to 
allow you to check on this. The DDEOK field contains Y when it is OK to send new 
data, or N when it is not OK.

You can either establish an automatic link from the DDEOK field in CWinA to a local 
field in your program, or use the DDE Request function of the applications 
program/macro language to check the value of the DDEOK field directly. When you 
activate the Transmit function of CWinA, it automatically copies a link to the DDEOK 
field to the Windows clipboard, which you can paste into a visible field in your 
application using the applications Paste Link function.

If you send data over the DDE link when CWinA is not accepting data, it will be 
buffered, but you run the risk of eventually overrunning the buffer (about 32 Kbytes), and 
your applications timing will be out of synch with the records appearing on the Casio 
diary at the receiving end.

Sending multiple records at once:

CWinA will accept and process one record or multiple records at a time over the DDE 
link.. Each record or group of records will be converted to Casio format and sent as they 
are received. No transmission terminator will be sent (non-SF-5x80 models only) until a 
final End record or Abort command is received over the DDE link.

If there are multiple records in a single DDE transfer, each record must end in <cr> or 
<cr><lf> (carriage return, linefeed).

Why send multiple records instead of one at a time? Its more convenient if you have a 
list of records displayed in an application to select and transmit them all at once by a 
Paste Link to CWinA. In addition, the DDE link can be rather slow when copying one 
record at a time. One way to speed it up is to copy multiple records as a set. However, 
larger sets of records take longer to transmit, so remember to check DDEOK before 
sending the next set to avoid data overrun, as noted above.

Step 3: Ending Transmission:

To end a transmission, send a record beginning with the data type End to DDERecord, 
or send the Abort command by DDE Execute.

This causes CWinA to end the Transmit function and terminates Receive mode on the 
Casio diary (non-SF-5x80 models only - you must manually end Receive mode on SF-
5x80 models).


Summary of DDE Execute Commands

Once you have opened a DDE link to CWinA you can send a number of commands to 
CWinA using the DDE Execute funtion, whether or not you have also created a data 
source/destination link. Some of these commands are described in context above, and 
you can find examples of each of them in DDEEXMPL.XLS. Heres a complete 
summary:

ReceiveDirect

Directs CWinA to begin to switch to Receive mode and copy a link to DDERecord to the 
clipboard. An application program can then establish a link to DDERecord using Paste 
Link. DDERecord will be updated with the contents of each new record as it is received 
from the Casio diary.

Format:
	ReceiveDirect

TransmitDirect

Directs CWinA to begin transmitting data as it is received over the DDE link. Single or 
multiple records can be transferred at once.

The source application is responsible for creating a data source DDE link or using DDE 
Poke to supply records.

A null record terminates the transmission.

Format:
	TransmitDirect[,link]

Parameters:

	link - optional link to application data in the format Application|topic!item

Abort

Aborts the current Receive or Transmit operation immediately.

Format:
	Abort

End

Directs CWinA to terminate operation and Exit.

Format:
	End

