KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: WR Backspace Method for 4D Write Pro
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: August 10, 2020

Below is a method that can be used to replace WR Backspace when replacing 4D Write with 4D Write Pro.
The method uses WP SET TEXT to "delete" the text by replacing the target with an empty string, it will also check first if the length of the range is greater than 0 characters, if not it will update the range to include the prior character.

// Method: WP_Backspace
C_OBJECT
($1;$wpRange_o)

If (Count parameters=1)
   $wpRange_o:=$1
  
   If ($wpRange_o.start=$wpRange_o.end)
      If ($wpRange_o.start#0)
        $wpRange_o:=WP Text range($wpRange_o.start-1;$wpRange_o.end)
      End if
   End if
  
   WP SET TEXT($wpRange_o;"";wk replace)
  
End if


An example of using the method:
C_OBJECT($wpSel_o)

$wpSel_o:=WP Selection range(WParea)
WP_Backspace($wpSel_o)