Code Rules Home
Microsoft Dynamics NAV Documentation
Code Rules

The following table shows how code rules are used to remove unsupported triggers and methods. Code rules are written using syntax similar to regular expressions. The following examples illustrate how code rules work and can be written.

Code transformation rule Code before transformation Code after transformation
<find>
x := y;
MESSAGE('Hello');
x := y;
MESSAGE('World');
NoteNote
Omitting the REPLACE instruction in the code transformation rule implies deletion.
MESSAGE('Hello');
MESSAGE('World');
<find>
x := y;
<replace>
y := z;
MESSAGE('Hello');
x := y;
MESSAGE('World');
MESSAGE('Hello');
y := z;
MESSAGE('World');
<find>
x := TRUE;
<replace>
;
<find>
y := x;
<replace>
x := TRUE;
<find>
y := x;
<replace>
x := FALSE;
MESSAGE('Hello');
y := x;
MESSAGE('World');
NoteNote
Rules are evaluated from top to bottom. Rules are run again if a match is found.
MESSAGE('Hello');
;
MESSAGE('World');
<find>
x := y;
<atTrigger>
OnOpenForm
OnInit=BEGIN
   MESSAGE('Hello');
   x := y;
   MESSAGE('World');
END;

OnOpenForm=BEGIN
   MESSAGE('Hello');
   x := y;
   MESSAGE('World');
END;
OnInitPage=BEGIN
   MESSAGE('Hello');
   x := y;
   MESSAGE('World');
END;

OnOpenPage=BEGIN
   MESSAGE('Hello');
   MESSAGE('World');
END;
<find>
x := z;
<comment>
Hello world
MESSAGE('Hello');
x := z;
//comment
MESSAGE('World');
MESSAGE('Hello');
//comment
MESSAGE('World');
<find>
CurrForm.!var1!.HEIGHT := TRUE;
<declareVariable>
!var1!Height
<declareVariableType>
Integer
<replace>
!declaredVariable! := TRUE;
OnRun=BEGIN
   MESSAGE('Hello');
   CurrForm.x.HEIGHT := TRUE;
   MESSAGE('World');
END;
VAR
  xHeight : Integer;
OnRun=BEGIN
   MESSAGE('Hello');
   xHeight := TRUE;
   MESSAGE('World');
END;
<find>
Text := '';
<declareVariable>
!control!HideValue
<declareVariableType>
Boolean INDATASET
<replace>
!declaredVariable := TRUE;
<atTrigger>
OnFormat
<moveToProperty>
HideValue
<moveValueToProperty>
!declaredVariable!
<movePropertyToControlName>
!control!
SourceExpr := x;
OnFormat=BEGIN
   MESSAGE('Hello');
   Text := '';
   MESSAGE('World');
END;
NoteNote
Assume that the preceding code is in a control with SourceExpr = x. The rule functions in the same way if the code is in a control with the Name property = x, or ID = x.
VAR
  xHideValue : Boolean INDATASET;
SourceExpr = x;
HideValue = xHideValue;
OnFormat=BEGIN
   MESSAGE('Hello');
   xHideValue := TRUE;
   MESSAGE('World');
END;
<find>
y := x;
<atTrigger>
OnActivateForm
<replace>
;
<moveToTrigger>
OnOpenForm
<moveCodeToTrigger>
y := x;
OnActivateForm=BEGIN
   MESSAGE('Hello');
   y := x;
   MESSAGE('World');
END;
OnActivateForm=BEGIN
   MESSAGE('Hello');
   ;
   MESSAGE('World');
END'

OnOpenForm=BEGIN
   y := x;
END;
<find>
y := !var!
<replace>
y := TRUE;
MESSAGE('Hello');
y := x;
x := z;
MESSAGE('World');
MESSAGE('Hello');
y := TRUE;
x := z;
<find>
!var1! := !var2!
<replace>
!var2! := !var1!
MESSAGE('Hello');
y := x;
x := z;
MESSAGE('World;);
MESSAGE('Hello');
x := y;
z := x;
MESSAGE('World');
<find>
!currForm!.EDITABLE := TRUE
<replace>
;
MESSAGE('Hello')
CurrForm.EDITABLE := TRUE;
MESSAGE('World');
MESSAAGE('Hello');
;
MESSAGE('World');
<find>
!currForm!.EDITABLE := TRUE
<replace>
;
MESSAGE('Hello')
CurrReport.EDITABLE := TRUE;
MESSAGE('World');
MESSAAGE('Hello');
;
MESSAGE('World');
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View