GDL: Button Interaction

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-04-11 09:18 AM - edited ‎2023-04-11 09:21 AM
Hi all,
Anyone have a clue why this button is not inversing the values, but instead is making them uniform?
If the first entry is 1, I want all the entries to change to 0, and if it is 0 I want them all to become 1. Instead, it makes all the entries match the first...
IF GLOB_UI_BUTTON_ID = 3 then
IF sg_lengthToggle[1][2] = 0 then
FOR i = 1 to sg_noBasement
sg_lengthToggle[i][2] = 1
PARAMETERS sg_lengthToggle[i][2] = sg_lengthToggle[i][2]
next i
ELSE
FOR i = 1 to sg_noBasement
sg_lengthToggle[i][2] = 0
PARAMETERS sg_lengthToggle[i][2] = sg_lengthToggle[i][2]
next i
endIF
endIF
Ling
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
Solved! Go to Solution.
- Labels:
-
Library (GDL)
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-04-13 10:03 AM - edited ‎2023-04-13 10:04 AM
Either you have to set "Run parameter script only once" in Compatibility Options, or query whether the script is run first after a user interaction:
isFirstRun = 0
success = APPLICATION_QUERY ("parameter_script", "firstoccasion_in_progress", isFirstRun)
if success & isFirstRun & GLOB_UI_BUTTON_ID = ...
Software Engineer, Library
Graphisoft SE, Budapest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-04-11 10:33 AM
Is it a rerun problem? It looks to me that every time the code is run it will toggle the value. Should it perhaps be controlled using GLOB_MODPAR_NAME with the GLOB_UI_BUTTON_ID parameter?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-04-11 11:03 AM
It should only be running once on button press, unless GLOB_UI_BUTTON_ID does not reset after function? You cannot seem to use GLOB_UI_BUTTON_ID with GLOB_MODPAR_NAME. Not sure how else to enforce a single run if that is the cause...
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-04-11 03:05 PM - edited ‎2023-04-11 03:11 PM
Maybe try changing to
PARAMETERS sg_lengthToggle = sg_lengthToggle ?
edit: plus i suggest to move PARAMETERS before last ENDIF, not to do it inside a loop

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-04-11 06:15 PM - edited ‎2023-04-11 06:17 PM
I managed to make it work by using a checkbox rather than a UI_BUTTON
test = sg_lengthToggle[1][2]
if invert then
for i = 1 to sg_noBasement
sg_lengthToggle[i][2] = not(test)
next i
parameters invert = 0
endif
parameters sg_lengthToggle = sg_lengthToggle
'invert' being the name of the checkbox. So if there is no necessity to use a button then you could juste stylize the checkbox like a button and that would work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-04-13 10:03 AM - edited ‎2023-04-13 10:04 AM
Either you have to set "Run parameter script only once" in Compatibility Options, or query whether the script is run first after a user interaction:
isFirstRun = 0
success = APPLICATION_QUERY ("parameter_script", "firstoccasion_in_progress", isFirstRun)
if success & isFirstRun & GLOB_UI_BUTTON_ID = ...
Software Engineer, Library
Graphisoft SE, Budapest

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-04-13 10:38 AM
Put all my button queries between an IF statement of the first run query and it all works. Thanks again Peter.
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-05-01 11:12 AM - edited ‎2023-05-02 06:22 AM
@Peter Baksa , can you only have one first run query? I added a second one in my Master Script in order to offset array values, but it appears to break my buttons in my parameter script...
Ling.
ps. Would appear to be so, or at least that I can't do it in both the Master and Parameter scripts at the same time. Merged my Master one into my Parameter one.
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-05-03 10:13 AM
The master script runs before the UI script too, and the query doesn't make sense in UI context - that is my first idea.
Software Engineer, Library
Graphisoft SE, Budapest