4D v14.3SET CHANNEL |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
SET CHANNEL
|
SET CHANNEL ( port ; settings ) | ||||||||
Parameter | Type | Description | ||||||
port | Longint |
![]() |
Serial port number | |||||
settings | Longint |
![]() |
Serial port settings | |||||
SET CHANNEL ( operation ; document ) | ||||||||
Parameter | Type | Description | ||||||
operation | Longint |
![]() |
Document operation to perform | |||||
document | String |
![]() |
Document name | |||||
The SET CHANNEL command opens a serial port or a document. You can open only one serial port or one document at a time with this command. To close an opened serial port, pass SET CHANNEL (11).
Historical Note: This command was originally the first 4D command used for working with serial ports and documents on disks. Since that time, new commands have been added. Today, you will typically work with documents on disk using the commands Open document, Create document and Append document. With these commands, you can read and write characters to and from documents using Create document or RECEIVE PACKET (these commands work with SET CHANNEL, too). However, if you want to use the commands SEND VARIABLE, RECEIVE VARIABLE, SEND RECORD and RECEIVE RECORD, you must use SET CHANNEL to access the document on disk.
The description of SET CHANNEL is composed of two sections:
The first form of the SET CHANNEL command opens a serial port, setting the protocol and other port information. Data can be sent with SEND PACKET, SEND RECORD or SEND VARIABLE, and received with RECEIVE BUFFER, RECEIVE PACKET, RECEIVE VARIABLE or RECEIVE RECORD.
The first parameter, port, selects the port and the protocol. You can address up to 99 serial ports (one at a time).Value for | Description |
0 | Printer port (Macintosh) or COM2 (PC) with no protocol |
1 | Modem port (Macintosh) or COM1 (PC) with no protocol |
20 | Printer port (Macintosh) or COM2 (PC) with sofware protocol such as XON/XOFF |
21 | Modem port (Macintosh) or COM1 (PC) with sofware protocol such as XON/XOFF |
30 | Printer port (Macintosh) or COM2 (PC) with hardware protocol such as RTS/CTS |
31 | Modem port (Macintosh) or COM1 (PC) with hardware protocol such as RTS/CTS |
101 to 199 | Serial communication with no protocol |
201 to 299 | Serial communication with software protocol such as XON/XOFF |
301 to 399 | Serial communication with hardware protocol such as RTS/CTS |
Important: The value you pass in port must refer to an existing serial COM port recognized by the operating system. For example, in order to be able to use the values 101, 103 and 125, the serial ports COM1, COM3 and COM25 must have been set up correctly.
In a standard configuration Mac OS and Windows support two serial ports: on Mac OS, the modem port and the printer port; on Windows, the COM1 and COM2 ports. However, additional serial ports can be added by the use of extension boards. Originally, 4D only adressed two standard serial ports and it was only later that the support of additional ports was implemented. For compatibility reasons, both addressing systems were kept.
If you want to use the printer/COM2 port with no protocol, you can use one of the following syntaxes:
SET CHANNEL(0;param)
or
SET CHANNEL(102;param)
If you want to use the modem/COM1 port with the XON/XOFF protocol, you can use one of the following syntaxes:
SET CHANNEL(21;param)
or
SET CHANNEL(201;param)
If you want to use the COM 25 port with the RTS/CTS protocol, you need to use the following syntax:
SET CHANNEL(325;param)
Value to accumulate | Description | |
in settings parameter | ||
Speed | 380 | 300 |
(in baud) | 189 | 600 |
94 | 1200 | |
62 | 1800 | |
46 | 2400 | |
30 | 3600 | |
22 | 4800 | |
14 | 7200 | |
10 | 9600 | |
4 | 19200 | |
2 | 28800 | |
1 | 38400 | |
0 | 57600 | |
1022 | 115200 | |
1021 | 230400 | |
Data bits | 0 | 5 |
2048 | 6 | |
1024 | 7 | |
3072 | 8 | |
Stop bits | 16384 | 1 |
–32768 | 1.5 | |
–16384 | 2 | |
Parity | 0 | None |
4096 | Odd | |
12288 | Even |
Tip: The various numeric values to be accumulated and passed in port and settings (but not including the values for COM1...COM99) are available as predefined constants in the theme Communications within the Design environment Explorer windows. For COM1...COM99, use numeric literals.
The second form of the SET CHANNEL command allows you to create, open, and close a document. Unlike the System Documents commands, it can open only one document at a time. The document can be read from or written to.
The operation parameter specifies the operation to be performed on the document specified by document. The following table lists the values of operation and the resulting operation with different values for document. The first column lists the allowed values for operation. The second column lists the allowed values for document. The third column lists the resulting operation.
For example, to display an Open File dialog box to open a text file, you would use the following line:
SET CHANNEL(13;"")
Operation | Document | Result |
10 | String | Opens the document specified by String. |
If the document doesn’t exist, the document is opened and created. | ||
10 | "" (empty string) | Displays the Open File dialog box to open a file. |
All file types are displayed. | ||
11 | none | Closes an open file. |
12 | "" (empty string) | Displays the Save File dialog box to create a new file. |
13 | "" (empty string) | Displays the Open File dialog box to open a file. Only text file types are displayed. |
All of the operations in this table set the Document system variable if appropriate. They also set the OK system variable to 1 if the operation was successful. Otherwise, the OK system variable is set to 0.
See examples for the commands RECEIVE BUFFER, SET TIMEOUT and RECEIVE RECORD.
Product: 4D
Theme: Communications
Number:
77
Created: < 4D v6
Append document
Communications
Create document
GET SERIAL PORT MAPPING
Open document
RECEIVE BUFFER
RECEIVE PACKET
RECEIVE RECORD
RECEIVE VARIABLE
SEND PACKET
SEND RECORD
SEND VARIABLE
SET TIMEOUT
4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)