/*
This example demonstrates how to ask the user for the path to a workgroup and
to connect to it. It uses the XSIApplication.Workgroups property to discover if
the workgroup already exists
*/
AddWorkgroupWithUI() ;
function AddWorkgroupWithUI()
{
var strTitle = "Connect to Workgroup" ;
var strHelpText = "Pick the root location of an existing workgroup" ;
var strDefault = "" ;
var strPath = PickFolder( strTitle, strHelpText, strDefault ) ;
if ( strPath != "" ) {
aWorkgroups = new VBArray( Application.Workgroups ) ;
cntWorkgroups = aWorkgroups.ubound( 1 ) + 1
for ( var i=0 ; i<cntWorkgroups; i++ ) {
var existingWorkgroup = aWorkgroups.getItem( i ) ;
if ( existingWorkgroup == strPath ) {
XSIUIToolkit.MsgBox( "This workgroup is already in the list" ) ;
return ;
}
}
try {
Application.AddWorkgroup( strPath ) ;
} catch( e ) {
// Maybe the path isn't valid
XSIUIToolkit.MsgBox( "Failed to addworkgroup\n" + e.description ) ;
}
}
} |