Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Proclip2 Library - <b> wildat() </b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 WILDAT() 

          The WILDAT function will perform a search of a target string for
          the first occurrence matching the specified string pattern.  The
          pattern string may contain the wildcard character (?) indicating a
          "don't care" for this position within the match.  The function also
          has the options of ignoring case during the match or altering the
          offset within the target string for the scan to begin.


      Format: 

               wildat(pattern, target [,offset] [,case])


      Parameters: 

               pattern...Character string variable or constant which is the
                         string to look for in the TARGET string.  The
                         PATTERN length must be greater than zero, less than
                         32,767 and shorter than the TARGET length.  The
                         following are special cases within the pattern.

                         ? (wildcard)   Indicates to the matching process
                                        that it should ignore the character
                                        in this position, but that a
                                        character will exist in that
                                        position.  The PATTERN of "t??" will
                                        match on all of the following
                                        examples: "that", "test", "text" and
                                        "with this".  The last one will match
                                        because of the .."th t.." matches the
                                        wildcard pattern.

                         \ (literal)    Indicates to the matching process
                                        that it should take the next
                                        character in the PATTERN literally.
                                        This may be used when attempting to
                                        match on the wildcard character
                                        itself.  For instance, a pattern of
                                        "\?" will match in the phrase "Do you
                                        understand?" when the question mark
                                        is encountered.  To match on the
                                        backslash character (\) itself, just
                                        precede it with a literal flag (eg.
                                        "\\").

               target....Character string variable or constant which is the
                         string to search for the occurrence of PATTERN.  The
                         TARGET length must be greater than zero, equal to or
                         less than 32,767 and greater than the PATTERN
                         length.

               offset... OPTIONAL. Numeric variable or constant which is
                         the offset within the TARGET for the search to begin.
                         The default is no offset so searching will start at
                         the first character in the TARGET.  The first
                         character in the TARGET is at offset zero (0) so all
                         offsets are the actual character position in the
                         string minus one.  Think of the offset as telling
                         the function to "ignore this many characters before
                         beginning the search."  The length of the PATTERN
                         string plus this OFFSET must not exceed the length
                         of the TARGET string.

             case......  OPTIONAL .  Logical variable or constant which
                         instructs the function to ignore case during the
                         search.

                         .T.            DEFAULT.  Forces the matching process
                                        to adhere to case matching.

                         .F.            Setting this flag to false (.F.)
                                        instructs the function to ignore case
                                        matching.  Therefore, "The" and "the"
                                        will be considered identical for
                                        matching purposes.

      Examples: 

               1.   Search the TARGET text and return the position of every
                    occurrence of the word "the" and ignore case matching.
                    The function will find two occurrences, one at position
                    #01 and the other at position #33.

                    .
                    .
                    .
                    target = 'The quick brown fox jumped over the lazy dog.'
                    offset = 0
                    do while .T.
                         offset = WILDAT('the', target, offset, .f.)
                         if offset < 1
                              exit
                         endif
                         (do something)
                    enddo
                    .
                    .
                    .

                    The quick brown fox jumped over the lazy dog
                                                   

               2.   Search the TARGET text and return the position of every
                    occurrence of the pattern "t??t" and enforce case
                    matching.  The function will find four occurrences, at
                    positions #16, #25, #32 and #35.

                    .
                    .
                    .
                    pattern = 't??t'
                    target = 'That guy gives tests on text with that book.'
                    offset = 0
                    do while .T.
                         offset = WILDAT(pattern, target, offset)
                         if offset < 1
                              exit
                         endif
                         (do something)
                    enddo
                    .
                    .

                    That guy gives tests on text with that book.

               3.   Search the TARGET text and return the position of every
                    question mark (?).  As this is the wildcard character
                    remember we must use the literal (\) expression.  The
                    function will find two occurrences, one at position #13
                    and the other at position #24.

                    .
                    .
                    .
                    pattern = '\?'
                    target = 'Did you know?  Does she?'
                    offset = 0
                    do while .T.
                         offset = WILDAT(pattern, target, offset)
                         if offset < 1
                              exit
                         endif
                         (do something)
                    enddo
                    .
                    .
                    .

                    Did you know?  Does she?
                                          


      Returns: 

               memvar....Number variable which, if greater than zero,
                         indicates the position within the TARGET where the
                         PATTERN was found.  This position is relative to the
                         start of the TARGET not the start of the
                         TARGET+OFFSET.  If zero then no match was found.  If
                         less than zero then an error in one of the
                         parameters prevented the search from beginning.


      Cautions: 

               None.

See Also: WILDRAT()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson