Chapter 3: Caché 3.2.1 Enhancements

Table of Contents | Chapter 1 | Chapter 2 | Chapter 4
Chapters 1 and 2 describe the enhancements introduced in Version 3.2.0 of Caché. This chapter focusses on the enhancements in Version 3.2.1. Note that everything in Chapters 1 and 2 are also available in Caché 3.2.1.

Windows 2000 Support

A major enhancement feature of Caché 3.2.1 is full support for Windows 2000 computers. Windows 2000 machines can therefore be used as Caché database servers, Caché development platforms, Caché clients, and so forth.
Note: The Caché for Windows 2000 product does not currently support raw Ethernet-based networking (e.g. DDP or LAT). A new packet driver will be available sometime in the future on the InterSystems Web site which will allow these protocols to run.

New SQL Functions

Caché SQL now supports the following functions: For details on syntax and usage, see the Caché SQL Reference.

Change to Unique and PrimaryKey Indices

In Caché 3.2.1, the default index TYPE for Unique and PrimaryKey indices has changed from KEY to INDEX. If you have indices defined as Unique or PrimaryKey, you must either rebuild the index or change the index definition, as described in the next chapter.

The new index structure for Unique and PrimaryKey indices is better for three reasons:

Note that if the TYPE of an index is not defined, the default type of INDEX is used. Prior to Caché 3.2.1, KEY was the default TYPE for indices defined as Unique or PrimaryKey.

SQL Foreign Key Referential Actions

Caché SQL now properly supports all Foreign Key referential action. A Foreign Key definition may contain either or both of these referential action clauses:
ON DELETE <ref-action>

ON UPDATE <ref-action>

where ref-action is one of the following: Note that prior to this change, all Foreign Keys behaved as thought they were using an update and deletereferential action of NO ACTION.

The following example uses both referential action clauses:

CREATE TABLE Patient (
        PatID               VARCHAR(16),
        Name                VARCHAR(30),
        DOB                 DATE,
        Primary_Physician   VARCHAR(16) DEFAULT 'A10001982321',
        CONSTRAINT Patient_PK PRIMARY KEY (PatID),
        CONSTRAINT Patient_Physician_FK FOREIGN KEY
          Primary_Physician REFERENCES Physician (PatID)
          ON UPDATE CASCADE
          ON DELETE SET NULL
        )

These referential action clauses can be used anywhere you can define a Foreign Key constraint, such as a CREATE TABLE statement. For details on syntax and usage, see the Caché SQL Reference.

Physical Cursor Addressing for CHARWIN

As part of Caché's ongoing support for wide characters, physical cursor addressing mode has been implemented for CHARWIN. %CHARWIN and %XDTM2 now have both physical and logical cursor addressing modes for dealing with wide characters that must operate in tandem with the Caché Terminal.

Physical cursor addressing mode is the preferred method of dealing with wide characters such as Japanese and Korean (Hangul). When initializing CHARWIN, you must issue the command:

WRITE /INIT("Cache Terminal Wide Characters")
In addition, make sure that:

In physical cursor addressing mode, coordinates in /CUP, /WOPEN, etc, represent physical (i.e., narrow) cells. Therefore, it is possible to overwrite just half of a wide character either with a narrow character or part of another wide character. When this happens, the other half of the wide character is turned into a blank.

Note: As part of implementing physical cursor addressing mode, the "Cache Terminal Wide Characters" terminal type was added to ^mtercap.
Logical cursor addressing mode can be used only when physical cursor addressing is disabled in the Caché Configuration Manager (i.e., "Physical Cursor Positioning" must be set to No). In addition, you must specify a character pitch with:
WRITE /PITCH(n)
where n is 1.25, 1.5, 1.75 or 2 and specifies how large a wide character is in relation to a narrow character. To open windows, the background must contain only narrow characters. Otherwise the window borders will be misaligned.

Collation Number Change for Japanese Table

In Caché 3.2.0, the Japanese1 collation table was incorrectly given collation number 21. Because number 21 belongs to the Finnish1 collation table, the Japanese1 collation table now has collation number 22.

Spooling Device Now Correctly Updating $X/$Y Table

