Please enable JavaScript to view this site.

Altova Authentic 2020 Desktop

Below are a few JScript programming tips that you may find useful while developing a scripting project in Authentic Desktop Scripting Editor.

 

Out parameters

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

 

Integer arguments

.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);

 

use:

 

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

 

Iterating .NET collections

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

.NET templates can be instantiated as shown below:

 

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

 

or

 

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

 

.NET enumeration values

.NET enumeration values are accessed as shown below:

 

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

 

Enumeration literals

The enumeration literals from the Authentic Desktop API can be accessed as shown below (there is no need to know their numerical value).

 

objExportXMIFileDlg.XMIType = eXMI21ForUML23;

© 2019 Altova GmbH