Log In    |    Knowledge Base    |    4D Home
Tech Tip: Replacing a highlighted string with a new string
PRODUCT: 4D | VERSION: 2003.2 | PLATFORM: Mac & Win
Published On: January 22, 2004
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Versions 6.8 and 2003

The following method replaces a string that is being highlighted in an enterable field or variable.

  ` Project Method: Replace_HighlightedString
  ` Description: Replace the string that is being highlighted in
  ` an enterable text field or variable.
  ` Parameters: $1 - Pointer to an enterable field or variable
  ` $2 - A new string to replace.



GET HIGHLIGHT($area->;$startSel;$endSel)
If ($startSel<$endSel)
  $area->:=Delete string($area->;$startSel;$endSel-$startSel)
  $area->:=Insert string($area->;$newstring;$startSel)
  HIGHLIGHT TEXT($area->;$startSel;$startSel+Length($newstring))
End if

Caution: Do not execute this method from an object that has the focusable option enabled. Otherwise, the enterable field or variable will lose its highlighted position.