The spooling device now calculates $X/$Y by taking three values into account: Therefore, you must set the spooler device pitch with the same value as the printer pitch.

The pitch is the width of wide characters as compared with normal width characters. Its value can be:

To set the pitch of the current device, use:
$ZU(86,17,1,value)
where value is one of the above values.

For example, to generate a spool to be printed on a device that outputs Kanji Zenkaku (wide) characters so that they are twice as wide as ASCII characters, you would execute:

Open 2 ; open spooler
Use 2 Set oldpitch=$ZU(96,17,1,8)
; your code goes here
Close 2
When writing code, please keep in mind that something like:
If $X+$L(string)>132 ...
does not work if the characters have different widths.

In Japanese, for instance, there are Zenkaku (wide) and Hankaku (narrow) characters. $Length still returns the number of characters in the string, but $X is updated according to their widths. For example, if Zenkaku characters are twice as wide as the Hankaku ones, outputing a Zenkaku will increase $X by 2. If you are working in such a locale, it is advisable to use $ZWIDTH() in place of $LENGTH(). $ZWIDTH() will return the effective width of the string on the current device. It takes into account the $X/$Y table and the device pitch.

COM Port Section in Configuration Manager

As part of the COM port enhancements, the Caché Configuration Manager has been enhanced with a ComPorts section, in the Advanced->Startup->Terminal panel. You can now add, modify, activate, and delete COM port definitions.

COM Port Enhancements

The Caché COM port interface has been enhanced for the Windows NT platform. The enhanced interface consists of a COM port definition table in the configuration (.cpf) file, a new COM port server utility, and enhancements to the OPEN and USE commands and the $ZA special variable for COM ports.

New OPEN and USE Parameters

Two additional parameters have been added to the OPEN and USE commands for COM ports on Windows NT. The syntaxes for the new parameters are:
OPEN port:(:::"portstate":baudrate)
USE port:(:::"portstate":baudrate)
The portstate parameter modifies the COM port state as follows (byte position is one-based):

Table 3-1: Portstate Parameter
Byte
Command
Value
Meaning
1
Disconnect 'D'
' '
Disconnect (hang up) the port
Do not disconnect the port
2
Modem Control '1'
'0'
' '
Use modem control
Do not use modem control
No change to modem control
3
Data Bits '5'
'6'
'7'
'8'
' '
5 data bits
6 data bits
7 data bits
8 data bits
No change to bit size
4
Parity '0'
'1'
'2'
'3'
'4'
' '
No parity
Odd parity
Even parity
Mark parity
Space parity
No change to parity size
5
Stop Bits '1'
'5'
'2'
' '
1 stop bit
1.5 stop bits
2 stop bits
No change to stop bit setting
6
Flow Control 'X'
'C'
'D'
' '
Use Xon/Xoff flow control
Use CTS/RTS flow control
Use DSR/DTR flow control
No change to flow control
7
DTR '0'
'1'
' '
Disable DTR (set it off, keep it off)
Enable DTR (set it on, keep it on)
No change to DTR state
8
$ZA Error Reporting '0'
'1'
'2'
' '
Disable $ZA error reporting (default).
Enable $ZA error reporting.
No change to $ZA error reporting.

baudrate is the desired baud rate. The following baud rates are supported (if the hardware permits):

An alternate way of changing the parameters settings, issuing a disconnect, or changing the baud rate is by using the /COMPARAMS, /DISCONNECT, or /BAUD keywords on the USE command. The syntax is:
USE port:/COMPARAMS="portstate"
USE port:/DISCONNECT
USE port:/BAUD=baudrate
The values for portstate and baudrate are the same as above.

For both syntaxes, the Disconnect parameter performs a hangup on modem-controlled ports by lowering the DTR signal for two seconds and then restoring it. The Disconnect does not close the port. The program can dial out again without reopening the COM device.

The Modem Control parameter determines how Caché responds to the state of the RLSD (received line signal detector) pin, which is also known as DCD (data carrier detect). If the line is modem controlled, the state of RLSD is monitored by Caché and an error is generated if a READ command is issued when carrier is not present. A WRITE command does not receive an error when carrier is not present because it must be possible to send the dial command to the modem prior to a connection being established. Caché Modem control checking can be enabled or disabled at any time. It is suggested you turn modem control off while sending commands to the modem and turn it on once carrier is detected and connection has been established.

