I'm trying to implement Java's System.out.println()
method in Progress ABL
.
The closest functionality seems to be:
test.p:
MESSAGE "hello world" SKIP.
I ran the following tests to see if it works:
Windows
FAIL C:\opt\prgs\dlc117\bin\prowin -b -p test.p
OK C:\opt\prgs\dlc117\bin\prowin -b -p test.p | % ToString
OK C:\opt\prgs\dlc117\bin\_progres -b -p test.p
OK C:\opt\prgs\dlc117\bin\_progres -b -p test.p | % ToString
Unix
TODO
So in the end, I'd implement it like this:
METHOD STATIC PUBLIC VOID println(i_cText AS CHAR):
MESSAGE i_cText SKIP.
PAUSE 0.
CATCH oError AS CLASS Progress.Lang.Error:
/* Suppress error because MESSAGE doesn't support NO-ERROR. */
END.
END.
I haven't found a way to know when the MESSAGE
will fail. I tried checking OPSYS
, TERMINAL
and SESSION:BATCH-MODE
but they are not reliable. I'd need to know if default output
exists but how?
AFIAK you always have to redirect in order to execute in batch. Your commandline without redirecting results in
---------------------------
Error
---------------------------
** Attempt to write with no current output destination. (516)
---------------------------
Once you redirect, code below will write to stdout.
put unformatted "put Hello world".
message "message Hello world".
display "display Hello world".
quit.
you can use | tee
on linux or | % ToString
in powershell
result
prowin.exe -b -p .\helloworld_stdout.p | % ToString
put Hello world
message Hello world
display Hello world