AdoScript Triggers

AdoScript functioality can be triggered in different ways. In the following the alternatives to include AdoScript in the implementation of a modelling toolkit are introduced.


AdoScript Trigger Classification

AdoScript via Menu Item

The library attribute "External coupling" of the dynamic sub-library allows to define new menu items for each component of the ADOxx Modelling Toolkit and assign AdoScript functionality to the item. By clicking on the item the AdoScript code specified is executed.

ITEM "ADOxx-Standard-Methode" acquisition:"~Hilfe" modeling:"~Hilfe"
    analysis:"~Hilfe" simulation:"~Hilfe"
    evaluation:"~Hilfe" importexport:"~Hilfe"
CC "Application" GET_PATH "adostd.hlp"
START ("\"" + path + "\"")

AdoScript on Event

AdoScript can be bound to events in ADOxx and be triggered accordingly. Events are categorized similar as AdoScript commands. The listener implementation is done in library attribute "External coupling" of the dynamic sub-library.

ON_EVENT "AppInitialized" {
#do smthg.

AdoScript via Notebook

In addition to menu items in the tool, buttons within the notebook of instances and models can be used to trigger AdoScripts. The attribute type "PROGRAMCALL" is used to assign AdoScript functionality within the notebook.


Trigger AdoScript during Startup - Command Prompt Handover

AdoScript integration is possible using command line parameter on startup of ADOxx based tools

ECHO CC "AdoScript" FREAD file:("batchupd.adoscript")
    EXECUTE (text) CC "Application" EXIT | areena -ubatchupd -pbatchupd
    -dADOxxdb -ssqlserver -e

The following command line parameters are available:





-e InlineHandOver or File Execution

Test AdoScript in Debug Shell

As a testing facility, the AdoScript Debug Shell can be used to run code snipplets within the modelling toolkit. The shell window is itself programmed in AdoScript. To integrate the shell, use the code below and add it to the library attribute "External coupling" of the dynamic sub-library resulting in a new sub-menu item called "Shell window" within the menu "Extras" of the modelling component.

ITEM "Shell window" modeling: "Extras" Menu Entry
SET endbutton:"ok"
WHILE (endbutton = "ok") {
  CC "AdoScript" EDITBOX text: (adoscript)
     title:"Enter the code you want to test..."
     fontname:"Arial" fontheight: 14
  IF ( endbutton = "ok") {
    SETG adoscript:(text)
Script Code for Shell Window


AdoScript Debug Shell


Icon Based Triggers

The command SET_ICON_CLICK_HDL changes the click handler (the function which is executed on a click) of a smart icon. Smart icons can be defined within the library attribute "External coupling" using the "AppInitialized" event.

CC "Application" [ raw* ] SET_ICON_CLICK_HDL [ component:Component ]
name:strValue { AdoScript }

Component: "acquisition" | "modeling" | "analysis" |"simulation" |
"evaluation" | "importexport" | "all"
--> RESULT ecode:intValue .

The name of a custom smart icon is the name specified at INSERT_ICON. The names of the built-in smart icons are listed in the SET_ICON_VISIBLE documentation.
* The raw argument at the CC element may be of importance here! Without specifying raw, variables used in the handler are replaced by the current values of these variables. If the handler just calls a global procedure without parameters, raw is not needed. In any other case raw is important to allow the definition of new variables in the script.

As an example, please find attached to this post a sample implementation that shows how to

  • Invoke a script within a file (scenario 2) from an icon
  • Invoke a script within the library attribute (scenario 3) an icon
  • Invoke the same script in an event handler

The sample code is also shown below. To include and test by yourself, please modify/add the following snipplet to the "External coupling" library attribute within the dynamic library.

ON_EVENT "AppInitialized" {

  # add an icon handler for the file-based execution
  CC "Application" INSERT_ICON component: "all"
name: "GetModelIDFileExecute"
text:"Get Model ID (execute file)"

  # here "raw" is not needed, since the file is handled as an
# encapsulated procedure
  CC "Application" SET_ICON_CLICK_HDL name:"GetModelIDFileExecute"  {
    EXECUTE file: ("db:\\HDLAdoScript.asc")
  # add an icon handler for the file-based execution
  CC "Application" INSERT_ICON component: "all" name: "GetModelIDAdoScriptExecute"
text:"Get Model ID (AdoScript in HDL)"
  # "raw" is important here, since the code should be interpreted and
# no variables are set
  CC "Application" raw SET_ICON_CLICK_HDL
name:"GetModelIDAdoScriptExecute" {
   CC "Modeling" GET_ACT_MODEL
    SET id_ActModel: ( modelid )
    CC "AdoScript" INFOBOX ("Return from direct invocation: " +
STR id_ActModel + "!")


ON_EVENT "AfterCreateModelWindow" {
#This event is triggered after a new model window was created in the
# modelling editor.
# modelid contains the model ID of the model in question.

  CC "AdoScript" INFOBOX "Execute during event from direct implementation"
  CC "Modeling" GET_ACT_MODEL
  SET id_ActModel: ( modelid )
  CC "AdoScript" INFOBOX ("Return from direct invocation (in event) " +
STR ( id_ActModel ) + "!")


Context Menu Item Trigger

The command in the message port "Application" INSERT_CONTEXT_MENU_ITEM inserts a new (custom) menu item into a context menu. 

CC "Application" INSERT_CONTEXT_MENU_ITEM context:Context
 [ pos:strValue ]
Context :   "drawingarea.general" | "drawingarea.mobject" |
"drawingarea.connector" | "drawingarea.swimlane" |
"modelingtable" |"explorer.db" | "" |
"startpage.thumb" .


For executing an AdoScript wiht this item SET_CMI_SELECT_HDL is used. It replaces the code which is executed on selection of a context menu item with an AdoScript.


CC "Application" [ raw* ] SET_CMI_SELECT_HDL context:Context item:strValue { AdoScript } .

Context :   "drawingarea.general" | "drawingarea.mobject" |
"drawingarea.connector" | "drawingarea.swimlane" |
"modelingtable" |"explorer.db" | "" |
"startpage.thumb" .


The example below shows how context menu triggers are used.

ON_EVENT "AppInitialized" {

CC "Application" INSERT_CONTEXT_MENU_ITEM context: "drawingarea.mobject"
item: "Create Comment"
CC "Application" SET_CMI_SELECT_HDL context: "drawingarea.mobject"
item: "Create Comment" {
 EXECUTE file: ("db:\\WriteComment.asc")


Average (0 Votes)
The average rating is 0.0 stars out of 5.