SET INPUT
Documentation | Blog | Demos | Support
SET INPUT
4.8 out of 5 stars
2 ratings
5 Stars | 50% | |
4 Stars | 50% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |
Specifies the current input document.
Syntax
SET INPUT docname [FILEPATH options]
Parameters
docname | The 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 options | Specifies 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; pipe://<OS command> – executes the OS command. |
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
Executes an OS command and captures its output (i. e. STDOUT).
% In this case, data is formatted. % You can add the lines directly but you need to filter the useful ones. set input MyDoc filepath "pipe://dir ..\\Images\\*.jpg" list all MyDoc Directory: C:\users\cebre\pictures Mode LastWriteTime Length Name ------ ----------------- ------- ------------------- -a---- 21-Oct-2023 09:45 2885941 20200827_114259.jpg -a---- 21-Oct-2023 09:42 2555772 20200827_114311.jpg set input terminal
4.8 out of 5 stars
2 ratings
5 Stars | 50% | |
4 Stars | 50% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |