The following tables show how code rules are used to remove
unsupported triggers and methods. Code rules are written using
syntax similar to regular expressions. A code rule uses one or more
special words to match code on the form.
The following special words are used as tags to find and replace
expressions, to create variables, and to move code and
properties:
The following special words are used as placeholders for
variables:
The following examples illustrate how code rules work and can be
written. The first examples show simple find and replace rules. The
next examples build on the find and replace rule.
<find> and <replace>
Use the <find> and <replace> special words to find
specific code and replace it. If you omit the <replace>
instruction in the code transformation rule, then the found code is
deleted but not replaced with any code.
<atTrigger>
Use the <atTrigger> special word to specify that you want
to find and replace code only if it is in the specified
trigger.
Code transformation rule |
Code before transformation |
Code after transformation |
|
Copy Code |
<find>
x := y;
<atTrigger>
OnOpenForm
|
|
|
Copy Code |
OnInit=BEGIN
MESSAGE('Hello');
x := y;
MESSAGE('World');
END;
OnOpenForm=BEGIN
MESSAGE('Hello');
x := y;
MESSAGE('World');
END;
|
|
|
Copy Code |
OnInitPage=BEGIN
MESSAGE('Hello');
x := y;
MESSAGE('World');
END;
OnOpenPage=BEGIN
MESSAGE('Hello');
MESSAGE('World');
END;
|
|
<comment>
Use the <comment> special word to add comments to the
CodeRules.txt file. The comment is ignored in the code
transformation.
Code transformation rule |
Code before transformation |
Code after transformation |
|
Copy Code |
<find>
x := z;
<comment>
Hello world
|
|
|
Copy Code |
x := z;
MESSAGE('Hello World');
|
|
|
Copy Code |
MESSAGE('Hello World');
|
|
!var! and !var<int>!
<declareVariable>,
<declareVariableType>, and !declaredVariable!
Use the <declareVariable> special word to specify that the
transformed code must declare a new variable. The expression after
the <declareVariable> special word is the name of the new
variable. Use the <declareVariableType> special word to
specify the data type of the new variable that is declared. Use the
!declaredVariable! special word to specify that you want to use the
new variable that you declared.
Code transformation rule |
Code before transformation |
Code after transformation |
|
Copy Code |
<find>
!currForm!.!var1!.HEIGHT(!var2!)
<replace>
!currForm!.!var1!.HEIGHT := !var2!
<find>
CurrForm.!var1!.HEIGHT;
<declareVariable>
!var1!Height
<declareVariableType>
Integer
<replace>
!declaredVariable!;
|
|
|
Copy Code |
OnRun=BEGIN
…
MESSAGE('Hello');
CurrForm.x.HEIGHT(NewHeight);
MESSAGE('World');
END;
|
|
|
Copy Code |
VAR
xHeight : Integer;
OnRun=BEGIN
…
MESSAGE('Hello');
xHeight := NewHeight;
MESSAGE('World');
END;
|
|
!currForm!
<moveToProperty>,
<moveValueToProperty>, and
<movePropertyToControlName>
Use the <moveToProperty> and the
<moveValueToProperty> special words to move a value to the
specified property. Use the <movePropertyToControlName>
special word to move this property to the specified control.
<moveCodeToTrigger> and
<moveToTrigger>
Use the <moveCodeToTrigger> special word to specify the
code that you want to move to a trigger. Use the
<moveToTrigger> special word to specify the trigger to which
you want to move the code.
Code transformation rule |
Code before transformation |
Code after transformation |
|
Copy Code |
<find>
y := x;
<atTrigger>
OnDeactivateForm
<replace>
;
<moveToTrigger>
OnCloseForm
<moveCodeToTrigger>
y := x;
|
|
|
Copy Code |
OnDeactivateForm=BEGIN
MESSAGE('Hello');
y := x;
MESSAGE('World');
END;
OnInit=BEGIN
MESSAGE('Hello');
y := x;
MESSAGE('World');
END;
|
|
|
Copy Code |
OnClosePage=BEGIN
y := x;
END;
OnInit=BEGIN
MESSAGE('Hello');
y := x;
MESSAGE('World');
END;
|
|