Tags:
create new tag
view all tags

.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 this routine will 'cut' the the <search_text> from <text_field>. This is different from PASSing a blank field, if you pass a blank field, then blanks will be inserted into <text_field>. The number of blanks will depend on the <len_of_replace> field below.

<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 PASSed or a blank/zero value is PASSed, 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 replaced, 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 PASSed or a blank/zero value is PASSed, <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 PASSed or a blank/zero value is PASSed, <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 PASSed or a blank/zero value is PASSed, <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 you PASS a zero or blank, <search_text> will be 'cut' from <text_field>. If not PASSed at all, <replace_with> will be used to the end of the field.

Note 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: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2012-03-27 - JeanNeron
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback