Are API/broadcast events restricted from calling component or user macros?

For general Flowcode discussion that does not belong in the other sections.
Post Reply
medelec35
Valued Contributor
Posts: 2411
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 768 times
Been thanked: 830 times

Flowcode v11 Are API/broadcast events restricted from calling component or user macros?

Post by medelec35 »

I've been working on a PC Developer project that saves and loads component properties to a config file via PropertyManager. I've run into a consistent, repeatable issue, and having dug into it, I believe I now understand the actual cause.

Whenever I call PropertyManager1::Save / PropertyManager1::Load, or other multi-step component macros, from inside an event handler — tested across Ev_Property, Ev_Initialise, Ev_Start, Ev_Stop, Ev_PostInitialise and Ev_ProjectClosedown — it either silently fails (e.g. a 0-byte config file, no error) or doesn't complete properly. Simple calculations and flag assignments inside the same event handlers work fine every time.

This is standard interrupt behaviour: the wiki describes an event as functioning "similarly to an Interrupt," and specifically as "a simulation-side interrupt." Events are interrupts, and interrupt rules apply — you can call a component's macro from one so long as it's fairly simple and not something that could already be running elsewhere at the same time. Property Manager's Save/Load and CSV Read/Write are multi-step and share state with the rest of the project, so calling them from an event risks the interrupt cutting in mid-sequence — exactly matching the failures I've seen.

The workaround, and the correct way to do this: set a flag inside the event handler, then consume that flag afterwards from Main, in a normal execution context — that works reliably every time.

Could you confirm this is indeed how events are implemented under the hood? If so, it'd be worth stating plainly in the docs, since it isn't spelled out anywhere currently and cost a fair bit of time to track down. Original save/load symptom for reference can be found here

Thanks.
Martin

Steve-Matrix
Matrix Staff
Posts: 2030
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 302 times
Been thanked: 469 times

Re: Are API/broadcast events restricted from calling component or user macros?

Post by Steve-Matrix »

Are you able to distil the issue you are having into a very simple project and then explain what you're seeing?

Steve-Matrix
Matrix Staff
Posts: 2030
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 302 times
Been thanked: 469 times

Re: Are API/broadcast events restricted from calling component or user macros?

Post by Steve-Matrix »

Sorry - I see that there's a succinct project in the linked post. I'll have a look. Although you seem to have solved the issue anyway and so hopefully you're good to continue?
medelec35 wrote:
Mon Sep 14, 2026 9:45 pm
Could you confirm this is indeed how events are implemented under the hood? If so, it'd be worth stating plainly in the docs, since it isn't spelled out anywhere currently and cost a fair bit of time to track down.
Historically, Events and a lot of the simulation API have been solely for internal use to allow us to create components. For this reason, the public documentation surrounding them is probably lacking. I'll see if we can find some time to improve this.

Post Reply