KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility method to search for a string in a 4D Write Pro area
PRODUCT: 4D Write Pro | VERSION: 16R4 | PLATFORM: Mac & Win
Published On: July 13, 2017

Here is a utility method that perform a search for a character string in a 4D Write Pro area.

  //  Method: wpFind
  //  Parameters
  //    $1  -  WP Area Object Name
  //    $2  -  Text to find
  // ----------------------------------------------------

C_TEXT($1;$wpArea_t;$2;$toFind_t)
C_TEXT($text_t)
C_LONGINT($start_l;$end_l;$pos_l)

If (Count parameters>=2)
  $wpArea_t:=$1
  $toFind_t:=$2
  $text_t:=ST Get plain text(*;$wpArea_t)
  GET HIGHLIGHT(*;$wpArea_t;$start_l;$end_l)
  If ($end_l>$start_l)
    $start_l:=$end_l
  End if
  $pos_l:=Position($toFind_t;$text_t;$start_l)
  If ($pos_l>0)
    HIGHLIGHT TEXT(*;$wpArea_t;$pos_l;$pos_l+Length($toFind_t))
  End if
End if