-
FlexPro
- At a Glance
- Features & Options
- Applications
- All Advantages
- What’s New in FlexPro 2021
- Try FlexPro For Free
- FlexPro View OEM Freeware
- Buying Guide
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
- Products
- News
- Support
- Company
- Contact
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
Find & Replace
- This topic has 9 replies, 3 voices, and was last updated 3 years, 6 months ago by Bernhard Kantz.
-
AuthorPosts
-
February 4, 2016 at 10:38 am #12900HerveM1234Participant
Hi,
Is there a way to perform a string replacement in a complete database?
i.e. : I would like to replace the string “aaa” by “bbb” in every formulas, (formulas name & content) diagrams, tables,… of the database.Thanks for help
February 4, 2016 at 10:38 am #8560HerveM1234ParticipantHi,
Is there a way to perform a string replacement in a complete database?
i.e. : I would like to replace the string “aaa” by “bbb” in every formulas, (formulas name & content) diagrams, tables,… of the database.Thanks for help
February 5, 2016 at 8:39 am #9423Bernhard KantzParticipantThere is no simple way of replacing strings in object names and (embedded) formulas. Of course one can program a small VBA script that crawls through the whole database and changes the desired entities (names, contents).
February 5, 2016 at 9:50 am #9425HerveM1234ParticipantOK for that.
Would it be possible to get an example of this kind of VBA script?
Thanks in advance.
February 8, 2016 at 9:20 am #9426Bernhard KantzParticipantSince the names to change occur in many different locations, it is no easy task. The following example just handles object names, formula contents and datasets for 2d diagrams.
Option Explicit Const csSearch As String = "Jan" Const csReplace As String = "01" Public Sub SearchReplace() Visit ThisDatabase.RootFolder End Sub Private Sub Visit(ByRef oFld As Folder) Dim cllObs As FpObjects Set cllObs = oFld.Objects Dim oObj As FpObject For Each oObj In cllObs Select Case oObj.ObjectType Case fpObjectTypeFolder Visit oObj Case fpObjectTypeFormula VisitFormula oObj Case fpObjectType2DDiagram VisitDiagram2D oObj End Select ' rename object itself Dim sNewName As String sNewName = Replace(oObj.Name, csSearch, csReplace) If sNewName oObj.Name Then oObj.Rename sNewName, fpRenamingOptionsDontCorrectReferences End If Next oObj End Sub Private Sub VisitFormula(ByRef oFml As Formula) oFml.Formula = Replace(oFml.Formula, csSearch, csReplace) End Sub Private Sub VisitDiagram2D(ByRef oDiag2D As Diagram2D) Dim oCurve As Curve2D For Each oCurve In oDiag2D.Curves With oCurve.Data .DataSet = Replace(.DataSet, csSearch, csReplace) .XDataSet = Replace(.XDataSet, csSearch, csReplace) End With Next oCurve End Sub
February 8, 2016 at 2:31 pm #9427HerveM1234ParticipantGreat, thanks a lot !
maybe yo should had this feature to the next release !
February 10, 2016 at 6:08 pm #9428HerveM1234ParticipantI’ve tested the code : perfect. excepted if there is FPScript expressions embedded in a diagram. These expressions are not modified by the macro.
Thanks again!February 11, 2016 at 8:22 am #9429Bernhard KantzParticipantFor 2d diagrams the code example just handles the datasets for the curves (there was a c&p error for the x dataset). There are of course many locations (e.g. axis scaling) where embedded FPScript code may occur. Handling all the cases would have blown up the code.
From the overall structure one easily can add the functionality needed in ones specific case.May 11, 2021 at 2:28 pm #28939AnonymParticipantHallo,
ich bin noch kein Profi, was VBA angeht. Ich würde gerne bitte wissen, wie der Aufruf aussieht, wenn ich VisitFormula anwenden möchte.
Bei mir geht es auch darum, die Zeichenkette (String File) in meinen Formeln in der Objektliste durch einen anderen String zu ersetzen. Danke im Voraus.
Was tippe ich in meinen Direktbereich? Danke
May 14, 2021 at 10:17 am #28940Bernhard KantzParticipantWenn Sie lediglich in allen Formeln, eine Zeichenkette durch eine andere ersetzen wollen, sollten Sie in der Select-Case-Anweisung im Sub Visit den Fall für das 2D-Diagramm entfernen.
Ersetzen Sie dann die beiden String-Konstanten durch Ihre Zeichenketten und führen dann das Sub SearchReplace aus.
Das Sub VisitFormula können Sie nicht dafür verwenden. Es ist Teil des Visitor-Patterns und dient zur Korrektur einer Formel.
-
AuthorPosts
- You must be logged in to reply to this topic.