1. Konrad Kaltenbach
  2. PowerBuilder
  3. Monday, 2 October 2023 12:33 PM UTC

Dear experts,

we have a PBL consisting solely of DataWindows which are combined to generate certain documents.

Sometimes the task pops up to replace a certain string in the text property of a Text control in many DataWindows simultaneously, e. g. a year specification: 2022 -> 2023:

How can I do this economically?
Can I avoid opening each DW and in each DW this certain Text control?

I'm still hoping that there is a possibility like to open such a library in an appropriate text editor and to use "Replace all". But my attempts failed: After replacing the strings in and saving the PBL with Notepad (?) the PBL was damaged somehow. PowerBuilder did not identify the DataWindows anymore.

Thanks in advance for all trials to help me!

Kind regards,
Konrad Kaltenbach

Konrad Kaltenbach Accepted Answer Pending Moderation
  1. Wednesday, 4 October 2023 13:50 PM UTC
  2. PowerBuilder
  3. # 1

Hi René! Hi Francisco! Hi John!
Thanks a lot to everyone of you!

Exporting the DWs using the Library Painter,
replacing in files with Notepad++ (cf. screenshot below) and
reimporting them afterwards at once really works!

Not as fast as if one could replace a string in a PBL itself with an editor (my dream) but much faster than using "Edit source" for every single DataWindow in PowerBuilder.

The way with a (temporary) source control I will try to test within the next weeks. (I need the help of our service provider for this.)

Happy regards, Konrad

Comment
  1. Miguel Leeuwe
  2. Friday, 6 October 2023 05:57 AM UTC
You could also use (temporarily maybe) pbnative source control.

You could also write a small program in powerbuilder that exports all datawindows as files ( look for the LibraryExport function).

After that you'd have to open each file and search and replace and then save the file (using powerbuilder).

In the end save the file and treat all the rest.

When done, import the modified files by using the LibraryImport function.

regards
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 2 October 2023 14:53 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Konrad -

It's possible to export all of the objects in a .pbl relatively painlessly using the Library Painter:

  1. Open the Library Painter and navigate to the .pbl that contains the objects to be exported.
  2. Press Ctrl+A to select all objects, or use extended selection (Shift + Mouse Click) to select a range of objects in the .pbl.
  3. Click the Export button on the Painter toolbar. In the "save" dialog window that appears, navigate to the drive/folder where you want all of the exported DataWindow source files (.srd) to reside. Click "Save" for the first exported object.
  4. Repeatedly click "Save" for each of the remaining selected objects (use the keyboard if you don't want to mouse-click).

Edit the .srd source files as needed. Rene's suggestion to use Notepad++ is excellent if you can make sure you are changing the text label and not something else within the DW source syntax (like an X-position value, for example).

To import, you can use a similar technique in the Library Painter that you used to export. In the dialog window where you select the .srd file to be imported, use extended selection to select a range of files.

Best regards, John

Comment
  1. René Ullrich
  2. Wednesday, 4 October 2023 07:51 AM UTC
You can use the "Search in Files" function in Notepad++ that also allows to do a replace. So you don't need to open all the files.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 4 October 2023 14:14 PM UTC
Hi John / Konrad;

FWIW: What I do to export All my App's object classes source into test files in one fell sweep is to use the Native Source Code control option in the Workspace. In this case, using the built-in native SCC, it will ask you for a folder to store the object source files. Then perform an "Add to Source". After that one operation, the SCC folder will have every object class in your App as a text file. Then Notepad++ (or what ever editor you want to use) away.. ;-)

Once the sweeping changes are done to the text files. Check out all the object classes in the Library painter. Then re-import the changes TXT file object source code again using the Library Painter. HTH

Food for thought.

Regards ... Chris
  1. Helpful
  1. Roland Smith
  2. Thursday, 5 October 2023 18:44 PM UTC
I avoid tooting my own horn but PBSearch can do search and replace and will perform a check-out on any object that is changed.
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 2 October 2023 13:09 PM UTC
  2. PowerBuilder
  3. # 3

Hi Konrad,

If you use a source control you can change the DWs in file system (in wsobjects directory). After that do a "Refresh" on the PBL to load the changes.

If not you don't use source control you can export all datawindows to file system, do the  changes and import it again.

Notepad++ have a function to replace in multiple files.

HTH,

René

 

Comment
  1. Konrad Kaltenbach
  2. Monday, 2 October 2023 13:24 PM UTC
Hi René,

thanks a lot for your answer!

I would have to do it the second way. But it is not possible to export all DWs at once, is it? Exporting each single DW will cost me more time than using "Edit source" for each one in PowerBuilder...

Regards,

Konrad
  1. Helpful
  1. Francisco Martinez @Appeon
  2. Monday, 2 October 2023 14:28 PM UTC
Hi Konrad,



You can also create a local git repository, add your workspace to that SC, do the changes, refresh and delete the SC directories

Regards - Francisco
  1. Helpful 1
  1. René Ullrich
  2. Wednesday, 4 October 2023 05:17 AM UTC
Hi Konrad,

You ca also use the Library Painter to select and export more than one object. But it will you ask for each object. It should be still faster then export single objects.

The way with a (temporary) source control should be the best way.
  1. Helpful 2
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.