CMDLINE.TEST

From Pickwiki
Jump to navigationJump to search

HomePage>>SourceCode>>BasicSource>>CMDLINE.TEST

Test routine for PARSE.CMDLINE

* ============================== CMDLINE.TEST ==================================
* @TCL: Test and demonstrate the use of PARSE.CMDLINE.
* ==============================================================================
* 30-Aug-2005 jra: OPTIONS parameter added to PARSE.CMDLINE
* 04-May-2005 jra: Add more info to display.
* ??/??/2004 jra: see PARSE.CMDLINE for more info
* ==============================================================================

  $include RMS.BP EQU.CMDLINE

  print
  print "For more info: http://trac.docmagic.com/dsi/wiki/ParseCmdLine"
  print
  print "Options? (ex: 'LONGFLAGS'; 'SINGLEPARAM' [commas OK] ):": ; input OPTIONS

  convert ',' to @FM in OPTIONS
  call PARSE.CMDLINE(@SENTENCE, mat CMDLINE, OPTIONS)

  print "SENTENCE: ":@SENTENCE
  print
  print "CMD.VERB: ":CMD.VERB
  print "CMD.HELP: ":CMD.HELP
  print
  print " --- Args are all arguments before any Flags or Options:"
  print
  print "CMD.NUM.ARGS:":CMD.NUM.ARGS
  print
  FOR N.A = 1 TO CMD.NUM.ARGS
    print "CMD.ARG.S<1,":N.A:">: ":CMD.ARG.S<1,N.A>
  NEXT N.A
  print
  print " --- Flags are anything following '-'s; each has a list of Params :"
  print
  print "CMD.NUM.FLAGS:":CMD.NUM.FLAGS
  print
  FOR N.F = 1 TO CMD.NUM.FLAGS
    print "CMD.FLAG.S<1,":N.F:">: ":CMD.FLAG.S<1,N.F>:"  CMD.PARAM.S<1,":N.F:",1>: ":CMD.PARAM.S<1,N.F,1>
    NUM.PARAMS = DCOUNT(CMD.PARAM.S<1,N.F>, @SVM)
    FOR N.P = 2 TO NUM.PARAMS
      print "                    CMD.PARAM.S<1,":N.F:",":N.P:">: ":CMD.PARAM.S<1,N.F,N.P>
    NEXT N.P
    print
  NEXT N.F
  print " --- Options are anything after '(':"
  print "   [ except S,N,P,I,A,E,H: these are converted to NO.WARN,NOPAGE, etc.]"
  print
  print "CMD.NUM.OPTIONS:":CMD.NUM.OPTIONS
  print
  FOR N.O = 1 TO CMD.NUM.OPTIONS
    print "CMD.OPTION.S<1,":N.O:">: ":CMD.OPTION.S<1,N.O>
  NEXT N.O
  print
 stop