|
Working with the Basic Editor in ConceptDraw
The Professional edition of ConceptDraw starting from the version 5.0 contains a built-in editor for editing scripts written in ConceptDraw Basic. You can call the editor from the menus "Tools / ConceptDraw Basic / Application Script", "Tools / ConceptDraw Basic / Document Script", "Tools / ConceptDraw Basic / Page Script", "Tools / ConceptDraw Basic / Shape Script", depending on the execution level of the script you need to edit. Each of the menus contains the "Edit..." and "Remove"items. The "Edit..." item opens the Basic editor window with the script of the corresponding execution level. The "Remove" item removes the script of the chosen execution level.
The built-in CDBasic editor is a regular text editor with such editing functions as Copy, Cut, Paste, Find/Replace etc. The editor has its own main and context menus. The full list of menu commands of the CDBasic editor can be found in the following sections: "Basic Editor Menu" , "Basic Editor Context Menu", "Basic Output Context Menu"
Editing External Modules
The editor allows to edit scripts of both built-in and external modules. The script texts are stored in the UTF-8 encoding. In fact, you can use any editor, supporting the UTF-8 encoding, to edit ConceptDraw Basic scripts.
External modules can be connected by using the #Include statement. The main and context menu contain commands for working with external modules. So, the "File / Include Source..." command calls the Open dialog and inserts the #Include statement with the filename of the external module, chosen in this dialog. Such external module can be opened both from the "File / Open Script..." menu and the "File / Open Source" menu, if the insertion point is located in the line with the #Include statement. The "File / Exclude Source" command removes the #Include statement from the line with insertion point.
Compilation and Execution of Scripts
By choosing the "Build / Compile" command you can compile the source of the script to check it for syntax errors. Or you can run the program by using the "Build / Run" command. The source code of the script will be compiled, and if there are no errors, executed. If a script is resident or being executed, you can stop it by using the "Build / Stop" command.
You can also use the "CD Basic" toolbar to run and stop scripts. It contains three buttons; the "Run" and"Stop" do the same as the corresponding menu commands, and the "Pause" button suspends executing script for a while, showing a dialog with the corresponding message. On closing the dialog, execution of the script is resumed.
A script can be executed automatically when an object, containing the script is loaded. That means that an application-level script will run when you launch the application. When you load a document or created a document from a template , the document level script is launched automatically. Then, if the document-level script remains resident, the scripts at all page levels are executed subsequently, starting from the first page. Once a page-level program has been executed, and provided it remains resident (it wasn't stopped by the End statement), scripts of the shapes on the page are launched. A shape-level script is also started automatically, once the script-containing object has been inserted into the document from a library or duplicated.
To enable/disable automatic launching of scripts, use the corresponding flag in the application preferences, which are saved with the application.
CDBasic Output Window.
The "CDBasic Output" window is used by the program to display errors and warning and debug messages displayed with the Trace statement.
This service window can be enabled/disabled from the "Build / CDBasic Output Window"menu.
The CDBasic compiler displays service messages in the "CDBasic Output"window, and if any errors are found in the script during compiling, they are displayed as well. Normally an error message includes the error number, a short description and the module and line number, where the error occurred. If you double-click on such message, the editor opens the required module and places the insertion point into the line where the error was found.
Going to the Specified Line of a Script
Sometimes when you edit a script you may need to go to a certain line of the code. For instance, when you get a run-time error, it may include the number of the line in the code, where the error occurred. You can navigate to the desired line in the editor window, by using the "Line Number" dialog, called from the "Edit / Go To Line..."menu of the editor.
|