/** * \brief Input Provider : Stream file * * This example shows how to create an input provider for a stream file * in the IFS and outputs the content of the stream file line by line. *

* The procedure getInputProvider returns the input provider for * the stream file /tmp/input-test.txt. *

* The main procedure does not need to know what implementation of input * provider it uses. It uses the interface service program RNGIN * and its procedures get the content regardless of the source. *

* After processing and displaying the data (in this case line by line) the * input provider gets closed and its resources freed. * * \author Mihael Schmidt * \date 15.01.2011 */ H dftactgrp(*no) actgrp(*caller) *------------------------------------------------------------------------- * PEP *------------------------------------------------------------------------- D main PR extpgm('RNGIN01') D main PI *------------------------------------------------------------------------- * Prototypes *------------------------------------------------------------------------- D getInputProvider... D PR * /include 'rng/input_provider_h.rpgle' /include 'rng/streamfile_input_provider_h.rpgle' *------------------------------------------------------------------------- * Varibables *------------------------------------------------------------------------- D input S * D data S 65535A varying D dsp S 50A D i S 10I 0 /free input = getInputProvider(); rng_input_open(input); dow (rng_input_read(input : data)); i += 1; dsp = %char(i) + ': ' + data; dsply dsp; enddo; rng_input_close(input); rng_input_finalize(input); *inlr = *on; return; /end-free /** * \brief Get input provider * * Returns the input provider. * * \return Input provider for stream file * * \info The calling program must take care of freeing the resources * of the input provider by calling rng_input_finalize. Prior to * freeing the resources the input provider must be closed, see * rng_input_close. */ P getInputProvider... P B D PI * * D inputPath S 100A /free inputPath = '/tmp/input-test.txt' + x'00'; return rng_input_stmf_create(%addr(inputPath)); /end-free P E