Understanding Code Rules - Form Transformation

dayscott
Member Posts: 42
code rules are very important for proper form transformation - they are not trivial though: http://msdn.microsoft.com/en-us/library/dd338843.aspx
1. question:

why is there "hello world" in the last line of the first box? it does not do anything.
2. question

I don't get the content of the first box at ALL.
what does !var1! do?
what does <declareVariableType>
Integer do ?
The replaced variable is not even Integer here... thats really weird :?
1. question:

why is there "hello world" in the last line of the first box? it does not do anything.
2. question

I don't get the content of the first box at ALL.
<find> CurrForm.!var1!.HEIGHT := TRUE; <declareVariable> !var1!Height <declareVariableType> Integer <replace> !declaredVariable! := TRUE;
what does !var1! do?
what does <declareVariableType>
Integer do ?
The replaced variable is not even Integer here... thats really weird :?
0
Comments
-
1. Hello World in the first column is a comment in the CodeRules.txt file. You add comments to the CodeRules.txt file by using the <comment> special word and then writing your comment. Comments in the CodeRules.txt file are ignored when transforming code.
The example given is a little confusing because it also has a comment in columns 2 and 3 of the table, but these are unrelated to the <comment> in column 1.
2. !var! (or !var1! or !var2!, etc.) lets you specify a variable in a code rule. The <declareVariable> special word specifies that the transformed code must declare a variable. <declareVariableType> specifies the data type for this new variable. You use !declaredVariable! in the code rule where you want the transformed code to use the new variable that was declared.
The example given is confusing because as you mention, is assigns a Boolean value to an Integer. A better example would be this one, from the actual CodeRules.txt file:<find> !currForm!.!var1!.HEIGHT(!var2!) <replace> !currForm!.!var1!.HEIGHT := !var2! <find> CurrForm.!var1!.HEIGHT; <declareVariable> !var1!Height <declareVariableType> Integer <replace> !declaredVariable!;
Then if you have code like this:OnRun=BEGIN … MESSAGE('Hello'); CurrForm.x.HEIGHT(NewHeight); MESSAGE('World'); END;
It would be transformed to this:VAR xHeight : Integer; OnRun=BEGIN … MESSAGE('Hello'); xHeight := NewHeight; MESSAGE('World'); END;
Hope that helps.
I have updated the Code Rules topic to try to make it clearer. The updated version will be available on MSDN (http://msdn.microsoft.com/en-us/library/dd338843.aspx) in a few months when we next update the Developer and IT Pro Help.Jill Frank
Senior Technical Writer
Microsoft Dynamics NAV0 -
first of all: Thanks for your answer, I appreciate it a lot that a MBS man is answering here.
@1.jillfrank wrote:1. Hello World in the first column is a comment in the CodeRules.txt file. You add comments to the CodeRules.txt file by using the <comment> special word and then writing your comment. Comments in the CodeRules.txt file are ignored when transforming code.
The example given is a little confusing because it also has a comment in columns 2 and 3 of the table, but these are unrelated to the <comment> in column 1.
You say the "//comment" in column two is not needed, but isn't this a integral part of the "code rule" itself. How can this be unrelated?
The "Hello World" in the last line of the first column freaks me out, what does it do?
Please don't wait for uploading the MBS in a few months... the partners and ISVs need this now.0 -
first of all: Thanks for your answer
<comment> in the first column specifies that the next line(s) of the CodeRules.txt file are comments. These lines don't map to anything in the code on the form. They are ignored by the transformation tool.
You could have something like this in the CodeRules.txt file:<find> x := z; <comment> This is a comment. I can write notes here about what this rule does. Until the transformation tool finds the next special word, all of these lines are parsed as comments. <replace> ;
The <comment> line and the next three lines are ignored. When the transformation tool gets to the <replace> line, it recognizes the <replace> special word and knows that the comments have ended.
The above is exactly the same rule as<find> x := z; <replace> ;
In the example from your original post:<find> x := z; <comment> Hello world
The Hello world line does nothing.
Also, since there is no <replace> in that example, the found line is deleted.
Make sense?Jill Frank
Senior Technical Writer
Microsoft Dynamics NAV0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions