我无法在Maya MEL的脚本编辑器输出中看到结果评论。

huangapple go评论68阅读模式
英文:

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

全局程序打印模式(string $模式类型, int $行数, int $列数)
{
    if ($模式类型 == "三角形")
    {
        int $i = 0;
        while ($i < $行数)
        {
            int $j = 0;
            while ($j <= $i)
            {
                if ($i == 0 || $i == $行数 - 1 || $j == 0 || $j == $i)
                    print("* ");
                else
                    print("  ");
                $j++;
            }
            print("\n");
            $i++;
        }
    }
    else if ($模式类型 == "矩形")
    {
        int $i = 0;
        while ($i < $行数)
        {
            int $j = 0;
            while ($j < $列数)
            {
                if ($i == 0 || $i == $行数 - 1 || $j == 0 || $j == $列数 - 1)
                    print("* ");
                else
                    print("  ");
                $j++;
            }
            print("\n");
            $i++;
        }
    }
    else
    {
        print("无效的模式类型。请选择 '三角形' 或 '矩形'。\n");
    }
}

// 获取模式选择
string $模式选择 = `promptDialog -title "模式类型" -message "输入 '三角形' 或 '矩形' 以选择模式类型:" -button "确定" -defaultButton "确定" -cancelButton "取消" -dismissString "取消"`;
if ($模式选择 == "确定")
{
    $模式选择 = `promptDialog -query -text`;
    
    // 打印所选的模式
    if ($模式选择 == "三角形" || $模式选择 == "矩形")
    {
        int $模式行数 = `promptDialog -title "模式行数" -message "输入模式的行数:" -button "确定" -defaultButton "确定" -cancelButton "取消" -dismissString "取消"`;
        int $模式列数 = 0;
        if ($模式行数 == "确定")
        {
            $模式行数 = `promptDialog -query -text`;
            if ($模式选择 == "矩形")
            {
                $模式列数 = `promptDialog -title "模式列数" -message "输入模式的列数:" -button "确定" -defaultButton "确定" -cancelButton "取消" -dismissString "取消"`;
                if ($模式列数 == "确定")
                {
                    $模式列数 = `promptDialog -query -text`;
                }
            }
            print("星星模式(", $模式选择, "):\n");
            print_pattern($模式选择, $模式行数, $模式列数);
        }
    }
    else
    {
        print("无效的模式类型。请选择 '三角形' 或 '矩形'。\n");
    }
}

我想知道为什么会发生这种情况!或者这是一个错误。

英文:

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 == &quot;triangle&quot;)
    {
        int $i = 0;
        while ($i &lt; $rows)
        {
            int $j = 0;
            while ($j &lt;= $i)
            {
                if ($i == 0 || $i == $rows - 1 || $j == 0 || $j == $i)
                    print(&quot;* &quot;);
                else
                    print(&quot;  &quot;);
                $j++;
            }
            print(&quot;\n&quot;);
            $i++;
        }
    }
    else if ($patternType == &quot;rectangle&quot;)
    {
        int $i = 0;
        while ($i &lt; $rows)
        {
            int $j = 0;
            while ($j &lt; $cols)
            {
                if ($i == 0 || $i == $rows - 1 || $j == 0 || $j == $cols - 1)
                    print(&quot;* &quot;);
                else
                    print(&quot;  &quot;);
                $j++;
            }
            print(&quot;\n&quot;);
            $i++;
        }
    }
    else
    {
        print(&quot;Invalid pattern type. Please choose &#39;triangle&#39; or &#39;rectangle&#39;.\n&quot;);
    }
}

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

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

答案1

得分: 0

你将模式选择的结果定义为:int $patternRows...,然后将其与字符串进行比较:if ($patternRows == &quot;OK&quot;),这是不起作用的。同样的情况也发生在$patternCols上。在下面,您以错误的方式使用了print()语句。

英文:

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

huangapple
  • 本文由 发表于 2023年7月17日 17:06:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76702943.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定