11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The following example opens a sequential file named Seqtest; the letter code positionalparameter is ”NRW”. The “N” letter code specifies that if the file does not exist, create a newsequential file with this name. The “R” and “W” letter codes specify that the file is beingopened for reading and writing. The timeout is 5 seconds.ZNSPACE "%SYS"SET dir=$ZUTIL(168) ; determine <strong>Caché</strong> directorySET seqfilename=dir_"Samples\Seqtest"OPEN seqfilename:("NRW"):5WRITE !,"Opened a sequential file named Seqtest"USE seqfilenameWRITE "a line of data for the sequential file"CLOSE seqfilename:"D"WRITE !,"Closed and deleted Seqtest"QUITNotesDevice Ownership and the Current DeviceOPEN establishes ownership of the specified device. The process retains ownership of thedevice until the process either terminates or releases the device with a subsequent CLOSEcommand. While a device is owned by a process, no other process can acquire or use thedevice.A process can own multiple devices at the same time. However, only one device can be thecurrent device. You establish an owned device as the current device with the USE command.The ID of the current device is found in the $IO special variable.A process always owns at least one device (designated as device 0), which is its principaldevice. This device is assigned to the process when it is started and is typically the terminalused to sign onto <strong>Caché</strong>. The ID of the principal device is found in the $PRINCIPAL specialvariable.When a process terminates, <strong>Caché</strong> issues an implicit CLOSE for each of the devices ownedby the process and returns them to the pool of available devices.Changing Parameters for an Owned DeviceTo change the parameters for a device that is already owned by the process, you can:• Close and then reopen the device• Specify the device on another OPEN command, but with new parameter values.OPENIf you specify the device on another OPEN command, any device parameters set by the initialOPEN command remain in effect unless explicitly changed. Depending on the type of device,subsequent I/O may be different than if you had closed and then reopened the device.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 105

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!