cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
2024 Technology Preview Program

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

GDL
About building parametric objects with GDL.
SOLVED!

IF THEN Statements

GDL Enthusiast
Enthusiast

Hi,

 

If I write and IF THEN statement, the editor sometimes returns an error if I add an ENDIF on the next line. Most of the time it seems to run without error if I don't even add the ENDIF statement when creating a list of logic. 

 

The editor seems to like ENDIF after a series of parameters e.g:

IF list = 0 THEN

item = 1

method = 2

ENDIF

 

The Editor has no fault with no ENDIF after the following logic:

IF list = 0 THEN item = 0

IF list = 1 THEN item = 1

IF list = 1 THEN item = 1

 

Is there a clue as to when an ENDIF is required?

 

Many thanks, Matt

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Barry Kelly
Moderator

When the IF, THEN, command is all on the same line, you do not need the ENDIF (I still put it there anyway).

When the command is on a separate line, you must use ENDIF.

 

Barry.

 

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

View solution in original post

3 REPLIES 3
Solution
Barry Kelly
Moderator

When the IF, THEN, command is all on the same line, you do not need the ENDIF (I still put it there anyway).

When the command is on a separate line, you must use ENDIF.

 

Barry.

 

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
A_ Smith
Expert

if condition has only one statement and (as Barry mentioned) then is on the same line, you don't need endif

AC 22, 24 | Win 10
GDL Enthusiast
Enthusiast

That is helpful. It was one of those unknowns that is very pleasing to have a definitive answer to. 

 

Thank you both Barry and A_Smith for your responses!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!