How to extend your editor in Axapta
The editor in Axapta is as easy to extend as the rest environment. If you check the class EditorScripts, you see a list of methods which is standard. In this example we add a little script which marks your inputed extra code. We always mark all added or changed code, to make it easier to see afterwards what’s added and what’s standard. By doing this it is also makes it very easy to search for all code related to a certain project. This code is an example of what we all use several times a day.
It get’s it’s data from the standard user forms. Here we use the email field to store and get companyname and user-initial from, but you could extend this even more if you like.
To use it, add below code to you EditorScripts class in your environment. Go to Tools, Options and input your initial in the EMail field. Switch to the Developing tab and select a project plus click the save button. Mark a few lines of code in any editor window, right click and select “Scripts” from the option menu. Right under there this script should show with the name FOBeginEnd. When you click on the name, below code fill in the comments you see here, before and after your marked lines.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | // START 070307 FourOne/HL (FO_EditorAddOns4) // -- Description: void FOBeginEnd(Editor e) { int startLine = e.selectionStartLine(); int endLine = e.selectionEndLine(); str sToday = substr(date2str(today(), 321,2,0,2,0,4),3,6); str sCompanySlashUserId, sProject; str getNameFromEmailField() { SysUserInfo sys; ; select * from sys where sys.id == curuserid(); return sys.Email; } str getCurrentProject() { UserInfo userInfo; ; select * from userInfo where userInfo.id == curuserid(); return userinfo.startupProject; } ; sCompanySlashUserId = getNameFromEmailField(); sProject = getCurrentProject(); e.unmark(); e.gotoLine(startline); e.gotoCol(1); e.insertLines("// START " + sToday + " " + sCompanySlashUserId + " (" + sProject + ")\n" + "// -- Description: \n"); e.gotoLine(endline+2); e.gotoCol(1); e.insertLines("// END " + sToday + " " + sCompanySlashUserId + " (" + sProject + ")\n"); } // END 070307 FourOne/HL (FO_EditorAddOns4) |
March 23rd, 2008 at 19:59
does anyone knows if there is any other information about this subject in other languages?
October 28th, 2008 at 20:36
Great work.
April 15th, 2009 at 17:35
Not that I’m totally impressed, but this is more than I expected when I stumpled upon a link on Delicious telling that the info is quite decent. Thanks.