home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / cmsoriginal / cmswild.mss < prev    next >
Text File  |  2020-01-01  |  4KB  |  116 lines

  1. @make(vmappendix)
  2. @comment(this is the WILD appendix, by Carl Kass, Dec 13, 1980)
  3. @comment<Copyright (C) 1980 Columbia University>
  4. @case<device,diablo="@Typewheel(pica)">
  5. @appendixname(name="WILD subroutine")
  6. @introduction
  7. The WILD subroutine is an assembler language subroutine which is PL/I
  8. callable as well as assembler callable.  It compares two varying
  9. length strings with wild card matching.  
  10. @cmssyntax
  11. The subroutine may be declared either with two or three parameters
  12. from PL/I as follows:
  13.  
  14. @begin(example,group)
  15. DECLARE WILD ENTRY(CHAR(*) VAR,CHAR(*) VAR[,CHAR(2)])
  16.     EXTERNAL OPTIONS(ASSEMBLER,INTER,RETCODE);
  17. @end(example)
  18.  
  19. and called as follows:
  20. @begin(example,group)
  21. CALL WILD(pattern,source[,wildcards]);
  22. @end(example)
  23. where "pattern" and "source" are character(*) varying and "wildcards"
  24. is character(2). "pattern" and "source" need not be the same length.
  25. "pattern" represents the pattern string, whereas "source" is the
  26. string to be tested for matching the patten. "wildcard", if specified,
  27. represents the two wildcard characters. The first of the two
  28. characters is a symbol which may appear in the pattern string but not
  29. the source string which will match any number of any characters
  30. (SNOBOL's ARB pattern). It is the calling program's responsibility to
  31. ensure that the first wildcard character does not appear in the source
  32. string.  The second wildcard character which may appear in the pattern
  33. and/or the source string will match any single character in the source
  34. string (SNOBOL's LEN(1)). If only two strings are passed, then the
  35. wildcard characters default to "*" for ARB and "%" for LEN(1).
  36.  
  37. To call WILD from assembler, use the standard OS calling conventions.
  38. The format of the source and pattern strings is as follows:
  39.  
  40. @begin(verbatim)
  41.                  +----------+--------------------+
  42.                  |          |                    |
  43.                  +----------+--------------------+
  44.                     length          text
  45. @end(verbatim)
  46.  
  47. where the length field is a binary halfword containing the length of
  48. the text field. The wildcard string is simply a two byte string (CL2).
  49. If no wildcard string is to be passed to WILD, then the first byte of
  50. the second word of the parameter address block (PAB) must be X'80'.
  51.  
  52. If the strings match, then WILD will set a return code of 0 whereas if
  53. they don't match the return code will be set to 8.  From PL/I this
  54. value may be examined through the PLIRETV builtin function, from
  55. assembler register 15 will contain the return code.
  56.  
  57. Note:
  58. PLIRETV should be declared as follows:
  59. @begin(example)
  60. DECLARE PLIRETV BUILTIN;
  61. @end(example)
  62. and then used as any normal builtin function having no arguements (see
  63. example below).
  64. @cmsexamples
  65. This is an example of calling WILD from a PL/I program passing it
  66. three parameters:
  67. @begin(example,group)
  68. /* S1 IS THE PATTERN AND S2 IS THE SOURCE */
  69. DECLARE (S1,S2) CHAR(72) VARYING;
  70. /*  $ IS ARB AND  & IS LEN(1)   */
  71. DECLARE WILDCHARS CHAR(2) STATIC INITIAL('$&'); 
  72. DECLARE WILD ENTRY(CHAR(*) VAR,CHAR(*) VAR,CHAR(2))
  73.      EXTERNAL OPTIONS(ASSEMBLER,RETCODE,INTER);
  74. DECLARE PLIRETV BUILTIN;
  75.      .
  76.      .
  77.      .
  78. CALL WILD(S1,S2,WILDCHARS);
  79. IF PLIRETV=8 THEN GOTO NOMATCH;
  80.              ELSE GOTO MATCH;
  81. @end(example)
  82. @drawline
  83. This example illustrates calling WILD from assembler using the default
  84. wildcard characters:
  85. @begin(example,group)
  86.         L       15,=V(WILD)     POINT AT SUBROUTINE
  87.         LA      1,PAB           POINT AT PAB TO PASS
  88.         BALR    14,15           DO CALL
  89. * THE RETURN IS TO HERE
  90.         LTR     15,15           IS THE RETURN CODE 0?
  91.         BZ      MATCH           IF SO THEN GOTO MATCH
  92.         B       NOMATCH         OTHERWISE GOTO NOMTACH
  93.          .
  94.          .
  95.          .
  96. PAB     DS      0F           FULLWORD ALIGN THE PAB
  97.         DC      A(PATTERN)   ADDRESS OF PATTERN STRING
  98.         DC      X'80'        FLAG INDICATING ONLY 2 PARMS
  99.         DC      AL3(SOURCE)  ADDRESS OF SOURCE STRING
  100.          .
  101.          .
  102.          .
  103. PATTERN DS      H           FILL IN LENGTH OF PATTERN
  104.         DS      CL80        ANY LENGTH FOR PATTERN STRING
  105. SOURCE  DS      H           FILL IN LENGTH OF SOURCE
  106.         DS      CL90        ANY LENGTH FOR SOURCE STRING
  107. @end(example)
  108. @vs1syntax
  109. @na
  110. @vs1examples
  111. @na
  112. @additionalinfo
  113. WILD runs extremely quickly and may be freely used to compare two
  114. strings.
  115. @references
  116. @na