Skip to content

Commit

Permalink
create comarg.gsf
Browse files Browse the repository at this point in the history
  • Loading branch information
kodamail committed Feb 16, 2015
1 parent 7c2d187 commit 10b5176
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions comarg.gsf
@@ -0,0 +1,27 @@
* get value from standard command arguements
* target: string or number
function comarg( args, target )
ret = ''

cnt = 0
i = 1
while( 1 )
arg = subwrd( args, i )
if( arg = '' ) ; break ; endif

if( substr( arg, 1, 1 ) = '-' )
key = substr( arg, 2, math_strlen(arg)-1 )
i = i + 1
val = subwrd( args, i )
if( key = target ) ; ret = val ; endif

* say 'ok: ' % key % ' : ' % val
else
cnt = cnt + 1
val = arg
if( cnt = target ) ; ret = val ; endif
endif

i = i + 1
endwhile
return ret
1 change: 1 addition & 0 deletions zip.sh
Expand Up @@ -37,6 +37,7 @@ zip gscript.zip \
atoi.gsf \
chcase.gsf \
cmonth.gsf \
comarg.gsf \
color.gsf \
dayofyear.gsf \
days.gsf \
Expand Down

0 comments on commit 10b5176

Please sign in to comment.