From 8617da6779501a55711013395736908798a171da Mon Sep 17 00:00:00 2001 From: crc Date: Sat, 11 Nov 2017 03:09:16 +0000 Subject: [PATCH] continue work on the glossary tool FossilOrigin-Name: 9c3e69aa10132d8247a74d01c3e1fd52464bb2a244ad01cb8f9a78df9b6bee6b --- wip/glossary.forth | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/wip/glossary.forth b/wip/glossary.forth index f7f613a..6fc4827 100755 --- a/wip/glossary.forth +++ b/wip/glossary.forth @@ -111,6 +111,41 @@ examples, they will be displayed after the description. field:ex2 '{n/a} s:eq? [ field:ex2 s:with-format 'Example_#2:\n%s\n\n puts ] -if ; ~~~ +# Begin Processing + +This application can take a variable number of arguments. + +I first check to make sure at least one was passed. If not, just exit. + +~~~ +sys:argc n:zero? [ #0 unix:exit ] if +~~~ + +If execution reaches this point there's at least one argument. I use a +loop to store arguments into an array. + +~~~ +'Args d:create #32 allot +#0 sys:argc [ dup sys:argv s:keep over &Args + store n:inc ] times drop +~~~ + +And then populate constants for each one I care about. + +~~~ +#0 &Args + fetch 'QUERY s:const +#1 &Args + fetch 'TARGET s:const +#2 &Args + fetch 'TARGET2 s:const +~~~ + +FUTURE: + +:process-arguments + QUERY + 'help [ display-help ] s:case + 'describe [ find-and-display-entry ] s:case + 'export [ handle-exports ] s:case + 'edit [ handle-edits ] s:case + drop ; ---- @@ -133,10 +168,6 @@ assumes the first argument is the type of search and the second is name of a word, class, or other detail to search for. Grab them and save as `QUERY` and `TARGET`. -~~~ -#0 sys:argv 'QUERY s:const -#1 sys:argv 'TARGET s:const -~~~ The *words.tsv* has the following fields: