This page exists within the Old ArtZone Wiki section of this site. Read the information presented on the linked page to better understand the significance of this fact.
Author: Rob Whisenant, © 2008
In build 2.2.2.17, DAZ Studio was given the ability to pass an array of arguments into a DzScript object. The type of arguments that can be passed in via the array are limited to basic types; String, Number, Boolean, Array, etc. Below you will find sample code for two scripts… One for a script that does the calling and one for the script being called.
// The path to the script being called; ./scripts/support/MyName/MyScript.ds var sSUPPORT_PATH = String( "%1/support/MyName/MyScript.ds" ).arg( App.getScriptsPath() ); // Create a file object var oFile = new DzFileInfo( sSUPPORT_PATH ); // Get whether the file exists var bFound = oFile.exists(); // If the file doesn't exist if( !bFound ) { // Try iteratively finding *.dsa, *.dsb or *.dse var aExtensions = new Array( "a", "b", "e" ); for( var i = 0; i < aExtensions.length; i += 1 ) { oFile = new DzFileInfo( String( "%1%2" ).arg( sSUPPORT_PATH ).arg( aExtensions[ i ] ); bFound = oFile.exists(); if( bFound ) { break; } } } // If a file is found and the version number is 2.2.2.17 or newer if( bFound && App.version >= 33686033 ) { // Create a script object var oSCRIPT = new DzScript(); // If the script loads if( oSCRIPT.loadFromFile( oFile.absFileName() ) ) { // Execute the script; pass in an array of arguments oSCRIPT.execute( new Array( App.version, sSUPPORT_PATH, bFound ) ); } }
// Get the arguments passed in to the script var aARGS = getArguments(); // Display a message box with the arguments MessageBox.information( String( "%1" ).arg( aARGS.join( "\n" ) ), "Arguments", "&OK" );