Wrench value from your Creo Investments Home Measure the benefits Simple Automation can bring Why
A personal way to do PDM Peer to Peer
3D Drawings Model Based
Smooth out unwanted sharp edges Other
www.proetoolbox.co.uk - Simple Automation made Simple

Creating a Pro/Web.Link aware Text Editor

For years I have relied upon Notepad++ to write my Simple Automation applications. On one project I had the fortune to be requested to help develop some scripts using the AutoIT scripting toolset. This community had gone to the trouble of creating a custom editor for their language so that users of it could more quickly write, check and test code. One of the hurdles to learning AutoIT (or any new language for that matter) is simply getting rapid access to the command definitions. It has been communicated to me that Pro/Web.Link similarly can be a problem for the same reason. Furthermore once users had gained the confidence to build medium complexity applications, they found themselves making typos in the commands or half remembering the structure of parameters in a method. It became clear to me that it may be time to build a better editor.

The Choices

In many ways the choice I made to use SciTE (Scintilla Text Editor) was pre-ordained because the community at AutoIT used it. I was very apprehensive about moving away from Notepad++ however as it has been a joy to work with over the years. I'm sure that what I have acheived with SciTE is equally possible with Notepad++, but the documentation for SciTE is dramatically easier to read and understand.

One interesting fact about both Notepad++ and SciTE is that they are both users of the Scintilla Text editing component.


Desired Feature List

I chose to aim towards the following features.

  • Need to code highlight HTML, JavaScript.
  • Need to code highlight Pro/Web.Link commands.
  • Need to provide mechanism for auto-completing Pro/Web.Link commands.
  • Need to provide mechanism for showing call tips for Enumerated Values, Object Properties and Object Methods.
  • Wanted ability to speed code creation activities using Abbreviation expansion.
  • Wanted ability to replicate (the now apparently broken) 'Functions List' add-in for Notepad++.
  • Wanted ability to lookup info for a selected command on the page.
  • Desired ability to join up editor and Pro/E by forcing the page to open in Pro/E and vice versa.

    Code Highlighting

    Highlighting for HTML and JavaScript is built into SciTE as a default but I chose to tweak the settings as the JS font sizes were overwhelmed by the HTML elements. I simply had to redress that balance!


    Highlighting for Pro/Web.Link needed to be setup by tweaking the Global.properties files to include the Pro/Web.Link API.

    I extracted a summary of the Pro/Web.Link API by writing custom parsing scripts which reviewed each page of the API Browser from PTC. While I cannot guarantee that I have every single command, I'm likely very close.


    Auto-Completion & Call-Tips

    Provided the relevant properties files are configured in SciTE you can use the built-in auto-completion functionality and also the Call-tips functionality. As mentioned above generating these files was a matter of writing a couple of custom parsing scripts to review and extract information from PTC's Pro/Web.Link API Browser.

    To use Auto-completion, type e.g. 'GetPro', then press CNTL-I (or CNTL-SPACE). If your combination of characters results in no matches being found then nothing happens, if the combination results in multiple being found you are presented with a list as per the next picture and if only one match is found the full word is entered into your code.

    To use the command tips, simply type SPACE after the word and you will then be prompted with the command tip (call tip) for that command. You will notice that for methods the different areas of the parameters will highlight as you populate your code. I have formatted the tip to be the actual reference followed by [return info] and then the description. Should you wish to re-show the call-tip you can place your cursor inside the brackets for the method and then press CNTL-SHIFT-SPACE.


    Abbreviation Expansion for faster, better quality code writing

    I have configured a select few abbreviations (if, for, switch, function, try, while, WEBLINK) to aid Simple Automation Writers. To use the functionality type the abbreviation and then immediately press CNTL-B. This will replace the abbreviation with the 'template' text. The 'WEBLINK' abbreviation will expand into a base template for a Pro/Web.Link application.

    CNTL-B Expands to...


    'Functions List' Functionality

    Very often you forget exactly how to fill out your own Functions. I loved the Functions List add-in for Notepad++ and have missed it dearly since it stopped working with the newest build of Notepad++. A similar result has been acheived in the SciTE environment by leveraging the built in LUA scripting language capabilities in SciTE.


    Get Info

    *WIP* I have implemented two options for obtaining command help. First you can use CNTL-3 (Get Command Help) to obtain a brief set of info about the command in the output window without requiring another application. Or you can choose RMB/API Help to jump to the page in the API Browser that is the de-facto reference for that command. The first option has been acheived by writing a simple *AutoIT* program to read my API summary file (xml) and the second is a small customisation of the PTC API Browser so that it can be opened to a specific page.

    To get Brief Command Help, highlight the command then press CNTL-3 or Tools\Get Command Help. The info appears in the output pane on the right.

    To get API Command Help, highlight the command then press RMB/API Help or Help\SciTE Help. A browser is launched and the API Browser loads the relevant page for the command.


    Join up Editor and Pro/E

    *Work in Progress*



    There's quite a lot of changes to default SciTE to make the editor what it now is. I decided to add in some basic information in the output pane at start and also when the user presses CNTL-9 (or Tools\Start Page). This info lists in brief form how to operate the editor and it's more advanced functions.


    Having the best tools to hand is always a good way of improving your performance. Linking the Pro/Web.Link API Browser into the code editor can improve the quality of your code. Owners of the 'A Pro/ENGINEERS Guide to Pro/Web.Link' book can download this customised editor from Bonus Applications.