I have been asking @David_Tschumperle in private a series of questions, using foo_* commands to help facilitate my learning. The last one might be of interest to you all. Perhaps you already have some idea or already solved this and can help me right away.
I am trying to learn how to apply : (no arg)
to my commands. It isn’t so easy. I took some cues from stdlib.gmic
to create this foo.
foo_noarg_:
l[]
if isnum("$1")
e[] "good"
skip ${1=0},${2=1},${3=0}
a=$1 b=$2 c=$3
else
e[] "bad"
if ["'$1'"]!=',' noarg fi
a=0 b=1 c=0
fi
onfail e[] "ugly" noarg a=0 b=1 c=0
endl
sp $a sp $b sp $c
Out of the commands below, only gmic foo_noarg_ q
works.
gmic foo_noarg_
gmic foo_noarg_ ,
gmic foo_noarg_ ,0
gmic foo_noarg_ q # Works (^_^)
gmic foo_noarg_ , q
gmic foo_noarg_ ,0 q