top of page
Rechercher

Tip 7 #4D Write Pro - Find/Replace

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


Code pour le Chercher/Remplace dans un document Write Pro

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


277 vues0 commentaire

Posts récents

Voir tout

List of 4D Components and Plugins

I realize that there is no list of existing components and plugins in 4D. I think it can be cool to make such kind of list to try to have a kind of catalog where people can look at to see what is avai

bottom of page