Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I can't see the result comment on output in Script Editor in Maya MEL

I can’t see the result comment on output in Script Editor in Maya MEL and I think It’s not have a error when I ran It. I don’t know why. I write a Hollow triangle or Hollow Rectangle star " * " Pattern

This is source code

global proc print_pattern(string $patternType, int $rows, int $cols)
{
    if ($patternType == "triangle")
    {
        int $i = 0;
        while ($i < $rows)
        {
            int $j = 0;
            while ($j <= $i)
            {
                if ($i == 0 || $i == $rows - 1 || $j == 0 || $j == $i)
                    print("* ");
                else
                    print("  ");
                $j++;
            }
            print("\n");
            $i++;
        }
    }
    else if ($patternType == "rectangle")
    {
        int $i = 0;
        while ($i < $rows)
        {
            int $j = 0;
            while ($j < $cols)
            {
                if ($i == 0 || $i == $rows - 1 || $j == 0 || $j == $cols - 1)
                    print("* ");
                else
                    print("  ");
                $j++;
            }
            print("\n");
            $i++;
        }
    }
    else
    {
        print("Invalid pattern type. Please choose 'triangle' or 'rectangle'.\n");
    }
}

// Get pattern choice
string $patternChoice = `promptDialog -title "Pattern Type" -message "Enter 'triangle' or 'rectangle' for the pattern type:" -button "OK" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
if ($patternChoice == "OK")
{
    $patternChoice = `promptDialog -query -text`;
    
    // Print the selected pattern
    if ($patternChoice == "triangle" || $patternChoice == "rectangle")
    {
        int $patternRows = `promptDialog -title "Pattern Rows" -message "Enter the number of rows for the pattern:" -button "OK" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
        int $patternCols = 0;
        if ($patternRows == "OK")
        {
            $patternRows = `promptDialog -query -text`;
            if ($patternChoice == "rectangle")
            {
                $patternCols = `promptDialog -title "Pattern Columns" -message "Enter the number of columns for the pattern:" -button "OK" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
                if ($patternCols == "OK")
                {
                    $patternCols = `promptDialog -query -text`;
                }
            }
            print("Star Pattern (", $patternChoice, "):\n");
            print_pattern($patternChoice, $patternRows, $patternCols);
        }
    }
    else
    {
        print("Invalid pattern type. Please choose 'triangle' or 'rectangle'.\n");
    }
}

I want to know why this happen! Or It’s a bug.
.
sadsadasdasdsadasdasdasdasdasdsadasdasdsadasdasdsadasdasdasdasdasdasdasdasdasdsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You define the result of pattern choice as: int $patternRows... and later you compare it with a string: if ($patternRows == "OK") what does not work. The same happens with $patternCols. And below you use the print() statement in a wrong way.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading