printing out min,max,mean value of a picture

Maybe an example is worth a thousands words:
Define this function in file foo.gmic:

foo : 
   echo "First comment\n"
   echo[^-1] "Second comment\n"
   echo[] "Third comment\n"
   echo_stdout "Fourth comment\n"

Then try this from the console:

$ gmic foo.gmic foo
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input custom command file 'foo.gmic' (1 new, total: 3135).
[gmic]-0./foo/ First comment

[gmic]-0./ Second comment

Third comment
Fourth comment


[gmic]-0./ End G'MIC interpreter.

Another try, with redirection of stdout to a file:

$ gmic foo.gmic foo >stdout.txt
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input custom command file 'foo.gmic' (1 new, total: 3135).
[gmic]-0./foo/ First comment

[gmic]-0./ Second comment

Third comment

[gmic]-0./ End G'MIC interpreter.

$ cat stdout.txt 
Fourth comment