Jump to content

Recommended Posts

Posted

I've made this script to adjust the extensions on our rectangular transition ducts but it doesn't want to work for me. Everything is fine if I keep it simple and leave out the " Or "Ductmate 35" " part but for this to work, I will need the or statement.

 

Anyways, here's the script...

 

select item.cid
case 2

	dim extin = item.dim[6].numvalue
	dim extout = item.dim[7].numvalue
	dim con1 = item.connector[1].value
	dim con2 = item.connector[2].value
	
	if ( con1 = ("TDC" or "Ductmate 35") ) and
	(extin < 2 ) then
	item.dim[6].value = 2
	end if

	if ( con2 = ("TDC" or "Ductmate 35") ) and
	(extout < 2 ) then
	item.dim[7].value = 2
	end if

	if ( con1 <> ("TDC" or "Ductmate 35") ) and
	(extin < 0.5 ) then
	item.dim[6].value = 0.5
	end if

	if ( con2 <> ("TDC" or "Ductmate 35") ) and
	(extout < 0.5 ) then
	item.dim[7].value = 0.5
	end if

	item.update()

end select

 

Can anyone spot the problem? I'm hoping its an embarrassingly simple one.

Posted

In lisp you would need another pair of brakets I think its the same here if ((.........

Posted

Do you mean it should look something like this?

 

if ( con1 = ("TDC" or "Ductmate 35") ) and
[color="red"]((extin < 2 ))[/color] then
item.dim[6].value = 2
end if

 

I don't think putting something into two sets of brackets ((X)) would change the logic of the statement. I tried it just to be safe and there was no change.

 

Thanks for trying though :)

Posted

Dont program with this type of code method try this

 

if (( con1 = ("TDC" or "Ductmate 35") ) and [color=red](extin < 2 ))[/color] then

Posted

Thanks for the tip. That actually looks a lot better and I changed my script to use the same format. Unfortunately it didn't fix the problem, but I think I figured out what is happening.

 

take a look at these two pieces of code...

 

if ( con2 = ("TDC" or "Ductmate 35") ) and
	(extout < 2 ) then
	item.dim[7].value = 2
	end if

;;;which is followed by...

if ( con2 <> ("TDC" or "Ductmate 35") ) and
	(extout < 0.5 ) then
	item.dim[7].value = 0.5
	end if

 

I think that the or statement may be working, but then I have a second line of code which is supposed to handle what happens if con2 does not equal TDC or Ductmate 35. I didn't take into account that this statement would be true whether the connector were TDC or Ductmate 35 because it can't be both. I probalby should of made that into an "and" statement.

 

Still, that would take a slightly chunkier piece of code. Do you know how I could use an else statement for this? I tried a few variations but kept getting errors I couldn't understand/fix.

 

This is what my script now looks like...

 

select item.cid
case 2

	dim extin = item.dim[6].numvalue
	dim extout = item.dim[7].numvalue
	dim con1 = item.connector[1].value
	dim con2 = item.connector[2].value
	
	if (( con1 = ("TDC" or "Ductmate 35")) and (extin < 2 )) then
	item.dim[6].numvalue = 2 elseif
	extin < 0.5 then
	item.dim[6].numvalue = 0.5
	end if

	if (( con2 = ("TDC" or "Ductmate 35")) and (extout < 2 )) then
	item.dim[7].numvalue = 2 elseif
	extout < 0.5 then
	item.dim[7].numvalue = 0.5
	end if


	item.update()

end select

 

Can you spot any syntax errors in that last script?

 

By the way, thanks for all of your help so far.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...