The DTR Setting option can be used to control login from an attached modem. If the DTR Setting is configured as 0 (zero), then the DTR control signal will be off, and modems will not communicate with the computer. This will prevent a dial-in connection from occurring. If the DTR setting is configured as 1 (one), then the DTR control signal will be on, and modems will communicate with the computer. In this case, dial-in can occur. If you configure DTR off, then you must programmatically set DTR with the OPEN or USE command to be able to dial out using a connected modem. The DTR setting is probably unimportant when using a null modem cable to connect directly to a terminal device or serial printer because the null modem cable should force the DTR control pin on.

Testing the Status with $ZA

The status of modem control pins can be tested using the $ZA device special variable. This can be done regardless of whether Caché modem control checking is on or off for the port. The relevant $ZA values are shown below (bit positions are zero based):

State
$ZA Bit
$ZA Test
Notes
MS_CTS_ON
12
$za\4096#2 CTS set if TRUE.
MS_DSR_ON
13
$za\8192#2 DSR set if TRUE.
MS_RING_ON
14
$za\16384#2 Ring set if TRUE.
MS_RLSD_ON
15
$za\32768#2 Carrier detect set if TRUE.
CACHE_DTR
24 & 25
$za\16777216#4 Cache requested DTR setting:
0 DTR off
1 DTR on
2 DTR handshaking

If $ZA error reporting is enabled, Comm port errors will be cleared with a call to the Windows ClearCommError() function. The port error state will be reported as follows:

State
$ZA Bit
$ZA Test
Notes
CE_BREAK
16
$za\65536#2  
CE_FRAME
17
$za\131072#2  
CE_IOE
18
$za\262144#2  
CE_OVERRUN
19
$za\524288#2  
CE_RXPARITY
20
$za\1048576#2  
CE_TXFULL
21
$za\2097152#2  
TXHOLD
22
$za\4194304#2 Set if any of the following fields are true in the error mask returned by ClearCommError():
fCtsHold
FDsrHold
FRlsdHold
FXoffHold
fXoffSent

COM Port Definition Section in Configuration File

The Caché COM port server process manages COM ports for a configuration. A table of port settings is read from the configuration .cpf file. These ports are opened by the COM server, the ports are initialized to the settings in the table, and gatekeeper threads are created to manage the port. Whenever a process issues an OPEN command on a port managed by the COM port server, the server relinquishes control of the port and monitors the opening process. When the port is closed, the COM server is notified and the regains control of the port. When control returns to the COM server, the settings established by the .cpf file are restored.

If input appears at an unowned COM port or if RLSD becomes active on an unowned, modem controlled, COM port, the COM server logs in a new Caché process with the COM port as its principal I/O device. How the process starts up (programmer or application mode, namespace, routine name) is determined by the settings for that COM port established in the Caché Control Panel in the Security, User Accounts section. The format is similar to the way LAT and TELNET ports are tied to a routine. Creating an entry for COM2: will direct logins on port COM2. Creating an entry for COM: will direct logins on all COM ports for which no specific entry exists.

The format of the COM section of the .cpf file is as follows:

[Com]
Com=ON
COM1:=1801X11;19200
...
COMnn:=1801X11;19200
The Com=[ON/OFF] line determines if the COM server process is created when the configuration starts up. The COMn:=params;baud lines define the set of ports controlled by the COM server and their parameter settings. The first ";" piece of the parameters ("1801X11" in the above example) is of the same format as parameters argument to the OPEN and USE commands for COM ports, except that first byte of the OPEN command parameter string (disconnect) is not present in the .cpf file parameter. The second ";" piece ("19200" in the example) is the baud rate.

Note that the size of the COM port table is determined by the ttysiz=n,m parameter in the [config] section of the cache.cpf file. The first (n) part ot the ttysiz parameter is the size of the tty table in bytes. The second (m) part of the ttysiz parameter is the number of entries to allocate space for in the COM port table. This parameter can be modified in the Advanced tab of the Caché Configuration Manager by opening the Memory section item and editing the "TTY Name Table" entry.

COM Port Server Utility

