Programming Points Print this Topic Previous Page Up One Level Next page

Home >  UModel Programmer's Reference > Scripting Editor >

Programming Points

The following programming points should be noted:


All namespaces and types of the following .NET assemblies can be accessed in the Microsoft .NET Framework per default:









Additional assemblies can be added to the scripting project via the project's context menu, or dynamically (at runtime) in the source code by using CLR.LoadAssembly.


Out-parameters from methods of the.NET Framework require special variables in JScript.

For example:


 var dictionary = CLR.Create( "System.Collections.Generic.Dictionary< System.String,
 System.String >" );

 dictionary.Add("1", "A");

 dictionary.Add("2", "B");


 // use JScript method to access out-parameters

 var strOut = new Array(1);

 if ( dictionary.TryGetValue("1", strOut) // TryGetValue will set the out parameter

         alert( strOut[0] ); // use out parameter



.NET Methods that require integer arguments should not be called directly with JScript Number Objects which are Floating Point Values.


For example, instead of:


var objCustomColor = CLR.Static( "System.Drawing.Color" ). FromArgb( 128, 128, 128 );




var objCustomColor = CLR.Static( "System.Drawing.Color" ). FromArgb( Math.floor( 128 ), Math.floor( 128 ), Math.floor( 128 ) );



To iterate .NET collections the JScript Enumerator as well as the .NET iterator technologies can be used:


For example:

 // iterate using the JScript iterator

 var itr = new Enumerator( coll );

 for ( ; !itr.atEnd(); itr.moveNext() )

         alert( itr.item() );


 // iterate using the .NET iterator

 var itrNET = coll.GetEnumerator();

 while( itrNET.MoveNext() )

         alert( itrNET.Current );


.NET templates can be instantiated as shown below:


var coll = CLR.Create( "System.Collections.Generic.List<System.String>" );




 CLR.Import( "System" );

 CLR.Import( "System.Collections.Generic" );

 var dictionary = CLR.Create( "Dictionary< String, Dictionary< String, String > >" );


.NET Enum values are accessed as shown below:

 var enumValStretch = CLR.Static( "System.Windows.Forms.ImageLayout" ).Stretch;


Enumeration literals, as defined in the Altova type libraries, can now be used instead of numerical values.


 objExportXMIFileDlg.XMIType = eXMI21ForUML23;


© 2019 Altova GmbH