Tip 7 #4D Write Pro - Find/Replace
- Gabriel Inzirillo
- 20 juin 2019
- 1 min de lecture
Dernière mise à jour : 24 juin 2019
Here is a little piece of code that allow you to find and replace a string by another inside a 4D Write Pro document.
Don't forget to replace Form.WPObj, Form.search et Form.replace in the code

C_OBJECT($find)
$length:=0
// Find
$allText:=WP Get text(Form.WPObj)
$pos:=0
$find_col:=New collection
Repeat
$pos:=Position(Form.search;$allText;$pos+1;$length)
If ($pos>0)
$find_col.push(New object("pos";$pos;"length";$length))
End if
Until ($pos=0)
// Replace
For ($i;$find_col.length-1;0;-1)
$find:=$find_col[$i]
$range:=WP Text range(Form.WPObj;$find.pos;$find.pos+$find.length)
WP SET TEXT($range;Form.replace;wk replace)
End for
Comentários