A NEW TODAY IS DAWNING!

TB0013 - Mass Editing of Screen Properties

Number: TB0013

Availability: As of BuildPro 8.00, developer users.


Introduction

The creation or editing of objects in the BuildPro Development Environment can be automated through the use of BuildPro Scripts. By programmatically creating script files, thousands of objects can be modified based on a set of rules. With the introduction of scriptable screen property screens, the developer can now mass edit the properties of screens and screen fields. This bulletin gives a specific example.


An example

In this example we will provide the specific steps required to change the Apply Logic property of all screen fields in an application. A similar method could be used to change for example the default font on all button fields or the background color of all screens.

For all edit fields we want to change the Apply Logic property from "After" to "Always (after)". To do this we will find out which edit fields have this property and create a script to automatically modify all those fields

NOTE: Before running automated scripts.against your application, make an archive backup of all your applications.


Finding out which objects to edit

The Export Object Properties feature allows you to store all the properties of all screen fields to a file (from the BuildPro Developer, see Tools/Export Object Properties...). In this example we want to export all Screen Field properties. The output would look something like this:

"Appn Name","Screen Name","Field No","Field Name","Field Type","Mnemonic","Top","Left","Height","Width","Font","Text BG Color","Text FG Color","BG Color or Pattern","Allow H Scroll","Apply Logic","Dictionary Name","Max. Characters","Val. On Show","Val. If Blank","Validation Action","Dbl Click Action","Use Dict Width","Help Name"
"contact","Action","1","PushButton6","Push Button","","0","50","77","900","ContactFont","","","","N","Always (after)","","20","N","Y","F-ExpTitle","","N",""
"contact","Action","2","PushButton7","Push Button","","0","1050","77","4067","ContactFont","","","","N","After","","20","N","Y","F-ExpTitle","","N",""
"contact","Action","3","PushButton9","Push Button","","0","5217","77","900","ContactFont","","","","N","After","","20","N","Y","F-ExpTitle","","N",""
"contact","Action","4","PushButton11","Push Button","","0","6217","77","900","ContactFont","","","","N","After","","20","N","Y","F-ExpTitle","","N",""
"contact","ActionShow","1","Picture5","Picture","","0","350","154","333","","","","","N","","","1","N","N","","","N",""
"contact","ActionShow","2","Edit5","Edit Field","","0","983","115","4067","","","","","N","After","","50","N","N","","F-ActionShow_Comp","N",""
"contact","ActionShow","3","LabelEdit6","Label","","0","5167","146","1000","","white","","solid-white","N","","","20","N","N","","","N",""
"contact","ActionShow","4","CheckBox7","Check Box","","10","6583","100","317","","white","","solid-white","N","After","","1","N","N","","","N",""
...

If you have Microsoft Excel installed look at the complete list of fields.

In Excel it would be easy select all the edit fields and those with the Apply Logic set to "After". Excel however is limited to 65,000 rows. Many application will have more than 65,000 screen fields in an application. Therefore we will use Linux scripting to be able process an unlimited number of fields.

A simple Linux command will help us determine the relevant screen fields:

$ grep "Edit Field" exportfile.txt | grep "After" > list_of_fields

We now have a text file (list_of_fields) containing all the relevant Edit Fields.


Creating a BuildPro Script file

In order to drive the scriptable Screen Properties screen (see Tools/Screen Properties...) we need only the screen name and field number. The rest of the properties have no use in this example.

To extract only the screen name and field number from the comma delimited list we use a simple shell script (click on the link to view the script):

$ extractcol < list_of_fields > names_fieldnos

The result will look something like this (containing only the screen name a space character and the field number):

ActionShow 2
CompAdd 2
CompAdd 3
CompAdd 4
...

We will then use this data to generate the BuildPro script file using another simple script:

$ genscript1 < names_fieldnos > script_file

Of course this whole procedure could have been performed with a single command:

grep "Edit Field" exportfile.txt | grep "After" | extractcol | genscript1 > script_file

NOTE. These shell scripts are quite simple. You might want to a script that changes all the fields for a single screen before canceling out of the Screen Field properties pop-up dialog. You could also split the exportfile.txt in this example to several files to decrease the size of the BuildPro scripts.


Running the BuildPro Script

To run the script we can either start it from the Scripting Subsystem (Tools / Scripting...) or from the command line:

C:\BuildPro\bin\wintdyx -uvision -acontact -iscript_file

After running the script you must perform a General All (see Application / Generate / Application) before running the application.