User Tools

Site Tools


Remove Store Id

Summary

Below is an example demonstrating how you can remove a StoreId from the database, via script.

API Areas of Interest

Example

DB_Remove_Store_Id.dsa
// DAZ Studio version 4.9.1.24
 
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function( sStoreID, bVerbose ){
 
	/*********************************************************************/
	// String : A function for retrieving a translation if one exists
	function text( sText )
	{
		// If the version of the application supports qsTr()
		if( typeof( qsTr ) != "undefined" ){
			// Return the translated (if any) text
			return qsTr( sText );
		}
 
		// Return the original text
		return sText;
	};
 
	/*********************************************************************/
	// Get the asset manager
	var oAssetMgr = App.getAssetMgr();
	// If the asset manager is not found
	if( !oAssetMgr ){
		// We are done...
		return;
	}
 
	// Define common strings
	var sTitle = text( "Information" );
	var sButton = text( "&OK" );
 
	// If the version of the application doesn't provide the function needed
	if( typeof oAssetMgr.removeStore == "undefined" ){
		// If being verbose
		if( bVerbose ){
			// Inform the user
			MessageBox.information(
				text( "The \"%1\" store could not be removed. " +
					"A newer version of %2 is required.")
					.arg( sStoreID ).arg( App.appName ),
				sTitle, sButton );
		}
	// If the store is successfully added to the database
	} else if( oAssetMgr.removeStore( sStoreID ) ){
		// If being verbose
		if( bVerbose ){
			// Inform the user
			MessageBox.information(
				text( "The \"%1\" store has been removed." ).arg( sStoreID ),
				sTitle, sButton );
		}
	} else {
		// If being verbose
		if( bVerbose ){
			// Inform the user
			MessageBox.information(
				text( "The \"%1\" store was not removed." ).arg( sStoreID ),
				sTitle, sButton );
		}
	}
 
// Finalize the function and invoke
} )( "My Store", true );