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

UI_BUTTON problem

Anonymous
Not applicable
Hey,

I'm trying to use UI_BUTTON to run a sub script. I see the only way to do this is to check the value of GLOB_UI_BUTTON in master script and then do a GOSUB.

The problem here is that I can't reset GLOB_UI_BUTTON so it will do the function for multiple times every time the master script is ran. If I add a check to see if the GLOB_UI_BUTTON has changed or not, it won't have this problem, but then nothing happens if I want to press one button more than once in a row.

Is there any way to do this? It would be much easier if you could add a function directly into the button script like this:
UI_BUTTON GOSUB "my_function", text, x, y [, width, height, id]
But the documentation here doesn't say its possible: http://gdl.graphisoft.com/gdl-docs/gdl-guide/chapter-9-non-geometric-scripts/the-user-interface-scri...
1 REPLY 1
Lachlan Green
Enthusiast
Hi Jrantala,

This happens because the parameter script can be run multiple times, thus resulting in the calculation occurring twice or more. I had this exact problem last year and it's a simple solution. Here is the topic I started. It has a working object in my last reply. Essentially you need to insert the code below from Michael Rensing (Found in this topic) which only runs part of the script if it is the first time the script is being run.
Michael wrote:
This should do it.
Code:

n = APPLICATION_QUERY ("PARAMETER_SCRIPT", "FIRSTOCCASION_IN_PROGRESS", isFirstRun)
IF isFirstRun THEN
A=A+1
ELSE
A=A
ENDIF
Lachlan Green | Wilson Architects | BIM Manager, Architect
Started on AC9 | Currently AC27 & AC28 | BIMCloud | GDL
Mac Studio (14,13) M2 Max, 64GB, 1TB SSD | MacOS 14.7