.TEXT FIND AND REPLACE

This subroutine finds and replaces text in a text/alpha field.


Usage:

      PASS         <text_field>               FIELD            SHARE? Y
      PASS         <search_text>              FIELD            SHARE? N
      PASS         <replace_with>             FIELD            SHARE? N
      PASS         <no_of_replacements>       FIELD            SHARE? Y
      PASS         <skip>                     FIELD            SHARE? N
      PASS         <max_no_replace>           FIELD            SHARE? N
      PASS         <start_of_text>            FIELD            SHARE? N
      PASS         <len_of_text>              FIELD            SHARE? N
      PASS         <start_of_search>          FIELD            SHARE? N
      PASS         <len_of_search>            FIELD            SHARE? N
      PASS         <start_of_replace>         FIELD            SHARE? N
      PASS         <len_of_replace>           FIELD            SHARE? N
      GOSUB    --- .TEXT FIND AND REPLACE
      *        Check for errors
      IF       --- .TEXT FIND AND REPLACE     NE

Description:

This subroutine finds and replaces text in a text/alpha field. The first 2 parameters are required. If any required parameters are missing, the subroutine will CANCEL.

<text_field> is the text to be modified (Required). This must be PASSed with Share "Y" to return the value.

<search_text> is the text to be searched for (Required).

<replace_with> is the replacement text (Optional). If not PASSed or blank, this routine will 'cut' the the <search_text> from <text_field>.

<no_of_replacements> returns the number of times the text was replaced (Optional). This must be PASSed with Share "Y" to return the value.

<skip> is the number of occurrences of <search_text> to skip before beginning replacement (Optional). If not PASSed, all occurrences will be replaced.

<max_no_replace> is the maximum number of replacements you want performed (Optional). If not provided, all occurrences will be replaced. For example, if you only want the first 2 occurrences replaced, PASS 0 for <skip> and 2 for <max_no_replace>, or if you only want the 3rd & 4th occurrences replaces, PASS 2 for <skip> and 2 for <max_no_replace>. You can also PASS -1 to indicate all occurrences.

<start_of_text> is the starting position in <text_field> to begin the search (Optional). If not provided, <text_field> will be searched starting at position 1.

<len_of_text> is the number of characters from <start_of_text> to be searched (Optional). If not provided, <text_field> will be searched to the end of the field.

<start_of_search> is the starting position in <search_text> to use (Optional). If not provided, <search_text> starting at position 1 will be used.

<len_of_search> is the number of characters from <start_of_search> to be used (Optional). If not provided, <search_text> will be used to the end of the field.

<start_of_replace> is the starting position in <replace_with> to use (Optional). If not provided, <replace_with> starting at position 1 will be used.

<len_of_replace> is the number of characters from <start_of_replace> to be used (Optional). If not provided, <replace_with> will be used to the end of the field.

Notes this is a case sensitive search, regular expressions are not allowed.

Comments:

Read what other users have said about this page or add your own comments.


-- JeanNeron - 2012-02-10

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2012-02-10 - JeanNeron
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback