11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

than a read operation that times out. A read timeout retains the new state of variable,including any characters input before the timeout occurred. If a READ command containsmultiple read operations, the interrupt affects only the read operation in progress. To commitor revert multiple read operations as a unit, use transaction processing.Reading from Non-Keyboard DevicesAs described earlier, READ can be used to acquire input from any character-oriented device.This includes devices such as magnetic tapes and sequential disk files, as well terminal keyboards.However, you must first establish the device to read from as the current device withthe OPEN and USE commands.With non-keyboard devices, you can use any of the three available forms (variable-length,single-character, and fixed-length). The choice of which form to use in any given case dependson the type of terminator available. With fixed-length READ, <strong>Caché</strong> treats terminatorsencountered within the input string the same as any other character.For example, if you are reading from a device that presents data in a line-oriented formatwith CARRIAGE RETURN/LINE FEED as the line terminator, you can use the variablelengthform. In this case, <strong>Caché</strong> reads each line into variable in its entirety, terminating inputonly when it reaches the Return (ASCII code 13) at the end of the line. (Remember, from theuser input examples shown previously, that is the input terminator.)On the other hand, if you are reading from a magnetic tape that presents records as a seriesof fixed-length fields, you would use the fixed-length (variable#n) form. For example, assumethat you have a mag tape that uses a record format consisting of four fields of up to 8, 12, 4,and 6 characters, respectively. You might use code similar to the following to read in thedata:READ field1#8,field2#12,field3#4,field4#6In this case, the #n value sets the input terminator for each field.READWhich terminator is used for a given device can be set by the device parameters that youspecify for that device on the OPEN or USE command.When reading block-oriented data from magnetic tape, the $ZB special variable contains thenumber of bytes remaining in the I/O buffer. Its function is entirely different than its usewhen reading character-oriented data. $ZB does not contain the read terminator character orthe last input character during block-oriented I/O. Refer to $ZB for further details.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 123

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

Saved successfully!

Ooh no, something went wrong!