cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Can If statement use more than 1 value?

TimSharp
12-Amethyst

Can If statement use more than 1 value?

Can we do if statements like below that check for 2 things instead of just one?

example:

If ((E2.Ellipse.Segments[1].Pen = RemovePen) or (E2.Ellipse.Segments[1].Pen = RemovePen2))

Create Object_Info E2
Create Object_Attribute "Delete" "String" E2
E2.Info.Attributes["Delete"].Value = "Yes"
End If

I've tried it in a macro and it doesn'[t seem to work. I'm so used to doing this in other macro languages that it didn't occur to me that it might not be possible in Isodraw macros. Can someone confirm this or tell me where my syntax is wrong?

If I separate the if statements they work, but then I have to copy the code between the if and end if for each one which makes the macro much longer.

Thanks to Trevor Hendricks for the orginal macro that I'm altering for this.

10 REPLIES 10

First, thanks for the credit.

Second, not that I'm aware of. My suggestion would be to move the following lines to a submacro.

Create Object_Info E2
Create Object_Attribute "Delete" "String" E2
E2.Info.Attributes["Delete"].Value = "Yes"

You could then call this from within each If statement. It's not the cleanest, but would reduce repeated code. Note that you'd like need to change the E2 variable to a global if it isn't already.

Thanks Trevor

I guess I shouldn't moan about missing things, but I just assumed that if statements in any language would work with multiple values.

Yes your solution will cut down code so I'll do that.

I havn't checked it with your example, but IML should understand these logical operators:

|| (meaning "or")

&& (meaning "and")


I've been experimenting this morning using the ampersands and pipes, but no luck. Could you provide a simple example of the sytax to use?

This might not make much sense, but show the syntax:

Macro UseBooleanOperators
Define e as Element

e = activeDoc.firstSelectedElement

if ( (e.type="Outer_thread") || (e.type="Inner_thread") ) then
Message "Element is a thread."
End If

if ( (e.type="Group") && (exists(e.info)=true) ) then
Message "Group is an object."
End If

End Macro

That worked. I didn't have the parantheses set up properly. Missing the set that included the two checks. Thank you for the sample.

Thanks, that works fine. I thought it was strange not having an or/and operand for if's etc.

Are there lots of other undocumented features of IML?

Hi All.

I too wish to know, it would be of much use as in the documentation it mentions...

'Operands to the comparison operators must be numeric.'

To my understanding comparing two strings is not possible, only numbers can be compared - I find this quite restrictive. If their are any documents not in the current documentation, when can we expect this information to become available?

Regards

Alan

TimSharp
12-Amethyst
(To:acs_alan)

I agree that's restrictive. I come across these barriers all the time with the Isodraw Macro Language - things I've taken for granted in the past just can't be done in IML or have to be done using long winded workarounds.

It would be great if they went through the features of other macro languages to see what's missing in IML. I would push CoCreate's ME10 macro language, (another PTC product) as you can do just about anything with it and it has things such as menus, error trapping, screen prompts, table data etc. that were added on over the years and are just not possible in IML. I think IML works like a glorified recording function rather than a fully rounded macro language.

You can compare text. Below is an example showing the syntax (excuse the sample as it was what came to mind after my day yesterday ;-).

Macro Compare_Text
Define TryIt as String
TryIt = Get String "Am I lazy?"
If (TryIt = "Yes") Then
Message "You are self-aware."
Else
Message "Stop lying to yourself."
End If

End Macro

Announcements

Top Tags