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

"swapping" booleans

Anonymous
Not applicable
I have two parameters that, if one is on, the other needs to be off, and if the other is on, the (other) other needs to be off. I want the 'turning on' of one to turn off the other and the likewise.

So in my Master Script I use something like:

IF tcx = 1 THEN sc = 0
IF sc = 1 THEN tcx = 0

But what that does for me is only one side of it. If tcx gets turned on then sc is turned off, which is great, but then if I try and turn on sc, it won't let me and won't turn off tcx because tcx is already on and that means that sc HAS to be off.

Does this code (or something similar that actually works correctly) belong in a different script? or am I not thinking this through correctly?
8 REPLIES 8
TomWaltz
Participant
You need to incorporate GLOB_MODPAR_NAME, which is the name of the last parameter changed. It could really be in either the Master or Parameter script. I tend to put my stuff in the Parameter script, unless it is absolutely necessary to put it in the Master.

For example:
IF (GLOB_MODPAR_NAM = tcx) AND (tcx = 1) THEN 
sc = 0 
PARAMETERS sc= sc
ENDIF

IF (GLOB_MODPAR_NAM = sc) AND (sc = 1) THEN 
tcx = 0 
PARAMETERS  tcx = tcx
ENDIF
Tom Waltz
Anonymous
Not applicable
TomWaltz wrote:
Code:
IF (GLOB_MODPAR_NAM = tcx) AND (tcx = 1) THEN
sc = 0
PARAMETERS sc= sc
ENDIF

IF (GLOB_MODPAR_NAM = sc) AND (sc = 1) THEN
tcx = 0
PARAMETERS tcx = tcx
ENDIF
Tom I know that you know, but red markeds written with mistakes! 😉

In script that you have wroten "tcx" and "sc" can also be equal(0 or 1).
Correct beginning, but I think that script that sirduncan needs is:

IF GLOB_MODPAR_NAME = "tcx" THEN
sc=NOT(tcx)
PARAMETERS sc=sc
ENDIF

IF GLOB_MODPAR_NAME = "sc" THEN
tcx=NOT(sc)
PARAMETERS tcx=tcx
ENDIF
TomWaltz
Participant
In script that you have wroten "tcx" and "sc" can also be equal(0 or 1).
Correct beginning, but I think that script that sirduncan needs is:
You're right. I was just trying to give sirduncan the syntax to figure out the exact usage himself. Mine did not really work.
Tom Waltz
Anonymous
Not applicable
My congratulation Tom you have now over 600 Posts!
TomWaltz
Participant
Thanks. At the rate you're going, you'll catch up with me in no time, The funny thing is how in the beginning, I asked a million questions, now I'm actually providing usable answers once in a while!
Tom Waltz
Anonymous
Not applicable
Thanks guys - that did it. I haven't done anything with glob variables yet so this is as good of an intro as any. I'll have to read up on them. Thanks again for helping get this working.

So that you know, I actually used Toms code because I need to be able to have the them both off too. Only in the event that one is on and the other is toggled on would I need to turn off the first.

Thanks again.
TomWaltz
Participant
sirduncan.

if you really want to get ideas of what GDL can do for you, it's a good starting point to look over the "Global Variable" section of the manual. I've had a lot of good ideas by seeing what pieces I have in the Lego bucket.
Tom Waltz
Anonymous
Not applicable
Will do.