Scripting

Topic Contents: Hide

 

Internal Scripting allows you to write scripts using the Visual Basic or C# programming languages to create functions and procedures to automate things such as creating DataSets, modifying templates, and loading data. In addition to general program functionality, access to the CM4D API is available.

Scripting Security

To use scripting, you must have:

·        Site Database

·        Script User Privileges

Scripts are controlled by assigning user Privileges in SiteManager. What users can do with scripts, and at what level, is all managed by the Site Database Admin.

Scripting Restrictions

Internal scripting can use many of the API methods, with a few restrictions:

·        a new document cannot be created;

·        a document cannot be opened (scripts must act on the active document provided);

·        a document cannot be closed (documents must be closed through the user interface, by the user).

Script Execution

Scripts can be executed in three ways:

·        on document open (Document Defaults);

·        on ‘Execute’ of an Annotation (Annot Properties);

·        on demand (Execute buttons in Script dialogs).

Migrating External Scripts to Internal

Existing external scripts may be migrated into CM4D, but it must be put inside a very specific shell of start/end code and formatted to use internal references (cm4dDoc), rather than external (QaDoc).

Only VB.net or C# are supported, so if you have code in any other language it will need to be migrated accordingly.

Script Configuration

External .NET Assemblies, either global or private, can be called by internal scripts. See the topic, Script Assemblies.

Debugging Scripts

CM4D does not provide a debug environment for scripts. If you are concerned about being able to debug a script before using it in CM4D, you could develop your scripts in Excel or Visual Studio as an external script, and do any debugging in one of those applications. When you are done, migrate the code into CM4D.

See the topic, Create Internal Scripts in Visual Studio.