IF: Difference between revisions
From Macros Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| (20 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{ | [[:Category:Language|{{Up}}]] | ||
|param1=<value>|param1_desc= | {{Command|syntax=IF <value 1> <condition> <value 2>, THEN | ||
|param2=<condition>|param2_desc= | |description=:Conditional check to compare two values and act upon the result. | ||
|param3=<value>|param3_desc= | |||
|param4=THEN|param4_desc= | |param1=<value 1>|param1_desc=First value to check | ||
|param2=<condition>|param2_desc=Type of check, must be on of the following<br> | |||
:<nowiki>=</nowiki> Equals | |||
:<nowiki><></nowiki> Not equal | |||
:<nowiki><</nowiki> Less than | |||
:<nowiki>></nowiki> Greater than | |||
:<nowiki><=</nowiki> Less than or equal | |||
:<nowiki>>=</nowiki> Greater than or equal | |||
|param3=<value 2>|param3_desc=Second value to check | |||
|param4=THEN|param4_desc=The second value must be followed by THEN<br> | |||
:Any macro command can follow THEN. This command will be executed if the check if true | |||
}} | }} | ||
===Example=== | ===Example=== | ||
: | :A1 = 3 | ||
:A2 = 4 | |||
:IF A1 < A2 THEN Message "Hello" | |||
:IF A1 = A2 THEN Message "Goodbye" | |||
<br> | |||
:The message "Hello" will be displayed (because 3 is less than 4), but the message "Goodbye" will not be displayed (because 3 is not eual to 4). | |||
:For an example macro see [[Modify_Op_Path]] [[Modify_op_path2]] [[Calc_Geo_Extents]] [[Check_Point_Data]] [[Check_Circle_Data]] [[Check_Arc_Data]] [[Debug_Sel_geo]] [[Geo_Pattern]] [[Get_MTM_Data]] [[Get_Op_Tool_Path]] [[Global_Local]] [[Inch_Metric]] [[Print_Geo_Data_To_File]] [[Solid_Type]] [[Wg_List]] | |||
[[Category:Language]] | [[Category:Language]] | ||
Latest revision as of 00:04, 15 January 2011
Command
- IF <value 1> <condition> <value 2>, THEN
- Conditional check to compare two values and act upon the result.
Parameters
- <value 1>
- First value to check
- <condition>
- Type of check, must be on of the following
- = Equals
- <> Not equal
- < Less than
- > Greater than
- <= Less than or equal
- >= Greater than or equal
- <value 2>
- Second value to check
- THEN
- The second value must be followed by THEN
- Any macro command can follow THEN. This command will be executed if the check if true
Example
- A1 = 3
- A2 = 4
- IF A1 < A2 THEN Message "Hello"
- IF A1 = A2 THEN Message "Goodbye"
- The message "Hello" will be displayed (because 3 is less than 4), but the message "Goodbye" will not be displayed (because 3 is not eual to 4).