|  |     The problem seems to be with f$extract.  F$extract wants to look
    like this:
    
    	str = f$extract(starting_point,#of_character_to extract,string)
    
    Here's a quick hack that sort of works, so you can fool arouns with
    it until you get just what you want.
    
    
                   <<< CLOSET::SYS_:[NOTES$LIBRARY]HACKERS.NOTE;1 >>>
                         -<  -={ H A C K E R S }=-  >-
================================================================================
Note 334.0  requesting help on DCL /qualifiers in command procedure   No replies
THEBUS::KOSTAS "Wisdom is the child of experience."  61 lines  16-OCT-1986 09:38
--------------------------------------------------------------------------------
Hello,
     I have include this problem in here because I think that you may
  be able to help.
  The problem is this:
     1.  A command procedure is executed.
     2.  Check for the command 
     3.  Check for the qualifier
     4.     If qualifier takes an argument then extract the argument
            into a string.
     5.  Goto step 3 until no more qualifiers
  How can I do this is DCL?
-------------------------------cut here-------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$!  File: t0.com
$!
$!  Here is an attempt that does not work.
$!  
$!  Given the string str we want to store in the string log_str
$!  the value specified by the /log= qualifier (i.e. "log.file")
$!  in this example. Now all qualifiers are optional, which means 
$!  that they may appear or may not.
$!  
$ str = "abcdefg /log=log.file /verify"
$ str = f$edit(str,"COLLAPSE")
$ str_len = f$length(str)
$ l1 = f$locate("/",str)                !end of command
$ command = f$extract(0,l1,str)		! Have the first part here
$!
$ write sys$output "Command is  ''command'"
$!
$ start_pluck=l1+1
$!
$! Now get the next qualifier (log)
$!
$ rest_of_str = f$extract(start_pluck,99999,str)
$!
$ l2 = f$locate("/",rest_of_str)
$ if f$length(l2) .eq. 0 then goto done	! if there is not a qualifier
$ log_str = f$extract(0,l2,rest_of_str)
$ write sys$output "  l1=''l1', l2=''l2'"
$!
$ l3 = l2+1				! verify part
$!
$ ver_str = f$extract(l3,9999,rest_of_str)	! Assume only 2 qualifiers
$!
$! With the HA / / / / / / / you'd have to check for the slash
$!
$! log_str = f$extract( l1+f$length("/LOG="), l2, str)
$ log_str_len = f$length(log_str)
$ write sys$output "  str = ''str', length=''str_len'"
$ write sys$output "  log_str = ''log_str', length=''log_str_len'"
$ write sys$output " Verify string =  ''ver_str'"
$! show symbol str
$! show symbol log_str
$!
$done:
$! execute command with qualfiers??
$!
$!When I execute t0.com I get:
$!
$!  l1=7, l2=20
$!  str = abcdefg/log=log.file/verify, length=27
$!  log_str = log.file/verify, length=15
$!  STR = "abcdefg/log=log.file/verify"
$!  LOG_STR = "log.file/verify"
$!
$!!!!!!!!!!!
$!Some more examples to try the new version of t0.com with for 
$!the value of str.
$!
$!   Let str be:
$!
$!     1.   $ str = "abcdefg /log=log.file /verify"
$!     2.   $ str = "PURGE /nolog /since=today"
$!     3.   $ str = "DIR /log=mydir.log "
$!     4.   $ str = "HA / / / / "
$!     5.   $ str = "delete/log=/mydir./log "
$!
$!Thanks,
$!
$!Kostas G.
    
 | 
|  | This is a slightly better version (in my humble opinion)
These are valid in this version:
	$ MYCMD
	$ MYCMD QUAL1
	$ MYCMD /QUAL1/QUAL2
These are not valid yet because only "/" is used to separate qualifiers.
	$ MYCMD PARAM1 PARAM2
	$ MYCMD PARAM1/QUAL1/QUAL2 PARAM2/QUAL3/QUAL4
The symbol MYCMD must be defined like this:
	$ MYCMD == "@MYCMD PARSE"
This is to avoid DCL's anoying habit of disallowing $ @MYCMD /QUAL
				     while allowing $ @MYCMD PARSE /QUAL
Good Luck.
$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 'f$verify(0)'
$!  File: PARSE.COM
$!
$  say := write sys$output
$  ask := read /end=exit/error=exit sys$command answer /prompt= 
$ 
$  if P1 .eqs. "PARSE" then goto PARSE
$  name = f$environment("PROCEDURE") 
$  name = f$extract(0,f$locate(";",name)-4,name)
$  fnam = f$parse(name,,,"NAME","SYNTAX_ONLY")
$  'fnam' == "@" + fnam + " PARSE"
$  say ""
$  say "Type "
$  say "    $ ",fnam
$  say " or $ ",'fnam'
$  say ""
$ exit
$
$Parse: 
$  cmd = P2 + P3 + P4 + P5 + P6 + P7 + P8
$  cmd = f$edit( cmd ,"COLLAPSE,TRIM,UPCASE")
$  cmd_len = f$length(cmd)
$  nbr = 0
$ if f$lenght(cmd) .eq. 0 then goto No_More_Qualifiers
$Get_Qualifiers_Loop:
$  tmp = f$element(nbr,"/",cmd)
$  if tmp .eqs. "/" then goto No_More_Qualifiers
$  nbr = nbr + 1
$  qual'nbr' = tmp
$ goto Get_Qualifiers_Loop
$
$No_More_Qualifiers:
$
$
$  say "Command is  ",cmd
$!
$ if nbr .gt. 0 then goto There_Are_Qualifiers
$  say "There are NO qualifiers."
$ goto Exit
$
$There_Are_Qualifiers:
$ if nbr .eq. 1 then say "There is 1 qualifier."
$ if nbr .gt. 1 then say "There are ''nbr' qualifiers."
$
$  cnt = 1
$Show_Loop:
$  tmp = Qual'cnt'				! get the qualifier
$  tmp := 'tmp					! make it an ASCII string
$  say f$fao("Qualifier !2UB = '!AS'", cnt, tmp)! show it
$  cnt = cnt + 1
$ if cnt .le. nbr then goto Show_Loop
$
$Exit:
$  say ""
$  exit
$! execute command with qualfiers
$!
$!
$!     1.   $ cmd = "
$!     2.   $ cmd = "PURGE /nolog /since=today"
$!     3.   $ cmd = "DIR /log=mydir.log "
$!     4.   $ cmd = "HA / / / / "
$!     5.   $ cmd = "delete/log=/mydir./log "
$!
$!------------------------------------------------------------------------------
$!
$!  define symbol     $ TEST == "@MYPROCEDURE PARSE"
$!
$!  use:
$!
$!   $ TEST ABCDEFG/LOG=LOG.FILE/VERIFY
$!   Command is 'ABCDEFG/LOG=LOG.FILE/VERIFY'
$!   There are  3 qualifiers
$!   Qualifier  1 is 'ABCDEFG'
$!   Qualifier  2 is 'LOG=LOG.FILE'
$!   Qualifier  3 is 'VERIFY'
$!   $
$!   $ TEST 
$!   Command is ''
$!   There are NO qualifiers.
$!   $
$!   $
$!   $ TEST ABC/DEF
$!   Command is 'ABC/DEF'
$!   There are  2 qualifiers
$!   Qualifier  1 is 'ABC'
$!   Qualifier  2 is 'DEF'
$!   $
$!   $
$!   $ TEST /ABC
$!   Command is '/ABC'
$!   There are  2 qualifiers
$!   Qualifier  1 is ''
$!   Qualifier  2 is 'ABC'
$!
$! TEST_PARSE.COM
$!
$!  use by  $ @TEST_PARSE
$!
$ test = "@PARSE PARSE"
$
$ test abcdefg /log=log.file /verify
$
$ test PURGE /nolog /since=today
$
$ test DIR /log=mydir.log
$
$ test HA / / / /
$
$ test delete/log=/mydir./log
$ 
$!
 | 
|  | Here is a version that parses both parameters (up to 8) and qualifiers.
Values are returned in symbols
Parameter_count = number of parameters
P01	= parameter 1
P02	= parameter 2
P01Q_CNT = # of qualifiers on parameter 1
P02Q_CNT = # of qualifiers on parameter 1
P01Q01	= Qualifier 1 on param 1
P01Q02	= Qualifier 2 on param 1
P02Q01	= Qualifier 1 on param 2
P02Q02	= Qualifier 2 on param 2
$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! f$verify(0)
$!  File: PARSE.COM
$!  V1.2
$!
$  say := write sys$output
$  ask := read /end=exit/error=exit sys$command answer /prompt= 
$  fix2:= call FIX2
$  if P1 .eqs. "PARSE" then goto PARSE
$  name = f$environment("PROCEDURE") 
$  name = f$extract(0,f$locate(";",name)-4,name)
$  fnam = f$parse(name,,,"NAME","SYNTAX_ONLY")
$  'fnam' == "@" + fnam + " PARSE"
$  say ""
$  say "Type "
$  say "    $ ",fnam
$  say " or $ ",'fnam'
$  say ""
$ exit
$
$Parse: 
$  cmd = "''P2' ''P3' ''P4' ''P5' ''P6' ''P7' ''P8'"
$  cmd = f$edit( cmd ,"COMPRESS,TRIM,UPCASE")
$Remove_Unwanted_Spaces:
$  tmp = f$locate(" /",cmd)
$  if tmp .eq. f$len(cmd) then goto No_Unwanted_Spaces
$  cmd = f$extract(0,tmp,cmd) + f$extract(tmp+1,f$length(cmd)-tmp-1,cmd)
$ goto Remove_Unwanted_Spaces
$
$No_Unwanted_Spaces:
$
$  Q_CNT = 0	! number of command qualifiers
$  P_CNT = 0	! number of parameters
$  C_CNT = 0	! 0 if no command qualifiers 1 if there are
$
$ if f$length(cmd) .eq. 0 then goto No_More_Parameters
$
$Get_Parameters_Loop:
$  tmp_cnt = P_CNT + 1
$  FIX2 'tmp_cnt'
$  tmp = f$element( P_CNT , " " , cmd )
$  if tmp .eqs. ""  then goto No_More_Parameters
$  if tmp .eqs. " " then goto No_More_Parameters
$  P_CNT = tmp_cnt
$  slash = f$locate("/",tmp)
$  P'nbr' = f$extract(0,slash,tmp)
$  if slash .eq. 0 .and. nbr .eq. 1 then C_CNT = 1
$  qual'nbr' = tmp - P'nbr' - "/"
$  qual = qual'nbr'
$  p_nbr = nbr
$  gosub Get_Qualifiers
$goto Get_Parameters_Loop
$
$No_More_Parameters:
$  goto All_Done
$Get_Qualifiers:
$  q_nbr = 0
$  if f$length(qual) .eq. 0 then goto No_More_Qualifiers
$Get_Qualifiers_Loop:
$  tmp = f$element(Q_nbr,"/",qual)
$  if tmp .eqs. "/" then goto No_More_Qualifiers
$  Q_nbr = Q_nbr + 1
$  fix2 'q_nbr'
$  q_nbr = nbr
$  P'p_nbr'q'q_nbr' = tmp
$ goto Get_Qualifiers_Loop
$
$No_More_Qualifiers:
$  P'p_nbr'Q_CNT = 'q_nbr'
$Get_Qualifiers_RETURN:
$ RETURN
$FIX2:  subroutine
$  nbr :== 'P1'
$  if nbr .lt. 10 then nbr :== 0'nbr'
$ exit
$ endsubroutine
$All_Done:
$  Parameter_Count = P_CNT - C_CNT
$  P_NBR = 1
$
$  if Parameter_Count .ne. 0 then goto There_Are_Parameters
$  say "There are NO parameters."
$ if C_CNT .eq. 0 then exit
$
$There_Are_Parameters:
$  if Parameter_Count .gt. 1 then say "There are ''Parameter_Count' parameters."
$  if Parameter_Count .eq. 1 then say "There is 1 parameter."
$
$  P_nbr = 1
$
$Show_Param_Loop:
$  show_nbr = p_nbr - c_cnt
$  fix2 'p_nbr'
$  p_nbr = nbr
$  if c_cnt .eq. 0 .or. P_nbr .ne. 1 then say "Parameter ",Show_NBR ,"  ", P'p_nbr'
$  if c_cnt .eq. 1 .and. P_nbr .eq. 1 then say "Command Qualifiers:"
$  q_cnt = P'p_nbr'Q_CNT
$ if Q_cnt .gt. 0 then goto There_Are_Qualifiers
$  say "There are NO qualifiers."
$ goto End_Qualifier_Loop
$
$There_Are_Qualifiers:
$ if Q_cnt .eq. 1 then say "There is 1 qualifier."
$ if Q_cnt .gt. 1 then say "There are ''Q_cnt' qualifiers."
$
$  cnt = 1
$Show_Qual_Loop:
$  fix2 'cnt'
$  tmp = P'p_nbr'Q'nbr'				! get the qualifier
$  tmp := 'tmp					! make it an ASCII string
$  say f$fao("  qualifier !2UB = '!AS'", cnt, tmp)! show it
$  cnt = cnt + 1
$ if cnt .le. Q_cnt then goto Show_Qual_Loop
$End_Qualifier_Loop:
$  p_nbr = 'p_nbr' + 1
$  say ""
$ if p_nbr .le. Parameter_Count + C_CNT then goto Show_Param_Loop
$ 
$ exit
$!------------------------------------------------------------------------------
$!  Author:  Scott L. Hesterman		PXO
$!  Date:    25-NOV-1986
$!  Lang:    DCL  (VMS 4.4)
$!  
$!  Purpose: Parse DCL command lines to be passed to other procedures.
$!  
$!  This version includes the code to display the parsed output.
$!  To actually use it, you would only use the symbols defined
$!  rather than display them.
$!
$!------------------------------------------------------------------------------
$!
$!
$!  Sample runs
$!
$
$ TEST == "@MYPROCEDURE PARSE"
$
$ test abcdefg /log=log.file /verify
There is 1 parameter.
Parameter 1  ABCDEFG
There are 2 qualifiers.
  qualifier  1 = 'LOG=LOG.FILE'
  qualifier  2 = 'VERIFY'
$ test PURGE
There is 1 parameter.
Parameter 1  PURGE
There are NO qualifiers.
$ test /log=mydir.log
There are NO parameters.
Command Qualifiers:
There is 1 qualifier.
  qualifier  1 = 'LOG=MYDIR.LOG'
$ test Parm1 Parm2/q1  Parm3 /Q2 /Q3 /Q4  Parm4 /Q5/Q6
There are 4 parameters.
Parameter 1  PARM1
There are NO qualifiers.
Parameter 2  PARM2
There is 1 qualifier.
  qualifier  1 = 'LOG='
Parameter 3  PARM3
There are 3 qualifiers.
  qualifier  1 = 'Q2'
  qualifier  2 = 'Q3'
  qualifier  3 = 'Q4'
Parameter 4  PARM4
There are 2 qualifiers.
  qualifier  1 = 'Q5'
  qualifier  2 = 'Q6'
 | 
|  |     re. -1, -2, -3
    
    This is a thank you note for your help (i.e. Kevin O., Scott L. H. )
    You have contributed to the solution of my problem.
    
    Regards,
    
    Kostas G.
 |