或声明无效
我制作了这个脚本来调整矩形过渡管道上的扩展,但它不想对我起作用。如果我保持简单,去掉“或”Ductmate 35“部分,一切都很好,但为了使其工作,我需要Or语句。无论如何,这是剧本。。。
select item.cid
case 2
dim extin = item.dim.numvalue
dim extout = item.dim.numvalue
dim con1 = item.connector.value
dim con2 = item.connector.value
if ( con1 = ("TDC" or "Ductmate 35") ) and
(extin < 2 ) then
item.dim.value = 2
end if
if ( con2 = ("TDC" or "Ductmate 35") ) and
(extout < 2 ) then
item.dim.value = 2
end if
if ( con1 <> ("TDC" or "Ductmate 35") ) and
(extin < 0.5 ) then
item.dim.value = 0.5
end if
if ( con2 <> ("TDC" or "Ductmate 35") ) and
(extout < 0.5 ) then
item.dim.value = 0.5
end if
item.update()
end select
有人能发现这个问题吗?我希望这是一个令人尴尬的简单。 在lisp中,你需要另一对刹车,我认为在这里也是一样的,如果(。。。。。。。。。 你的意思是它应该看起来像这样吗?
if ( con1 = ("TDC" or "Ductmate 35") ) and
((extin < 2 )) then
item.dim.value = 2
end if
我不认为把一些东西放在两组括号((X))中会改变语句的逻辑。我试着这么做只是为了安全,没有任何变化。
谢谢你的努力 不要用这种类型的代码方法编程。试试这个
if (( con1 = ("TDC" or "Ductmate 35") ) and (extin < 2 )) then
谢谢你的提示。这实际上看起来好多了,我把脚本改成了同样的格式。不幸的是,它没有解决这个问题,但我想我知道发生了什么。
看看这两段代码。。。
if ( con2 = ("TDC" or "Ductmate 35") ) and
(extout < 2 ) then
item.dim.value = 2
end if
;;;which is followed by...
if ( con2 <> ("TDC" or "Ductmate 35") ) and
(extout < 0.5 ) then
item.dim.value = 0.5
end if
我认为or语句可能有效,但我还有第二行代码,它应该处理如果con2不等于TDC或Ductmate 35会发生什么。我没有考虑到无论连接器是TDC还是Ductmate 35,这一说法都是正确的,因为它不能同时是TDC和Ductmate 35。我可能应该把它写成一个“和”的陈述。
不过,这需要一段稍微粗一点的代码。你知道我怎么用else语句来表达这个吗?我尝试了一些变体,但不断出现无法理解/修复的错误。
这就是我的脚本现在的样子。。。
select item.cid
case 2
dim extin = item.dim.numvalue
dim extout = item.dim.numvalue
dim con1 = item.connector.value
dim con2 = item.connector.value
if (( con1 = ("TDC" or "Ductmate 35")) and (extin < 2 )) then
item.dim.numvalue = 2 elseif
extin < 0.5 then
item.dim.numvalue = 0.5
end if
if (( con2 = ("TDC" or "Ductmate 35")) and (extout < 2 )) then
item.dim.numvalue = 2 elseif
extout < 0.5 then
item.dim.numvalue = 0.5
end if
item.update()
end select
你能在最后一个脚本中发现语法错误吗?
顺便说一句,谢谢你迄今为止的帮助。
页:
[1]