The following user-callable functions are available in the ^COMMCTRL utility.

info^COMMCTRL

The info^COMMCTRL function shows COM port control information, as in this example:
%SYS> d info^COMMCTRL

configured table size = 2
entries in table = 2
ports in table = COM1:,COM2:,
controller PID = 44

update^COMMCTRL

The update^COMMCTRL function updates the COM port control process tables. Call this function after modifying the [COM] section of the cache.cpf file outside the Caché Configuration Manager.

shutdown^COMMCTRL

The shutdown^COMMCTRL function sends a message to the COM port control process telling it to shut down. The controller will have to be restarted (job START^COMMCTRL) or the configuration will have to be restarted in order for COM control functionality to be restored.

purge^COMMCTRL

The purge^COMMCTRL function deletes all COM port control table entries in the active database. This will disable logins. Running update^COMMCTRL will restore the entries.

Sample COM Port Routine

The following .INT routine includes the dial subroutine, which shows how to dial out (with lots of debug output). Also included is the showza subroutine that formats and displays $ZA.

ComDemo ;;02:23 PM  16 Feb 2000
COMDEMO ;Demo COM port enhancements.
        ;
        q
        ;
dial(n,number) ;
        ;Dial out on a modem.
        ;Includes debugging information display.
        ;Presumes your modem is set to echo control strings.
        ;Usage:  s port=$$dial(2,"5551234") ;call 555-1234 on COM2:
        ;Return value is "COM"_n_":" on success, "" on failure.
        u 0 w !,"testing dialout"
        s port="COM"_n_":"
        o port:(:"S"):10 e  u 0 w !,"Could not open port ",port c port q ""
        u port:(:"S"::" 0    11":9600) f i=1:1 r x:.2 e  q  ;discard any pending input.
        u 0 w !,"Modem control reset and DTR raised.",!,"Any residual input from previous sessions discarded"
        u port d showza(port,$za) ;show modem state.
        u 0 w !,"Resetting modem."
        u port:(:"S") w "ATZ",*13 r echo:3 e  u 0 w !,"no response to ATZ command" c port q ""
        r x,x,ok,y,y:1 s t1=$t i ok'="OK" u 0 w !,"OK not received following ATZ" c port q ""
        u 0 w " ",ok
        u 0 w !,"Dialing:  ATDT",number
        u port:(:"S") w "ATDT",number,*13 r echo:3 e  u 0 w !,"no echo to dial string" c port q ""
        r x,x ;get cr/lf
        r reply u 0 w " reply from modem:  ",reply
        i reply'?1"CONNECT".E c port q ""
        u 0 w !,"Setting COM port to modem control."
        u port:(:"S"::" 1")
        s connect=0 f i=1:1:4 d  q:connect  ;Wait for carrier detect.
        .u port:(:"S") s za=$za
        .u 0 w !,i,! d showza(port,za)
        .i za\32768#2 s connect=1 q
        .h 1
        .q
        i 'connect u 0 w !,"Not connected" c port q ""
        q port
        ;
showza(port,za) ;This formats and displays the value of $ZA (already obtained) for the port.
        n (port,za)
        u 0 w !,"$za for ",port," is ",za
        W !,"Modem Status:"
        w !,?5,"CTS = ",za\4096#2
        w !,?5,"DSR = ",za\8192#2
        w !,?5,"RING = ",za\16384#2
        w !,?5,"RLSD = ",za\32768#2
        s dtr=za\16777216#4
        w !,?5,"DTR = "
        w $s(dtr=0:"Off",dtr=1:"On",dtr=2:"DTR Handshaking enabled",1:"Invalid")," (Cache setting)"
        i za\65536=0 q
        W !,"Error status:"
        w !,?5,"BREAK = ",za\65536#2
        w !,?5,"FRAME = ",za\131072#2
        w !,?5,"IOE = ",za\262144#2
        w !,?5,"OVERRUN = ",za\524288#2
        w !,?5,"RXPARITY = ",za\1048576#2
        w !,?5,"TXFULL = ",za\2097152#2
        w !,?5,"TXHOLD = ",za\4194304#2
        q
        ;
        ;

Table of Contents | Chapter 1 | Chapter 2 | Chapter 4
Top of Page