From: Rony G. F. <Ron...@wu...> - 2022-06-12 10:47:24
|
Hi Mike, sorry a glitch in the demo code that would not check for an asterisk in the first column, here the corrected (hypothetical and untested code sample: command='pipe console | sort | console' -- intensions: read from the console, sort, output to console arrIn =.array~of("Max", "und", "Moritz", "diese", "beiden", "konnt", "...") arrOut=.array~new -- command gets input from ooRexx' arrIn, places stdout into arrOut ADDRESS SYSTEM command WITH INPUT USING (arrIn) OUTPUT USING (arrOut) -- now we need to postprocess the data received from the NetRexx pipe -- assuming that each line is in the form of "varName=varValue", -- lines that start with an asterisk (*) get ignored -- create a directory of varName/varValue entries dir=.directory~new do line over arrOut -- process output of pipe line by line *if left(line,1)="*" then iterate -- ignore lines starting with an asterisk* parse var line varName '=' varValue dir~setentry(varName,varValue) -- setentry will uppercase the index varName automatically end -- now you decide what do to with the directory: use it to set Rexx variables in the current -- context (in this very section of the code) or maybe return it to a caller who could use -- the directory to set variables in its context -- call BsfSetContextVariable("set",dir) -- will set the Rexx variable using dir -- or: --return dir -- will return the directory to the caller And an additional remark: if it is possible from NetRexx to call external programs in pipes, then you could always inject ooRexx filters that read from stdin and write to stdout as demonstrated in the above code. HTH, ---rony |