Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
mscripteditor [2017/12/22 02:21]
admin [Open MScript Editor]
— (current)
Line 1: Line 1:
-===== MScript Editor ===== 
-//MScript Editor// is a full-feature source code editor (xml scripting) that allows you to view and edit [[mScriptTags|MScript]] for each trigger point or MScript for the entire model. 
- 
-It offers code-assist (ctrl-space), syntax highlight, search/replace, undo/redo, code collapse/expand, set breakpoint for debugging. It can also generate Program Structure Diagram for the trigger script as well as Call Hierarchy Diagram. 
- 
-During and after model execution, it can display the script test coverage. 
- 
- 
-{{http://TestOptimal.com/img/mscriptEditor.png}} 
- 
----- 
-==== Open MScript Editor ==== 
-//MScript Editor// is a tab which can be placed in any of the 3 panes.  By default, //MScript Editor// is placed in the //bottom right pane//. 
- 
-When you click /select a state or transition, //MScript Editor// automatically loads the MScript for the corresponding state or transition.  
- 
-Changes are automatically pushed to the server when you move focus to other tabs in the IDE. 
- 
----- 
-==== Editing Triggers ==== 
-There are many [[Triggers|System Defined Triggers]] for each state, transitions as well at model level.  You can write MScript for each of these triggers by selecting the trigger name from the drop-down list of triggers. 
- 
-You may also view / edit MScript for the entire model by selecting the //model// in the trigger drop-down list.  
- 
-Editor allows you to check MScript syntax. To do so, click {{http://testoptimal.com/img/compile.png}}.  The error will be highlighted and there will be a set of buttons on the editor header to let you navigate through all errors (previous and next). 
- 
- 
-=== User Define Triggers=== 
-You may also create your own trigger using [[User Defined Trigger|User Defined Trigger]].  To define a //User Define Trigger//, hover mouse over {{http://testoptimal.com/img/more.png}} on the upper right corner of the editor and select //Add Trigger// You will be prompted to name the trigger. 
- 
-The new trigger will be added to the trigger drop-down list available for you to choose to add MScript. 
- 
-=== Program Structure Diagram=== 
-You can generate [[Program Structure Diagram|Program Structure Diagram]] for the selected trigger.  //Program Structure Diagram// is a good way to visualize MScript.  It helps you to get an overall view of your MScript and make it much easier to find coding mistake and logic errors. 
- 
-To generate the //Program Structure Diagram//, hover mouse over {{http://testoptimal.com/img/more.png}} on the upper right corner of the editor and select //Program Structure Diagram// option. The //Program Structure Diagram// should open in a separate browser window (or browser tab). 
- 
-=== Trigger Call Hierarchy Diagram === 
-//MScript// provides a function to call another trigger. This allows you to execute same trigger from different triggers.  You can generate the call hierarchy diagram that describes the flow of triggers calling other triggers. 
- 
-To generate the [[Trigger Call Hierarchy Diagram]], edit the trigger which you want to use as the starting trigger in //Trigger Call Hierarchy Diagram//. Then mouse over {{http://testoptimal.com/img/more.png}} on the upper right corner of the editor and select //Call Hierarchy Diagram// option. The //Trigger Call Hierarchy Diagram// should open in a separate browser window (or browser tab). 
- 
- 
- 
- 
-===User Defined Functions=== 
-You may create [[User Defined Functions|User Defined Functions]] that can be called anywhere in the model. These functions are declared in //Function// trigger. 
- 
----- 
-==== Shortcut Keys ==== 
-MScript editor supports [[MScript Editor ShortCut Keys|MScript Editor Shortcut Keys]] that allow you to perform basic editor functions with keyboard keys, e.g. //ctrl-F// for find, //ctrl-Space// for code-assist, etc. 
- 
----- 
- 
-====Code Assist==== 
-//Code Assist// is supported.  By pressing //ctrl-space//, a popup list is displayed showing the list of suggested mscript functions or constants that can be inserted into the editor or replace the selected mscript text in the editor.  //Code Assist// is context sensitive, that is, the content of the list displayed is dependent on what element the cursor is currently on in the editor.  
- 
- 
-{{http://testoptimal.com/img/MScriptEditor_CodeAssist.jpg}} 
- 
- 
-For example, if the cursor is on a blank line, the //Code Assist// list will be populated with list of mscript tags.  If the cursor is inside the //op// attribute of a //assert// tag, then the popup list will be populated with compare operators available: //eq//, //lt//, //gt//, etc. 
- 
-Below are the description of different //Code Assist// context supported with //ctrl - space// pressed: 
- 
-  * on a blank line - brings up the list of mScript tags. The selected tag is inserted with all attributes set to empty string. 
- 
-  * in an attribute value (between double quotes), code assist brings up the list of mScript methods. For some special attribute like //op//, a special list of values may be presented instead of mScript method list. 
- 
-With //ctrl-space//, it brings up a list of mscript functions that include both //system functions// and //plugin functions// as noted in the header of the popup.  Alternatively you may use //ctrl-S// to bring up just //system functions// and //ctrl-p// to bring up just //plugin functions//. 
- 
- 
- 
----- 
-==== Search / Replace Text ==== 
-Editor supports plain text match search / replace and regular expression search / replace.  
- 
-{{http://testoptimal.com/img/MScript_SearchReplace.png}} 
- 
-=== How to Invoke Search/Replace === 
-To invoke search and/or replace, just press //ctrl-F// when //MScript Eitor// has the focus or clicking on the search button above the editor area {{http://testoptimal.com/img/search.png}}. 
- 
-//Search and Replace// is displayed right above the editor area when invoked.  You may close //Search and Replace// by clicking on the close control on the far right or clicking anywhere in the while space area within //Search and Replace//. 
- 
-You must run the search first, once you've found the first match, you may then replace the matched text (selected) with the replacement string.  
- 
-There are different search criteria supported as described in //Search Text// section below. 
- 
-=== Searching Text === 
-Enter a text into the search field to start the search.  As you type search text into the search field, the editor will try to match the text you have entered and highlight the matches automatically with the first matched text highlighted in darker color. 
- 
-Last searched text is remembered and will be displayed as default value when the //Search and Replace// is invoked again. 
- 
-== Next / Previous == 
-To navigate through the matched texts in the editor, use the two navigation button next to the search field. 
- 
-While the cursor is in the search text field, you may use //Enter// or //down arrow// key to go to next match and //up arrow// to the previous match. 
- 
- 
-== Case Sensitive or Insensitive == 
-By default, the search is case sensitive if the search text contains one or more characters in uppercase.  To perform case insensitive search, enter the search text in lowercase. 
- 
-== Regular Expression == 
-//Regular expression// search is also supported.  To perform //regular expression// search, enclose the //regular expression// in a set of forward slash (/) like ///[0-9][a-z]/// 
- 
- 
-=== Replacing Text === 
-When you have found a match with //Search//, you can enter a replacement text.  
- 
-As you enter the replacement text, two buttons //R// and //RR// will be displayed to the right of the replacement field.   
- 
-== Single Replacement == 
-Use the button //R// to perform the replacement on the current matched text (darker shade) at the same time move the current selection to the next matched text in the direction used in the last search. 
- 
-Alternatively you can use //Enter// key to perform the replacement.  
- 
-While the cursor is in the replacement field, you may use //down arrow// key to go to next match and //up arrow// to the previous match without performing the replacement. 
- 
-Use //Search// buttons to change the direction for the next replacement. 
- 
- 
-== Replace All == 
-You may replace all matched texts in the direction of last search by clicking on the //RR// button. 
- 
-To replace matched texts in the other direction, just click on one of the search button to find the next match and then click on //RR// to replace all matched texts. 
- 
-The number of replacements performed is displayed next to the replacement buttons. 
- 
- 
- 
----- 
- 
-====MScript Macro==== 
-You may define a set of macros to encapsulate a set of frequently used MScript. This is done via editing the //CAMacro.properties// in //config// folder. 
- 
-You may add tooltip to each of the macro by appending //@tooltip:my tool tip msg// to the end of the macro line. 
- 
-Macro file //CAMacro.properties// can include other files by adding the following: 
- 
-     include=file1,file2 
- 
-To call up macros, press //ctrl+M// (or //alt+M//). 
- 
----- 
- 
-====Requirements Tags==== 
-If you have configured the interface to your requirements system, you may bring up a list of requirements by pressing //ctrl+R// (or //alt+R//). For more information about how to configure //TestOptimal// to access your requirements system, please see [[alm_configuration | ALM Configurarion]]. 
- 
- 
- 
----- 
-====Commenting MScripts==== 
- 
-  * code comments can added using xml comment tag. See an example below: 
- 
-     <!-- your comments goes here --> 
- 
-  * you can add as many comments you would like anywhere in the mscript triggers. 
-  * you can continue to use //comment// parameter, but commenting using xml comment tag is recommended. 
-  * you may have the comments written out to an output file as MScript is executed. By default writing comments to an output file is off. It can be turned on with MScript function //$enableCommentToSeqOut()// or turned off with //$isableCommentToSeqOut()//. 
- 
----- 
- 
-====Debugging MScript==== 
- 
-You can set breakpoint on MScript line by clicking on the line number column on the left of the editor. If MScript spans multiple lines, the breakpoint can only be set on the first line of the MScript. 
- 
----- 
- 
-====MScript File==== 
- 
-//MScript// is stored in //mscript.xml// in the model folder. You can certainly use third party xml editor to edit the MScript. If you do so, be aware that you must save the changes and reload the model in order for //TestOptimal// to see your changes. 
- 
----- 
-==== MScript Coverage==== 
-New in release 4.2, the system automatically collects execution coverage of each MScript tag during the model execution.  The execution coverage of MScript tags can then retrieved and displayed in editor. 
- 
-To retrieve MScript coverage metrics, select //MScript Coverage// from the drop-down menu at the upper-right corner of the editor. 
- 
-=== Coverage Metrics === 
-The system collects the number of times each MScript tag is executed.  For MScript container tags like //if// and //while// that contain other MScript tags, the coverage is also presented. 
- 
-The coverage metrics are then displayed with two additional mscript attributes: //execCount// and //coverage//. 
- 
-  * //execCount// - number of times the MScript tag has been executed. 
-  * //coverage// - percentage of child MScript tags that have been executed.