# Sequence in operation

**URL:** <https://discourse.nodered.org/t/sequence-in-operation/71445>\
**Category:** General\
**Created:** [29 November 2022 12:25 UTC](https://discourse.nodered.org/t/sequence-in-operation/71445 "2022-11-29T12:25:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)\
**Post date:** [29 November 2022 12:25 UTC](https://discourse.nodered.org/t/sequence-in-operation/71445/1 "2022-11-29T12:25:47Z")

</div>

Hi,  
I try with difficulty to improve my code and so sometimes I have probably banal questions to propose you.  
In my node-red project I have many delay node (and I'd like to reduce them) because I always put them between two function when in the second function I need to read the value of a variable set in the previous function.

Example:  
I use many node chronos scheduler ...

![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/501aab096fb7e895c838305ad17091723a796e5d.png)

node configuration

![chronos](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/5770c010c988009ca0ce7f6a404fb7a68f0edd59.png)

code flow

![code](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0e63ebb0cba8db4415c984615dca8773909e4bf8.png)

Well, the delay is necessary or independently by the complexity of the function previous (the example in very simple but is not always the case) the node chronos will always be able to read the flow variable also without the delay?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [29 November 2022 12:39 UTC](https://discourse.nodered.org/t/sequence-in-operation/71445/2 "2022-11-29T12:39:05Z")

</div>

I can't see the value of the delay node in the example you give above.

Your function and scheduler nodes are not both running at the same time.  
The scheduler node will do nothing until a message arrives at it's input.  
The function first sets flow.hour\_timer and then sends msg.

So the delay just provides a window in which flow.hour\_timer could be reset by another run (instance? iteration?) of the function or by some other part of the flow, presumably before it is used.

---

<div class="post-metadata">

**Author:** ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)\
**Post date:** [29 November 2022 12:46 UTC](https://discourse.nodered.org/t/sequence-in-operation/71445/3 "2022-11-29T12:46:00Z")

</div>

Ok,  
the instruction

```auto
flow.set("hour_timer", orario);

```

is performed before the

```auto
return msg;

```

Not simultaneously at the end of the function, as I thought ....

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [29 November 2022 13:24 UTC](https://discourse.nodered.org/t/sequence-in-operation/71445/4 "2022-11-29T13:24:19Z")

</div>

To be honest I don't know how individual actions within a function node are sequenced, but I assume that "return msg" is not executed until "flow.set...." is complete.

I am sure though that the scheduler node will do nothing until after the function node sends a message, regardless of a delay node.

Is flow.hour\_timer _only_ there to pass a value to the scheduler node? Although I am not familiar with the scheduler node, I assume you could use a property of the message. For example, in the function msg.hour\_timer = orario; and refer to msg.hour\_timer in the scheduler.

---

<div class="post-metadata">

**Author:** ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)\
**Post date:** [29 November 2022 14:07 UTC](https://discourse.nodered.org/t/sequence-in-operation/71445/5 "2022-11-29T14:07:33Z")

</div>

Ok, thank you ....

---

<div class="post-metadata">

**Author:** ![jens\_rossbach](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jens_rossbach/32/98717_2.png) [@jens\_rossbach](https://discourse.nodered.org/u/jens_rossbach)\
**Post date:** [15 January 2023 13:43 UTC](https://discourse.nodered.org/t/sequence-in-operation/71445/6 "2023-01-15T13:43:06Z")

</div>

I don't see the need for the delay node. The scheduler node reads the content from the flow context variable at flow deployment (so if the variable is not yet existing then, which is the case if you use memory-based variables, the node will run into an error) and everytime it gets refreshed via the input message (either enable or reload command). At that time, the timers will be (re)started.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 March 2023 13:43 UTC](https://discourse.nodered.org/t/sequence-in-operation/71445/7 "2023-03-16T13:43:29Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
