SET INPUT

SET INPUT

Welcome to our Knowledge Base

Documentation | Blog | Demos | Support

< All Topics
Print

SET INPUT

Specifies the current input document.

Syntax

SET INPUT docname [FILEPATH options]

Parameters

docnameThe name of the application document to which all output is to be sent. Can also be one of the two pre-defined application documents, terminal or printer.
FILEPATH optionsSpecifies that the input document will be governed by the options as follows:file://<the full path of a text file> – subsequent ZIM statements referring to the docname above will read this physical file instead;

port://name:speed:bits:parity:stopbits:CTS – It only works for Linux environments and specifies a serial port to be read;

connector://port:IP address – reads from the specified IP address (or URL) using that port number.

Comments

The SET INPUT defines an input for subsequent Zim commands referring to the defined docname. The input is maintained open until it is explicitly closed by a SET INPUT TERMINAL or another document name.

Usually, the docname is defined as structured with a big field (big enough for the required application) so that the contents of the records read can be processed.

Example

set input MyDoc
list 1 MyDoc
compute 1 MyDoc evaluate (let MyVariable = MyDocField)
... process MyVariable ...
list 1 MyDoc
set input terminal

The above example is very useful as it allows continuous records to be read from MyDoc without starting from its beginning all the time. The first record of MyDoc is listed, the second is processed, while the third is again listed. Finally, the document is closed.

The next example shows the combination of INPUT and OUTPUT documents. The output is MyReport. All records from FirstFile.txt are listed in the output. Then, 20 records from Zimprof are listed. Next, 10 records from SecondFile.txt are listed and, finally, all records from AnotherDoc are also listed. To wrap up, both INPUT and OUTPUT are closed by assigning them to TERMINAL.

set out MyReport
set input MyDoc filepath "file://c:\\myDir\\FirstFile.txt"
list all MyDoc
list 20 zimprof
set input MyDoc filepath "file://c:\\myDir\\SecondFile.txt"
list 10 MyDoc
list all AnotherDoc
set input terminal
set output terminal

This example reads and processes all input arriving from a serial port (only for Linux).

set input MyDoc filepath "port:///dev/tty99:115200:8:N:1:N"
while ...
   compute 1 MyDoc evaluate (let MyVariable = MyDocField)
   ... process MyVariable ...
endwhile
set input terminal
Was this article helpful?
4.5 out of 5 stars

1 rating

5 Stars 0%
4 Stars 100%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_CAEnglish