In JavaScript, using the Describe and Modify methods to access DataWindow property values has advantages and drawbacks. The examples here use Modify as illustrations, but similar considerations apply to Describe.
Advantage
You can specify column and property names dynamically
In your script, you can build a string that specifies the column and property names.
For example, the following code builds a string in which the default color value and the two color values in the If function are determined in the script. Notice how the single quotes around the expression are included in the first and last pieces of the string:
red_amount = parseInt(text_1.value); if (red_amount >= 0 and red_amount < 256) { modstring = "emp_id.Color='" + text_1.value + "\t If(emp_status=~'A~'," + 255 + "," + text_1.value + ")'"; dw_1.Modify(modstring)
The resulting string when red_amount is set to 128 is:
emp_id.Color='128\tIf(emp_status=~'A~',255,128)'
The following is a simpler example without the If function. The Color property for the column specified in ls_columnname is set to a constant value. You do not need quotes around the value if you are not specifying an expression:
dw_1.Modify(ls_columnname + ".Color=255");
Drawbacks
Setting several properties at once is possible but hard to debug
Although you can set several properties in a single method call, it is harder to understand and debug scripts that do so.
For example, the code for setting three properties is not too complex because there are no nested strings:
rtn = dw_1.Modify("emp_id.Font.Italic=0 oval_1.Background.Mode=0 oval_1.Background.Color=255");
Complex quoted strings are sometimes required
When you specify an expression for a property value, it is difficult to specify nested quotes correctly -- the code is hard to understand and prone to error. For Describe, this is less of a drawback -- strings will not become as complex because they do not include an expression.
For example, this string entered on a single line in a script assigns a DataWindow expression to the Color property:
Modify("emp_id.Color=\"16777215 \t If(emp_status=~~\"A~~\",255,16777215)\"");
For more information about quoted strings, see the section called “Standard datatypes” in PowerScript Reference.