How to correctly pass values to UI macros?

Home Forums Problems and solutions in GDL Graphical UI and parameters list How to correctly pass values to UI macros?

Viewing 2 reply threads
  • Author
    Posts
    • #4455
      Tim Haering
      Participant

      Hey everyone,
      i’m having trouble wrapping my head arround some issues regarding interfaces called by macros and teir data. The situation:

      Main object
      calls
      Macro1
      calls
      Macro2
      calls
      Macro3

      I modified the UI code that sits in Macro3 and it is displayed fine in the UI of the main object. Now i would like to use the user set value from the main object UI in the 3D-Script of Macro3. Do i have to pass it as parameter all the way down the macro chain to make it work? Is the macro treated as a function of the main object? In that case it should be able to read the value in the main object which it doesn’t. This left me quite confused maybe someone could explain it in detail or point me out to a ressource helping me?
      Thanks in advance!

    • #4456
      Péter Baksa
      Keymaster

      Hi,

      This works like in other languages’ function calls, just without the parentheses.
      To pass a parameter to a macro, use parameters all, or set it explicitly: call "macro" parameters p = p, .... The called macro’s unset parameters will be initialized to their default values visible in the parameter list.
      A macro doesn’t know about its caller’s parameters, so if it doesn’t have one, it can’t be passed further, and the lower macro’s parameter will be again initialized to its default value in the lower macro.
      So all the intermediate macros have to have the parameters that you are passing to the furthest one, and they have to be set in each macro call.

      Péter Baksa
      Library Platform, Software Engineer
      GRAPHISOFT SE

    • #4460
      Tim Haering
      Participant

      Thanks for the help Peter! Your detailed explanation helped a lot.

Viewing 2 reply threads
  • The forum ‘Graphical UI and parameters list’ is closed to new topics and replies.