GETOPTS.PRG

820 B 8e0762fdf7656025…
optstr = OPDATA()
optlen = LEN(optstr)
i = 0
DO WHILE i < 12
	i = i + 1
	opt[i] = ""
ENDDO

numopts = 0
i = optlen
char = ""
optval = ""
DO WHILE numopts < 12 .AND. i > 0
   char = ""
	IF i > 0 .AND. i <= optlen
      char = SUBSTR(optstr, i, 1)
		char = UPPER(char)
   ENDIF
	IF LEN(char) < 1
      RETURN
   ELSE
	IF char = "/" .OR. char = "\"
      RETURN
   ELSE
	IF char = " "
		numopts = numopts + 1
		&&**** since we are going in reverse, the optval is reversed
		slen = LEN(optval)
		j = slen
		optval2 = ""
		DO WHILE j > 0
			optval2 = optval2 + SUBSTR(optval, j, 1)
			j = j - 1
		ENDDO
		opt[numopts] = optval2
		optval = ""
   ELSE
	IF char > " " .AND. char <= "Z"
		optval = optval + char
   ENDIF
   ENDIF
   ENDIF
   ENDIF
   i = i - 1
ENDDO
RETURN