### Example: Get all versions of the first attribute profile Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_ALL_ATTRPROF_VERSIONS_OF_THREAD.html This example demonstrates how to retrieve all attribute profile versions for the first thread found in the first root directory. It includes error handling for preceding commands. ```ado-script # get root directories CC "Core" GET_ALL_ATTRPROF_VERSIONS_OF_THREAD apthreadid:(VAL token(apthreadids,0," ")) IF (ecode!=0) { CC "AdoScript" ERRORBOX ("Error in GET_ALL_ATTRPROF_VERSIONS_OF_THREAD!") EXIT } CC "AdoScript" INFOBOX ("Verions of first attribute profile:\n"+apversionids) ``` -------------------------------- ### ADOxx Example: Get All Attribute Profile Threads in Root Directory Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_ALL_ATTRPROF_THREADS_IN_DIR.html This example demonstrates how to get all attribute profile threads in the first root directory. It includes error handling and displays the found threads. ```asc # get root directories CC "Core" GET_ALL_ATTRPROF_SUBDIRS # get all attribute profile threads in first root directory CC "Core" GET_ALL_ATTRPROF_THREADS_IN_DIR apdirid:(VAL token(apdirids,0," ")) IF (ecode!=0) { CC "AdoScript" ERRORBOX ("Error in GET_ALL_ATTRPPROF_THREADS_IN_DIR!") EXIT } CC "AdoScript" INFOBOX ("Folloing attribute profile threads were found in the root directory:\n"+apthreadids) ``` -------------------------------- ### ACTIVATE_COMPONENT Example Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/ACTIVATE_COMPONENT.html An example demonstrating how to use the ACTIVATE_COMPONENT command in ADOxx scripting. ```ado-script CC "Modeling" ACTIVATE_COMPONENT ``` -------------------------------- ### Example: Creating and Managing AttrProf Versions Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/CREATE_ATTRPROF_VERSION.html Demonstrates a sequence of operations including creating new AttrProf versions, retrieving thread IDs, renaming threads, and deleting versions and threads. This snippet requires prior setup to obtain necessary IDs. ```asc # determine all directories of the root group CC "Core" GET_ALL_ATTRPROF_SUBDIRS SET apdirid:(VAL token (apdirids, 0, " ")) # get all threads in the first group CC "Core" GET_ALL_ATTRPROF_THREADS_IN_DIR apdirid:(apdirid) SET apthreadid:(VAL token (apthreadids, 0, " ")) # determine the class of the first AttrProf in the first group CC "Core" GET_ATTRPROF_CLASS_OF_THREAD apthreadid:(apthreadid) SET apclassid:(apclassid) # now we're ready to create a new AttrProfVersion CC "Core" debug CREATE_ATTRPROF_VERSION_EXT apclassid:(apclassid) apdirid:(apdirid) apthreadname:"Foo" apversionstr:"00000405" # get thread id and store it CC "Core" GET_ATTRPROF_THREAD_OF_VERSION apversionid:(apversionid) SET mythread:(apthreadid) # create another version CC "Core" debug CREATE_ATTRPROF_VERSION apthreadid:(apthreadid) apversionstr:"00000706" # keep version id in mind SET myversion:(apversionid) # create a third version CC "Core" debug CREATE_ATTRPROF_VERSION apthreadid:(apthreadid) apversionstr:"00000806" # rename thread (-> and all versions!) CC "Core" debug RENAME_ATTRPROF_THREAD apthreadid:(apthreadid) apthreadname:("Renamed Foo2!") # delete version which we kept in mind CC "Core" debug DELETE_ATTRPROF_VERSION apversionid:(myversion) # delete whole thread CC "Core" debug DELETE_ATTRPROF_THREAD apthreadid:(mythread) ``` -------------------------------- ### Example Usage of MINIMIZE_ALL Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/MINIMIZE_ALL.html This example demonstrates how to use the MINIMIZE_ALL command to minimize all open models. ```asc CC "Modeling" MINIMIZE_ALL ``` -------------------------------- ### Example: Displaying a Specific Notebook Chapter and Page Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/SHOW_NOTEBOOK_CHAPTER.html This script demonstrates how to get the current model, retrieve all objects, execute a notebook, and then display a specific chapter and page from that notebook. It includes error handling for model activation and object retrieval. Finally, it closes all notebooks. ```ado-script # get the current model SEND "GET_ACTIVE_MODEL" to:"Modeling" answer:modelid IF (modelid = "") { CC "AdoScript" ERRORBOX "Open a model first!" EXIT } # get all objects CC "Core" GET_ALL_OBJS modelid:(VAL modelid) IF (ecode != 0) { CC "AdoScript" ERRORBOX "Something went very wrong here (e.g. we passed the wrong model id)!\n" EXIT } CC "Modeling" EXEC_NOTEBOOK objid:(VAL token(objids,1," ")) CC "Modeling" SHOW_NOTEBOOK_CHAPTER objid:(VAL token(objids,1," ")) chapter:1 chapter-page:2 CC "AdoScript" INFOBOX "Now one notebook in the model should be executed and the second page of the first chapter should be shown!" CC "Modeling" CLOSE_ALL_NOTEBOOKS modelid:(VAL modelid) ``` -------------------------------- ### ADOxx Script Example: Listing All Application Models Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_ALL_APPMODEL_IDS.html This script retrieves all application models using GET_ALL_APPMODEL_IDS, then iterates through them to get details using GET_APPMODEL_INFO, and finally displays the names in an infobox. It demonstrates how to process the returned list of appmodel IDs. ```asc SET sAppModels:("All Application Models:\n\n") CC "Core" GET_ALL_APPMODEL_IDS FOR appModelId in:(appmodelids) { CC "Core" GET_APPMODEL_INFO appmodelid:(VAL appModelId) IF (onversions) { SET sAppModels:(sAppModels + appname + "\n") } } CC "AdoScript" INFOBOX (sAppModels) ``` -------------------------------- ### ADOxx Get User Name Example Source: https://adoxx.org/adoscript_reference/20_message_ports/UsrMgt/GET_USER_NAME.html This example demonstrates how to get a user's name using GET_USER_NAME or GET_SYSUSER_INFO based on whether the user is a system user or an ADOxx user, and then displays a greeting. ```ado-script CC "UserMgt" GET_CURRENT_USER_ID IF (usertype = "system") { CC "UserMgt" GET_SYSUSER_INFO userid:(userid) SET n:(cond(?logon-name-type = "samaccountname", username + "@" + domain, domain + "\" + username)) } ELSE { CC "UserMgt" GET_USER_NAME userid:(userid) SET n:(username) } CC "AdoScript" INFOBOX ("Hello " + n + "!") ``` -------------------------------- ### Example: Position and Resize Notebook to Full Screen Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/SET_NOTEBOOK_POS.html This example demonstrates how to execute a notebook, position it at (0,0), resize it to fit the screen, and then close all notebooks. It includes error handling for model activation and object retrieval. ```asc # get the current model SEND "GET_ACTIVE_MODEL" to:"Modeling" answer:modelid IF (modelid = "") { CC "AdoScript" ERRORBOX "Open a model first!" EXIT } # get all objects CC "Core" GET_ALL_OBJS modelid:(VAL modelid) IF (ecode != 0) { CC "AdoScript" ERRORBOX "Something went very wrong here (e.g. we passed the wrong model id)!\n" EXIT } SET myObjId:(VAL token(objids,1," ")) CC "Modeling" EXEC_NOTEBOOK objid:(myObjId) CC "Modeling" SET_NOTEBOOK_POS objid:(myObjId) x:(0) y:(0) CC "Application" GET_SCREEN_RES CC "Modeling" SET_NOTEBOOK_SIZE objid:(myObjId) w:(w) h:(h) CC "AdoScript" INFOBOX "Now one notebook in the model should be executed and fit the whole screen!" CC "Modeling" CLOSE_ALL_NOTEBOOKS modelid:(VAL modelid) ``` -------------------------------- ### Calling Quicksort Example Source: https://adoxx.org/adoscript_reference/01_adoscript/AdoScript_Examples.html Demonstrates how to prepare a string for Quicksort by replacing delimiters and then calling the Quicksort procedure. ```AdoScript SET text:("Caesar,Nero,Titus,Trajan,Konstantin,Augustus") SET text:(replall(text, ",", "\n")) QUICKSORT list:text start:0 end:(tokcnt(text, "\n")) CC "AdoScript" INFOBOX (text) ``` -------------------------------- ### Example Usage of GET_FACET_ENUMERATIONDOMAIN Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_FACET_ENUMERATIONDOMAIN.html This example demonstrates how to use GET_FACET_ENUMERATIONDOMAIN to retrieve an enumeration domain facet. It first gets a class ID, then an attribute ID, and finally uses GET_FACET_ENUMERATIONDOMAIN to get the facet value, which is then displayed using INFOBOX. ```asc CC "Core" GET_CLASS_ID classname:"Ende" CC "Core" GET_ATTR_ID attrname:"Typ" classid:(classid) CC "Core" GET_FACET_ENUMERATIONDOMAIN attrid:(attrid) CC "AdoScript" INFOBOX (val) ``` -------------------------------- ### Full Example: Creating, Populating, Selecting, and Showing a TreeListBox Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/TLB_SELECT_ALL.html This example demonstrates how to create a TreeListBox, insert entries, select all entries using TLB_SELECT_ALL, expand all, and then display the TreeListBox. It also includes error handling based on the return code. ```AdoScript # create the main TreeListBox with all its parameters CC "AdoScript" TLB_CREATE title:"My title" oktext:"Close" canceltext:"No way!" boxtext:"These are my entries" no-help:1 button-w:60 max-w:500 max-h:367 min-w:200 min-h:150 checklistbox:1 # insert some entries (as you like - ID should be unique) CC "AdoScript" TLB_INSERT id:1 is-parent:1 text:"Do this" CC "AdoScript" TLB_INSERT id:2 text:"Do that" # select all entries CC "AdoScript" TLB_SELECT_ALL CC "AdoScript" TLB_EXPAND_ALL # and finally show it CC "AdoScript" TLB_SHOW IF (ecode = 0) { CC "AdoScript" INFOBOX ("Selected ids: " + selectedids + "\n" + "You pushed the following button: " + endbutton) } ELSE { CC "AdoScript" INFOBOX ("You cancelled the dialog!") } ``` -------------------------------- ### Full Example: Create, Insert, Select, and Show TreeListBox Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/TLB_SHOW.html Demonstrates the complete workflow of creating a TreeListBox, inserting entries, selecting an entry, and then displaying the dialog using TLB_SHOW. Includes handling of return values. ```AdoScript # create the main TreeListBox with all its parameters CC "AdoScript" TLB_CREATE title:"My title" oktext:"Close" canceltext:"No way!" boxtext:"These are my entries" no-help:1 button-w:60 max-w:500 max-h:367 min-w:200 min-h:150 checklistbox:1 # insert some entries (as you like - ID should be unique) CC "AdoScript" TLB_INSERT id:1 text:"Do this" CC "AdoScript" TLB_INSERT id:2 text:"Do that" # select the first entry (here: check it) CC "AdoScript" TLB_SELECT id:1 select:1 # and finally show it CC "AdoScript" TLB_SHOW IF (ecode = 0) { CC "AdoScript" INFOBOX ("Selected ids: " + selectedids + "\n" + "You pushed the following button: " + endbutton) } ELSE { CC "AdoScript" INFOBOX ("You cancelled the dialog!") } ``` -------------------------------- ### Get and Display Temporary Filename in AdoScript Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/GET_TEMP_FILENAME.html This example demonstrates how to get a temporary filename using GET_TEMP_FILENAME and then display it in an infobox. ```AdoScript CC "AdoScript" GET_TEMP_FILENAME CC "AdoScript" INFOBOX ("The temporary file name is: " + filename) ``` -------------------------------- ### Get Attribute Profile Class of Thread Example Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_ATTRPROF_CLASS_OF_THREAD.html This example demonstrates how to retrieve the class ID of an attribute profile thread. It first gets all subdirectories, then all threads in a directory, selects the first thread, retrieves its class ID using GET_ATTRPROF_CLASS_OF_THREAD, and finally displays the class ID. ```adoScript # get root directory id CC "Core" GET_ALL_ATTRPROF_SUBDIRS # get all attribute profile threads in this directory CC "Core" GET_ALL_ATTRPROF_THREADS_IN_DIR apdirid:(VAL token(apdirids,0," ")) # pick the first thread SET mythread:(token(apthreadids,0," ")) # get its class CC "Core" GET_ATTRPROF_CLASS_OF_THREAD apthreadid:(VAL mythread) # show this class id CC "AdoScript" INFOBOX ("ClassID: "+(STR apclassid)) ``` ```adoScript # get all versions of first thread CC "Core" GET_ALL_ATTRPROF_VERSIONS_OF_THREAD apthreadid:(VAL mythread) # pick first verison SET myversion:(token(apversionids,0," ")) # get its class id CC "Core" GET_ATTRPROF_CLASS_OF_VERSION apversionid:(VAL myversion) # show this class id CC "AdoScript" INFOBOX ("ClassID: "+(STR apclassid)) ``` -------------------------------- ### Example: Setting View Mode Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/SET_VIEW_MODE.html This example demonstrates how to set the current view mode using the SET_VIEW_MODE command. It retrieves all view modes and then sets the mode based on a tokenized input. ```asc CC "Modeling" GET_ALL_VIEW_MODES CC "Modeling" SET_VIEW_MODE mode-name:(token(modename,1,"\n")) ``` -------------------------------- ### Get ADOxx Installation Directory Path Source: https://adoxx.org/adoscript_reference/20_message_ports/Application/GET_PATH.html Retrieves the absolute path to the ADOxx installation directory. This is useful for accessing core application files or configuration. ```adoscript CC "Application" debug GET_PATH ``` -------------------------------- ### Read File Content and Display Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/FREAD.html This example demonstrates creating a file, writing content to it, reading it back, and displaying the content in an INFOBOX. It shows the basic usage of FWRITE and FREAD. ```AdoScript CC "AdoScript" FWRITE file:"C:\\temp\\text.txt" text:"Hello World" CC "AdoScript" FREAD file:"C:\\temp\\text.txt" CC "AdoScript" INFOBOX (text) ``` -------------------------------- ### Example Usage of GET_NEXT_SWIMLANE Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/GET_NEXT_SWIMLANE.html This example demonstrates how to call the GET_NEXT_SWIMLANE function without specifying a particular swimlane object ID, likely to get the next swimlane in a default context. ```ado-script CC "Modeling" GET_NEXT_SWIMLANE ``` -------------------------------- ### Example: Get Referenced Attribute Profile Version ID Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_REFERENCED_ATTRPROF_VERSION_ID.html This example demonstrates how to use GET_REFERENCED_ATTRPROF_VERSION_ID within a script. It includes checks for model, class, object, and attribute existence before calling the command. The example uses debug to show the command's execution. ```AdoScript SEND "GET_ACTIVE_MODEL" to:"Modeling" answer:modelid IF (modelid = "") { CC "AdoScript" ERRORBOX "Open a model first" EXIT } CC "Core" GET_CLASS_ID classname:"Klasse mit allen Attributtypen" IF (ecode != 0) { CC "AdoScript" ERRORBOX "Your library does not contain a class called Aktivität!\n" EXIT } CC "Core" GET_OBJ_ID modelid:(VAL modelid) classid:(classid) objname:"Sepp" IF (ecode != 0) { CC "AdoScript" INFOBOX ("Your model does not contain an 'Klasse mit allen Attributtypen' 'Sepp'!\n"+ "Please model one and then rerun the script.") EXIT } CC "Core" GET_ATTR_ID classid:(classid) attrname:"Attributprofilreferenz für Test" IF (ecode != 0) { CC "AdoScript" INFOBOX "no such attr 'Attributprofilreferenz für Test'" EXIT } CC "Core" debug GET_REFERENCED_ATTRPROF_VERSION_ID modelid:(VAL modelid) objid:(objid) attrid:(attrid) ``` -------------------------------- ### AdoScript Example: Create and Remove Directory Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/DIR_REMOVE.html This example demonstrates how to create a directory using DIR_CREATE and then remove it using DIR_REMOVE. It includes checks for successful creation and removal, providing feedback via INFOBOX. ```AdoScript CC "AdoScript" DIR_CREATE path:("c:\\temp\\testdir") IF (ecode = 0) { CC "AdoScript" DIR_REMOVE path:("c:\\temp\\testdir") IF (ecode = 0) { CC "AdoScript" INFOBOX ("Directory successful removed.") } ELSE { CC "AdoScript" INFOBOX ("Directory could not be removed.") } } ELSE { CC "AdoScript" INFOBOX ("Directory already exists or cannot be created.") } ``` -------------------------------- ### Example: Renaming Objects in the Active Model Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/RUN_NAME_GENERATION.html This AdoScript example demonstrates how to get the active model's ID, run the name generation, and display the number of renamed objects or an error message. ```adoScript # Get the model id of the currently active model: SEND "GET_ACTIVE_MODEL" to:"Modeling" answer:modelid SET n_mid:(VAL modelid) # Name the objects in the model: CC "Modeling" RUN_NAME_GENERATION modelid:(n_mid) IF (ecode != 0) { CC "AdoScript" ERRORBOX "[mynamegen-01]\nDie Objektnamen konnten nicht erzeugt werden." title:"Error" EXIT } # Inform user how many objects have been renamed: CC "AdoScript" INFOBOX "Es wurden " + STR changes + " Objekte neu benannt." ``` -------------------------------- ### Create Directory and Check Status Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/DIR_CREATE.html Demonstrates how to create a directory using DIR_CREATE and then check the returned error code to provide user feedback. ```AdoScript CC "AdoScript" DIR_CREATE path:"c:\\temp\\testdir" IF (ecode = 0) { CC "AdoScript" INFOBOX "Directory successful created." } ELSE { CC "AdoScript" INFOBOX "Directory could not be created." } ``` -------------------------------- ### Example: Getting the Parent Modelgroup Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_MODELGROUP_PARENT.html Demonstrates how to use GET_MODELGROUP_PARENT to find the parent model group. This example first allows user selection of a model group, then retrieves its parent's name, and displays it. ```leo-grammar # let the user select a modelgroup CC "CoreUI" MODEL_SELECT_BOX without-models mgroup-sel # get the name of the parent modelgroup CC "Core" GET_MODELGROUP_PARENT mgroupid:(VAL token(mgroupids,0," ")) IF (ecode = 0) { CC "Core" GET_MODELGROUP_NAME mgroupid:(parentmgroupid) } # display the name IF (ecode = 0) { IF (mgroupname = "root") { CC "AdoScript" INFOBOX "You selected a top-level modelgroup!" } ELSE { CC "AdoScript" INFOBOX ("The selected the modelgroup is within " + mgroupname) } } ``` -------------------------------- ### Example: Using TLB_EXPAND_ALL in AdoScript Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/TLB_EXPAND_ALL.html This example demonstrates how to create a TreeListBox, insert entries, expand all entries using TLB_EXPAND_ALL, select an entry, and then display the TreeListBox. It also shows how to handle the return code and display information based on user interaction. ```AdoScript # create the main TreeListBox with all its parameters CC "AdoScript" TLB_CREATE title:"My title" oktext:"Close" canceltext:"No way!" boxtext:"These are my entries" no-help:1 button-w:60 max-w:500 max-h:367 min-w:200 min-h:150 checklistbox:0 # insert some entries (as you like - ID should be unique) CC "AdoScript" TLB_INSERT id:1 text:"Do this" is-parent:1 CC "AdoScript" TLB_INSERT id:3 parentid:1 text:"here" CC "AdoScript" TLB_INSERT id:2 text:"Do that" CC "AdoScript" TLB_EXPAND_ALL # select the first entry (here: check it) CC "AdoScript" TLB_SELECT id:3 select:1 # and finally show it CC "AdoScript" TLB_SHOW IF (ecode = 0) { CC "AdoScript" INFOBOX ("Selected ids: " + selectedids + "\n" + "You pushed the following button: " + endbutton) } ELSE { CC "AdoScript" INFOBOX ("You cancelled the dialog!") } ``` -------------------------------- ### Example: Retrieving EXPRESSION Attribute Values Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_EXPR_TEXT.html This example demonstrates how to get the value of an instance attribute and the default value of a class attribute of type EXPRESSION. It includes error handling and displays the retrieved values. ```asc # get all selected objects CC "Modeling" GET_SELECTED IF (objids = "") { CC "AdoScript" ERRORBOX "Select an instance first!" EXIT } # from the list of selected objects, extract the first objectid SET firstselected:(token(objids,0," ")) # now get the classes of the connected instances CC "Core" GET_CLASS_ID objid:(VAL firstselected) # get all attributes of the selected class CC "Core" GET_ALL_ATTRS classid:(classid) # get types of attributes FOR id in:(attrids) { CC "Core" GET_ATTR_TYPE attrid:(VAL id) IF ((attrtype)="EXPRESSION") { # get attribute value CC "Core" GET_EXPR_TEXT objid:(VAL firstselected) attrid:(VAL id) IF ((ecode)!=0) { CC "Core" GET_CLASS_NAME classid:(classid) CC "AdoScript" ERRORBOX ("Error in GET_EXPR_TEXT for object "+(classname)+""") EXIT } # show value CC "AdoScript" INFOBOX ("ExprValue: "+(expr)+""") # get class default value CC "Core" GET_EXPR_TEXT classid:(classid) attrid:(VAL id) IF ((ecode)!=0) { CC "AdoScript" ERRORBOX ("Error in GET_EXPR_TEXT for class "+(classname)+""") EXIT } # show default value CC "AdoScript" INFOBOX ("Default Value: "+(expr)+""") EXIT } } CC "AdoScript" ERRORBOX ("No attributes of type EXPRESSION found!") ``` -------------------------------- ### Execute Printer Setup Dialog and Check Result Source: https://adoxx.org/adoscript_reference/20_message_ports/Application/EXEC_PRTSETUP_DLG.html This snippet demonstrates how to open the printer setup dialog using EXEC_PRTSETUP_DLG and then checks if the user confirmed the dialog by pressing 'OK'. It's useful for conditionally proceeding with actions after printer configuration. ```AdoScript #Opening the printer setup dialog SEND "EXEC_PRTSETUP_DLG" to:"Application" answer:button IF (button = "OK") { CC "AdoScript" INFOBOX "Yeah! The user closed the printer dialog with the OK button!" } ``` -------------------------------- ### Full Example: Copy, Create, Paste, Save, and Open Model Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/PASTE_COPYBUFFER.html This comprehensive example demonstrates the workflow of copying all objects and relations from the current model, creating a new model, pasting the copied content twice into the new model, saving and discarding the new model, and then opening it in view mode to select the pasted objects. ```AdoScript ## 1. take the currently open model ## 2. copy all objects and all relation instances ## 3. create a new model ## 4. paste the objects twice ## 5. save and discard the model ## 6. open the new model in view mode ## 7. select the objects that were pasted second CC "Modeling" GET_ACT_MODEL IF (modelid = -1) { CC "AdoScript" INFOBOX ("Currently no model window exists.") EXIT } ## get all instances CC "Core" GET_ALL_OBJS modelid:(modelid) SETL a_instids:(objids) ## get all connectors CC "Core" GET_ALL_CONNECTORS modelid:(modelid) SETL a_relinstids:(objids) ## copy all objects CC "Core" CREATE_COPYBUFFER index:0 CC "Core" FILL_COPYBUFFER index:0 instids:(a_instids) relinstids:(a_relinstids) ## select a target model group CC "AdoUI" MODEL_SELECT_BOX without-models mgroup-sel title:"Select at least one target modelgroup" SETL a_mgroupids:(mgroupids) ## build a list with all modeltypes CC "Core" GET_ALL_MODELTYPES sep:"@" SET a_modeltypes:(modeltypes) CC "AdoScript" TLB_CREATE title:"Select a modeltype" flat:1 sorted:1 searchable:1 no-cancel:1 no-help:1 multi-sel:0 SETL a_id:0 FOR a_mt in:(a_modeltypes) sep:"@" { CC "AdoScript" TLB_INSERT id:(a_id) text:(a_mt) SETL a_id:(a_id + 1) } CC "AdoScript" TLB_SHOW SETL a_mt:(token (a_modeltypes, VAL selectedids, "@")) SET a_dstmodelid:0 SET ecode:1 WHILE (ecode != 0) { ## let the user enter a new modelname CC "AdoScript" EDITFIELD title:("New model of modeltype " + a_mt) caption:"~Modelname:" IF (ecode = 0) { SETL a_name:(text) CC "Core" CREATE_MODEL modeltype:(a_mt) modelname:(a_name) version:"" mgroups:(a_mgroupids) IF (ecode = 0) { SET a_dstmodelid:(modelid) } ELSE { CC "AdoScript" ERRORBOX ("An error occured creating the new model: " + errtext) ok } } ELSE { CC "AdoScript" INFOBOX ("Aborted by user!") EXIT } } ## paste twice in new model and that's it CC "Core" PASTE_COPYBUFFER index:0 modelid:(a_dstmodelid) CC "Core" PASTE_COPYBUFFER index:0 modelid:(a_dstmodelid) SETL g_acreatedinstids:(instids) SETL g_acreatedrelinstids:(relinstids) CC "Core" DELETE_COPYBUFFER index:0 ## save and discard model CC "Core" SAVE_MODEL modelid:(a_dstmodelid) CC "Core" DISCARD_MODEL modelid:(a_dstmodelid) ## open new model in modeling CC "Modeling" OPEN modelids:(STR a_dstmodelid) ## dye all remembered objects FOR a_id in:(g_acreatedinstids) { CC "Modeling" SELECT objid:(VAL a_id) } FOR a_id in:(g_acreatedrelinstids) { CC "Modeling" SELECT objid:(VAL a_id) } ``` -------------------------------- ### Example: Create, Rename, and Delete Attribute Profile Directory Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/DELETE_ATTRPROF_DIRECTORY.html This example demonstrates the lifecycle of an attribute profile directory, including creation, renaming, and deletion. It includes error handling for each step. ```asc # create an attribute profile directory CC "Core" CREATE_ATTRPROF_DIRECTORY apdirname:"New AttrProfDir" IF (ecode!=0) { CC "AdoScript" INFOBOX ("Error in CREATE_ATTRPROF_DIRECTORY!") EXIT } # get directory name of directory id CC "Core" GET_ATTRPROF_DIRECTORY_NAME apdirid:(apdirid) IF (ecode!=0) { CC "AdoScript" ERRORBOX ("Error in GET_ATTRPROF_DIRECTORY_NAME!") EXIT } CC "AdoScript" INFOBOX ("Added: "+(apdirname)+" ID: "+(STR apdirid)) # rename directory CC "Core" RENAME_ATTRPROF_DIRECTORY apdirid:(apdirid) apdirname:("Renamed AttrProfDir") IF (ecode!=0) { CC "AdoScript" INFOBOX ("Error in RENAME_ATTROPROF_DIRECTORY!") EXIT } # get new directory name CC "Core" GET_ATTRPROF_DIRECTORY_NAME apdirid:(apdirid) IF (ecode!=0) { CC "AdoScript" ERRORBOX ("ERROR GET_ATTRPROF_DIRECTORY_NAME #2!") EXIT } CC "AdoScript" INFOBOX ("Renamed to "+(apdirname)+"!") # delete directory name CC "Core" DELETE_ATTRPROF_DIRECTORY apdirid:(apdirid) IF (ecode!=0) { CC "AdoScript" ERRORBOX ("Error in DELETE_ATTRPROF_DIRECTORY!") EXIT } CC "AdoScript" INFOBOX ("Deleted "+(apdirname)+" successfully!") ``` -------------------------------- ### Get Visible Area of Active Model Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/GET_VISIBLE_AREA.html This example first retrieves the ID of the currently active model and then uses it to call GET_VISIBLE_AREA to get the visible area's bounds. Ensure the 'Modeling' context is available. ```ado-grammar SEND "GET_ACTIVE_MODEL" to:"Modeling" answer:modelid CC "Modeling" debug GET_VISIBLE_AREA modelid:(VAL modelid) ``` -------------------------------- ### BROWSER Example with Formatting Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/BROWSER.html Demonstrates the usage of the BROWSER command with custom title, content, line separator, row adjustment, handle column, alignment, and header options. ```AdoScript CC "AdoScript" BROWSER title:"My browser window" content:";Column 1;Column 2\tRow 1;Value 11\nAdditional line;Value 12\tRow 2;value 21;Value 22\tRow 3;Value 31;Value 32" linesep:"\t" adjust-rows with-handlecolumn alignment:"LR" header:"Save\nthis header" print-header:"Print\nthis header" ``` -------------------------------- ### Get Last Change Dates as Map Source: https://adoxx.org/adoscript_reference/20_message_ports/DB/GET_ALL_DATES_OF_LAST_CHANGE.html Retrieves last change dates for all models and stores them in a map for efficient processing. This example shows how to get the current model's last change date from the map. ```adoScript CC "Modeling" GET_ACT_MODEL #--> modelid CC "DB" GET_ALL_DATES_OF_LAST_CHANGE as-map #--> dates SET curdate:(dates[modelid]) CC "AdoScript" INFOBOX ("Last change of current model:" + curdate) ``` -------------------------------- ### Example: Select, Load, Create, Save, and Discard Model Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/SAVE_MODEL.html This example demonstrates a workflow involving model selection, loading, creating an object, saving the model, and then discarding it. Ensure the selected model is closed and does not contain an object with the name 'A new activity' before execution. ```adoScript CC "CoreUI" MODEL_SELECT_BOX CC "Modeling" IS_OPENED modelid:(VAL modelids) IF (isopened) { CC "AdoScript" ERRORBOX "Select a model that is not opened in the model editor!" EXIT } CC "Core" LOAD_MODEL modelid:(VAL modelids) # here we can access and change model information with Core commands, # e.g. create a new instance CC "Core" GET_CLASS_ID classname:"Aktivität" IF (ecode != 0) { CC "AdoScript" ERRORBOX ("Your library does not contain a class " + "called Aktivität!\n") EXIT } CC "Core" CREATE_OBJ modelid:(VAL modelids) classid:(classid) objname:"A new activity" IF (ecode != 0) { CC "AdoScript" ERRORBOX ("The object could not be created. \n" + "Maybe one with the same name already exists?") } CC "Core" SAVE_MODEL modelid:(VAL modelids) CC "Core" DISCARD_MODEL modelid:(VAL modelids) ``` -------------------------------- ### Example: Get User Profile Path Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_ENV_STRING.html Demonstrates how to use GET_ENV_STRING to retrieve the value of the 'userprofile' environment variable. ```asc CC "Core" debug GET_ENV_STRING envvar:("userprofile") ``` -------------------------------- ### Get Notebook Position and Size Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/GET_NOTEBOOK_POS_SIZE.html This example demonstrates how to get the position and size of a notebook using GET_NOTEBOOK_POS_SIZE. It first retrieves the active model, then all objects within that model, and finally executes and retrieves the details of a specific notebook. ```AdoScript # get the current model SEND "GET_ACTIVE_MODEL" to:"Modeling" answer:modelid IF (modelid = "") { CC "AdoScript" ERRORBOX "Open a model first!" EXIT } # get all objects CC "Core" GET_ALL_OBJS modelid:(VAL modelid) IF (ecode != 0) { CC "AdoScript" ERRORBOX "Something went very wrong here (e.g. we passed the wrong model id)!\n" EXIT } SET myObjId:(VAL token(objids,1," ")) CC "Modeling" EXEC_NOTEBOOK objid:(myObjId) CC "Modeling" debug GET_NOTEBOOK_POS_SIZE objid:(myObjId) CC "Modeling" CLOSE_ALL_NOTEBOOKS modelid:(VAL modelid) ``` -------------------------------- ### Setting up XML Script and Callbacks Source: https://adoxx.org/adoscript_reference/20_message_ports/Documentation/XML_ADD_CALLBACK.html This example demonstrates how to define a script using XML_SET_SCRIPT and then register callback procedures for specific XML elements using XML_ADD_CALLBACK. It includes a custom procedure 'CREATEMODEL' for 'MODEL' elements and a default procedure for all other elements. ```adoScript CC "Documentation" XML_SET_SCRIPT raw { PROCEDURE CREATEMODEL name:string id:int { CC "AdoScript" INFOBOX ("Invoked the procedure on node " + name + " with id " + id) } PROCEDURE DEFAULT { # invoked on all nodes but the "MODEL" nodes } } CC "Documentation" XML_ADD_CALLBACK "CREATEMODEL" name:"MODEL" type:"elementstart" CC "Documentation" XML_ADD_CALLBACK "DEFAULT" name:"**" type:"elementstart" ``` -------------------------------- ### Get Selected Model Names and Types Source: https://adoxx.org/adoscript_reference/20_message_ports/Explorer/GET_SELECTED_MODELS.html This example demonstrates how to retrieve the IDs of selected models, then fetch their names and types, and display them in an info box. It iterates through the returned model IDs and uses GET_MODEL_INFO to get details for each. ```asc CC "Explorer" GET_SELECTED_MODELS SET s:"" FOR i from:0 to:(selmodels.length - 1) { CC "Core" GET_MODEL_INFO modelid:(selmodels[i]) SET s:(s + cond(i, "\n", "") + modelname + " (" + modeltype + ")") } CC "AdoScript" INFOBOX (s) ``` -------------------------------- ### Load and use instance attributes for pen and fill colors Source: https://adoxx.org/adoscript_reference/31_graphrep/FILL.html Demonstrates how to load color values from instance attributes (e.g., 'Pen color', 'Fill color') and apply them to the PEN and FILL commands. Assumes these attributes are configured as short strings and displayed via Notebook dialogs. ```adoxx GRAPHREP SHADOW off AVAL sPenColor:"Pen color" AVAL sFillColor:"Fill color" PEN w:2pt color:(sPenColor) FILL color:(sFillColor) RECTANGLE w:2cm h:1cm ``` -------------------------------- ### Example: Numbering Objects in the Active Model Source: https://adoxx.org/adoscript_reference/20_message_ports/Modeling/RUN_MODEL_NUMBERING.html This AdoScript example demonstrates how to get the ID of the active model and then use RUN_MODEL_NUMBERING to enumerate its objects without displaying a result window. It includes error handling for enumeration failures. ```asc # Get the model id of the currently active model: SEND "GET_ACTIVE_MODEL" to:"Modeling" answer:modelid SET n_mid:(VAL modelid) # Number the objects in the model: CC "Modeling" RUN_MODEL_NUMBERING modelid:(n_mid) no-result-window:1 IF (ecode != 0) { CC "AdoScript" ERRORBOX "[enumeration-01]\nBeim Nummerieren der Objekte ist ein unerwarteter Fehler aufgetreten." title:"Error" } ``` -------------------------------- ### Create, Update, and Destroy Percentage Window Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/PERCWIN_DESTROY.html This example demonstrates creating a percentage window using PERCWIN_CREATE, updating its progress with PERCWIN_SET in a loop, and finally destroying it with PERCWIN_DESTROY after completion. ```AdoScript CC "AdoScript" PERCWIN_CREATE title:"Fortschritt:" SET step:0 FOR i from:0 to:100 by:2 { SET step:(step + 1) CC "AdoScript" PERCWIN_SET percentage:(i) text:("Step " + STR step) CC "AdoScript" SLEEP ms:200 } CC "AdoScript" INFOBOX "Finished!" CC "AdoScript" PERCWIN_DESTROY ``` -------------------------------- ### Example: Get and Set Attribute Value Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/GET_ATTR_ID.html This example demonstrates how to retrieve the ID of the 'Name' attribute for a selected object and then set its value to 'Seppl'. It includes error handling for cases where the attribute does not exist or the value cannot be set. ```Adoxx Script # get all selected objects CC "Modeling" GET_SELECTED IF (objids = "") { CC "AdoScript" ERRORBOX "No object has been selected!" EXIT } # from the list of selected objects, extract the first objectid SET selected:(VAL token(objids,0," ")) # get the class of the selected object CC "Core" GET_CLASS_ID objid:(selected) # get the attribute "Name" of the class CC "Core" GET_ATTR_ID classid:(classid) attrname:"Name" IF (ecode != 0) { CC "AdoScript" ERRORBOX "The selected object does not contain an attribute called \"Name\"!" EXIT } # set the name of the selected object CC "Core" SET_ATTR_VAL objid:(selected) attrid:(attrid) val:"Seppl" IF (ecode != 0) { CC "AdoScript" ERRORBOX "Could not set the attribute value!" EXIT } ``` -------------------------------- ### Draw a complex connector with wavy start and arrow end Source: https://adoxx.org/adoscript_reference/31_graphrep/EDGE.html Draws a connector with a thicker lightblue line, starting with a wavy line, ending with an arrow-head after a gap, and featuring a movable rectangle at the middle point. This example demonstrates combining EDGE with START, END, and MIDDLE commands for intricate graphical elements. ```leo GRAPHREP start-trans:-0.3cm end-trans:-0.5cm # Note: SHADOW is on by default. # Draw the basic edge line. PEN color:"lightblue" w:0.08cm EDGE # Draw the wavy line at the start. START POLYLINE 4 x1:0cm y1:0cm x2:-0.1cm y2:0.18cm x3:-0.2cm y3:-0.18cm x4:-0.3cm y4:0cm # Draw the arrow-head at the end. END POLYLINE 3 x1:-0.4cm y1:0.15cm x2:0cm y2:0cm x3:-0.4cm y3:-0.15cm # Draw the rectangle at the middle. MIDDLE FILL color:"lightblue" RECTANGLE y:-0.3cm w:0.3cm h:0.6cm ``` -------------------------------- ### Creating a Dialog and Adding Custom Buttons Source: https://adoxx.org/adoscript_reference/20_message_ports/AdoScript/TLB_ADD_BUTTON.html This example demonstrates the full workflow: creating a dialog, inserting entries, selecting an entry, adding custom buttons at specific positions or with conditional disabling, and finally showing the dialog. It also shows how to handle user interaction based on the dialog's result and which button was pressed. ```AdoScript # create the main TreeListBox with all it's parameters CC "AdoScript" TLB_CREATE title:"My title" oktext:"Close" canceltext:"No way!" boxtext:"These are my entries" no-help:1 button-w:60 max-w:500 max-h:367 min-w:200 min-h:150 checklistbox:1 # insert some entries (as you like - ID should be unique!) CC "AdoScript" TLB_INSERT id:1 text:"Do this" CC "AdoScript" TLB_INSERT id:2 text:"Do that" # select the first entry (here: check it) CC "AdoScript" TLB_SELECT id:1 select:1 # add a new button between OK and cancel CC "AdoScript" TLB_ADD_BUTTON name:"bt1" text:"Click me" index:1 # add a new button at the end and disable it if nothing is selected CC "AdoScript" TLB_ADD_BUTTON name:"bt2" text:"Click me2" disable_if_no_selection:1 # and finally show it! CC "AdoScript" TLB_SHOW IF (ecode = 0) { CC "AdoScript" INFOBOX ("Selected ids: " + selectedids + "\nYou pressed the following button: " + endbutton) } ELSE { CC "AdoScript" INFOBOX ("You cancelled the dialog!") } ``` -------------------------------- ### Start Attribute Class Filter Dialog Source: https://adoxx.org/adoscript_reference/20_message_ports/Documentation/EXEC_ACFILTER.html Starts the attribute and class filter dialog, preselecting 'Target Sample Model' and storing user settings in the 'Attribute and Class Filter' attribute. This example demonstrates how to use both the 'attribute' and 'modeltype' parameters. ```leo-grammar CC "Documentation" EXEC_ACFILTER attribute:"Attribute and Class Filter" modeltype:"Target Sample Model" ``` -------------------------------- ### Comprehensive Record Operations Example Source: https://adoxx.org/adoscript_reference/20_message_ports/Core/REMOVE_REC_ROW.html This example showcases a sequence of record operations, including adding, counting, getting row IDs, and removing rows from a RECORD attribute. It's useful for understanding the lifecycle of record manipulation within an attribute. ```AdoScript # get all selected objects CC "Modeling" GET_SELECTED IF (objids = "") { CC "AdoScript" ERRORBOX "Select an instance first!" EXIT } # from the list of selected objects, extract the first objectid SET firstselected:(token(objids,0," ")) # now get the classes of the connected instances CC "Core" GET_CLASS_ID objid:(VAL firstselected) # get all attributes of the selected class CC "Core" GET_ALL_ATTRS classid:(classid) # get types of attributes FOR id in:(attrids) { CC "Core" GET_ATTR_TYPE attrid:(VAL id) # check for type "RECORD" IF ((attrtype) = "RECORD") { # get attribute name CC "Core" GET_ATTR_NAME attrid:(VAL id) # here we get the row count CC "Core" GET_REC_ATTR_ROW_COUNT objid:(VAL firstselected) attrid:(VAL id) # show actual row count CC "AdoScript" INFOBOX ("Initial row count: "+(STR count)+". Now adding one...") # no add one row CC "Core" ADD_REC_ROW objid:(VAL firstselected) attrid:(VAL id) # again get row count CC "Core" GET_REC_ATTR_ROW_COUNT objid:(VAL firstselected) attrid:(VAL id) # again show actual row count CC "AdoScript" INFOBOX ("New actual row count: "+(STR count)) # now we get the row id of added row CC "Core" GET_REC_ATTR_ROW_ID objid:(VAL firstselected) attrid:(VAL id) index:(count) CC "AdoScript" INFOBOX ("Position "+(STR count)+": RowID: "+(STR rowid)) # get record class id CC "Core" GET_REC_CLASS_ID attrid:(VAL id) CC "AdoScript" INFOBOX ("ClassID: "+(STR classid)) # delete row CC "AdoScript" INFOBOX ("Now removing added row...") CC "Core" REMOVE_REC_ROW objid:(VAL firstselected) attrid:(VAL id) rowid:(rowid) ``` -------------------------------- ### XML_CLOSE Example Source: https://adoxx.org/adoscript_reference/20_message_ports/Documentation/XML_CLOSE.html Demonstrates opening a file for writing, opening another for reading, and then closing the output file. ```ado-script CC "Documentation" XML_OPEN "outputfile.xml" write CC "Documentation" XML_OPEN "inputfile.xml" CC "Documentation" XML_CLOSE write # now the file "inputfile.xml" is opened, the file "outputfile.xml" closed. ``` -------------------------------- ### Get Active Variant and Display Source: https://adoxx.org/adoscript_reference/20_message_ports/Drawing/GET_ACTIVE_VARIANT.html This example first gets the ID of the currently active model, then retrieves its active variant using GET_ACTIVE_VARIANT, and finally displays the variant name in an information box. Ensure the Modeling and Drawing message ports are available. ```AdoScript CC "Modeling" GET_ACT_MODEL CC "Drawing" GET_ACTIVE_VARIANT modelid:(modelid) CC "AdoScript" INFOBOX ("Active variant: " + variant) ```