Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

PARENTHESES in GDL

Anonymous
Not applicable
In GS scripts for windows I have find following line:
!------------------------------------------------------------------------------------------------------------------------------
dim stOpeningDir[]
stOpeningDir[1] = `Inside`
stOpeningDir[2] = `Outside`

values "gs_opening_dir" stOpeningDir

bOpeningDirection = (gs_opening_dir = stOpeningDir[2]) !GS writes so

end
!-------------------------------------------------------------------------------------
! Above script can be written also so:
!-------------------------------------------------------------------------------------
dim stOpeningDir[]
stOpeningDir[1] = `Inside`
stOpeningDir[2] = `Outside`

values "gs_opening_dir" stOpeningDir

IF gs_opening_dir = "Outside" THEN bOpeningDirection=1 ELSE bOpeningDirection=0 !Written by me and is same that GS has wrote

END
!--------------------------------------------------------------------------------------------------------------------------------

So that's all means that PARENTHESES have another additional function like "Special" IF Statment for Integer values.
I'm I right, or not?
5 REPLIES 5
Anonymous
Not applicable
I am not entirely sure what it is that you are trying to say, but square parentheses [] are reserved for arrays.
Anonymous
Not applicable
I am not entirely sure what it is that you are trying to say, but square parentheses [] are reserved for arrays.
Frank Beister
Advisor
The expression
(gs_opening_dir = stOpeningDir[2])
is boolean calculation. It's a comparation with boolean results: =1 true, =0: false.
Using this you can reduce some complex IF-THEN - constructions.

E.g.:
! opening: "single","double"
! display_opening: "no","first","all"

selection = (opening="double")*3 + NOT(display_opening="no") + (display_opening="all")

GOTO 200 + selection
Result:

selection=
0: single opening, no opening lines
1: single opening, show opening lines
2: single opening, show opening lines
3: double opening, no opening lines
4: double opening, show first opening lines
5: double opening, show all opening lines


So YES, you are right.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Frank Beister
Advisor
The boolean operations have a lower priority than addition or multiplication (below "PUNKT VOR STRICH", you should understand that 😉 ). So you have to put paranthesis around it. The paranthesis itself (in this case) do not have another function than in a calculation like (3+4)*5 to get 35 instead of 23.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
Vielen dank F.Beister,

perfekt erklärt!

I will save your reply as tip in my PC, until "Next Generation" GDL Manuel. 😉

Gruß