Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4332198
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:13:20+00:00 2026-05-21T10:13:20+00:00

Coming from a Java/C# background, the MEL site came as a bit of a

  • 0

Coming from a Java/C# background, the MEL site came as a bit of a letdown to me, maybe because I wasn’t used to it, but didn’t think it was as clear as some API sites.

I’m trying to write a MEL command to automate my save-as, rename file, save cycle. I know there must be some script out there already that does this, but I wanted to learn myself too

Initially, I want the user to click user-defined button from the shelf, and have a prompt-dialog, preloaded with the current scene name, with save-as and cancel button. Renaming and saving is fine, it’s the separating out into functions (is there a difference between functions and procedures?) that started to spawn errors.

string $sceneName_new;


// Initiates the scene saving, checking filename meets standards
proc saveSceneAs() {

    string $sceneName_old = `file -q -sceneName`;
    string $result = `promptDialog 
        -title "Save scene as"
        -message "Scene name:"
        -button "Save" -button "Cancel"
        -text $sceneName_old
        -defaultButton "Save" -cancelButton "Cancel"
        -dismissString "Cancel"`;

    if ($result == "Save") {
        $sceneName_new = `promptDialog -query -text`; // get result
        $sceneName_new = strip($sceneName_new); // clean whitespace (start/end)

        // check length of new name has at least one character
        if (size($sceneName_new) < 1) {
            print("Error: file name must contain at least one character. File not saved.\n");
        } else if ($sceneName_old == $sceneName_new) {
            confirmOverwriteOkay();
        } else {
            // good to save :D
            saveScene($sceneName_new);
        }
    } else {
        print("Cancelled. File not saved.\n");
    }   
}

// Asks user in case of unchanged filename, if okay to overwrite
proc confirmOverwriteOkay() {
    string $overwriteConfirm = `promptDialog 
                -title "Warning"
                -message "Are you sure you want to overwrite the current file?"
                -text $sceneName_new;
                -button "Yes, overwrite" -button "No, rename" -button "No, cancel"
                -defaultButton "No, rename" -cancelButton "No, cancel"
                -dismissString "No, cancel"`;

    if ($overwriteConfirm == "Yes, overwrite") {
        saveScene($sceneName_new);
    } else if ($overwriteConfirm == "No, rename") {
        // go back and try again
        saveSceneAs();
    } else {
        print("Cancelled. File not saved.\n");
    }
}


// Saves the scene with the given file name
proc saveScene(string $nameToSave) {
    // TODO: rename, save file
    print("File saved: " + $nameToSave);
}


saveSceneAs();    

And the errors:

// Error: -text $sceneName_new; // 
// Error: "$sceneName_new" is an undeclared variable. // 
// Error: -button "Yes, overwrite" -button "No, rename" -button "No, cancel" // 
// Error: Syntax error // 
// Error: saveScene($sceneName_new); // 
// Error: "$sceneName_new" is an undeclared variable. // 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:13:21+00:00Added an answer on May 21, 2026 at 10:13 am

    I solved this by adding the global keyword to the sceneName_new variable, and also declaring my use of it in the function it was called in – this will make the procedure use that global variable rather than create a new local one.

    global string $sceneName_new;
    
    // Asks user in case of unchanged filename, if okay to overwrite
    proc confirmOverwriteOkay() {
    
    global string $sceneName_new;       
    string $overwriteConfirm = `promptDialog 
                    -title "Warning"
                    -message "Are you sure you want to overwrite the current file?"
                    -text $sceneName_new;
                    -button "Yes, overwrite" -button "No, rename" -button "No, cancel"
                    -defaultButton "No, rename" -cancelButton "No, cancel"
                    -dismissString "No, cancel"`;
    
        if ($overwriteConfirm == "Yes, overwrite") {
            saveScene($sceneName_new);
        } else if ($overwriteConfirm == "No, rename") {
            // go back and try again
            saveSceneAs();
        } else {
            print("Cancelled. File not saved.\n");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coming from a java background, one of the things I am used to is
When I was learning Java coming from a background of some 20 years of
Coming from C++ to Java, the obvious unanswered question is why didn't Java include
Coming from a Classic ASP background, I'm used to multiple forms on a page,
Coming from a Java background it is new for me to deal with the
I just started to look at C, coming from a java background. I'm having
I am coming from an Enterprise Java background which involves a fairly heavyweight software
I am coming from Java and am currently working on a C# project. What
I'm starting with Python coming from java. I was wondering if there exists something
I'm a relatively new Java programmer coming from C++/STL, and am looking for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.