// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: Aug 21, 2003 // // Procedure Name: // melFileToOpen() // // Description: // Brings up a modal dialog for the user to input the pathname // to a MEL script to be loaded into the Script Editor. Called // from within the Script Editor code. // // Input Value: // None // // Output Value: // Pathname of a valid readable file that the user typed in. // global proc string melFileToOpen() // // Purpose: // // Called from the "File->Open Script" menu item // of the Script Editor under low memory conditions // on Windows, when a standard system dialog would // cause Maya to hang. // // Brings up a simple text box that allows the user // to type in a full path to a MEL script to load. // Loops until a valid pathname is entered, or // the user cancels the dialog. // // { string $text = ""; string $ok = (uiRes("m_melFileToOpen.kOk")); string $cancel = (uiRes("m_melFileToOpen.kCancel")); while( 1 ) { $result = `promptDialog -title (uiRes("m_melFileToOpen.kOpenScript")) -message (uiRes("m_melFileToOpen.kEnterFilename")) -button $ok -button $cancel -defaultButton $ok -cancelButton $cancel -dismissString $cancel -tx $text`; if ($result == $ok) { $text = `promptDialog -query -text`; if( !`filetest -r $text` ) { confirmDialog -title (uiRes("m_melFileToOpen.kError")) -message (uiRes("m_melFileToOpen.kOpenMessage")) -button (uiRes("m_melFileToOpen.kTryAgain")); continue; } else { break; } } else { // user cancelled dialog // $text = ""; break; } } return $text; }