英文:
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 == "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
答案1
得分: 0
你将模式选择的结果定义为:int $patternRows...
,然后将其与字符串进行比较:if ($patternRows == "OK")
,这是不起作用的。同样的情况也发生在$patternCols
上。在下面,您以错误的方式使用了print()
语句。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论