home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / cug / softt-3.lbr / GETARG.DQC / GETARG.DOC
Text File  |  1984-07-05  |  2KB  |  83 lines

  1. .bp 1
  2. .in 0
  3. .he 'GETARG (2)'11/10/78'GETARG (2)'
  4. .fo ''-#-''
  5. .fi
  6. .in 7
  7. .ti -7
  8. NAME
  9. .br
  10. getarg - get command line arguments
  11. .sp 1
  12. .ti -7
  13. SYNOPSIS
  14. .br
  15. stat = getarg (n, array, maxsize)
  16. .nf
  17. .sp
  18. integer n, maxsize
  19. character array(ARB)
  20. integer stat returned as length/EOF
  21. .fi
  22. .sp 1
  23. .ti -7
  24. DESCRIPTION
  25. .br
  26. Getarg returns the "n"th argument to the current program in the
  27. array "arg", one character per array element.
  28. The argument is terminated by an EOS marker.
  29. 'Maxsize'
  30. is passed as the maximum
  31. number of characters array is prepared to deal with (including
  32. the EOS);  getarg truncates the argument if necessary.
  33. Getarg returns the length of the argument in "arg"
  34. (excluding the EOS), or EOF
  35. if "n" specified a non-existent argument.
  36. .sp
  37. On some systems, if "n" is zero, the name of the current program
  38. is returned in "arg" and,
  39. if "n" is -1, the function returns the number of
  40. arguments on the command line.
  41. .sp
  42. Also, on some systems, command line arguments can only be passed
  43. in a single case (upper or lower).
  44. On these systems an escape mechanism may be necessary to
  45. indicate case when specifying arguments.
  46. .sp 1
  47. .ti -7
  48. IMPLEMENTATION
  49. .br
  50. .sp 1
  51. The implementation of 'getarg' may be quite different on different
  52. operating systems.
  53. Some systems allow only upper case (or lower case) on the command line;
  54. they may limit size; they may not even provide access at all without
  55. considerable contortions.
  56.  
  57. When implementing 'getarg', the designer should keep in mind that
  58. a 'delarg' will also be needed.
  59. One possible design would be to create a routine 'makarg', which would
  60. pick up the arguments from the system, convert them to ascii strings,
  61. handle any upper-lower case escape conventions, and store them in an
  62. array.
  63. 'Getarg' could then access this array, stripping off any quoted strings
  64. surrounding the arguments, and passing them along to the user.
  65. 'Delarg' could also access this array when removing reference to
  66. arguments.
  67.  
  68. If it is absolutely impossible to pick up command line arguments from
  69. the system, 'makarg' could be taught to prompt the user for them.
  70.  
  71. If the shell is implemented, 'getarg' (or perhaps 'markarg')
  72. will have to be altered to read arguments as passed from the shell.
  73. .sp 1
  74. .ti -7
  75. SEE ALSO
  76. .br
  77. initst, delarg
  78. .sp 1
  79. .ti -7
  80. DIAGNOSTICS
  81. .br
  82. None
  83.