You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I pass a variable to a snippet. The snippet uses the variable inside a condition, but in side that condition, the variable value is different from outside the condition.
Sample code:
---
title: Condition test
---
<<#SingleWindow
- app_name=Messages
<<#SingleWindow
- app_name=Slack
<<#SingleWindow
- app_name=Mail
___
---[SingleWindow]
(log Start: ${app_name})
if app_name
(log Processing: ${app_name})
${app_name}
- XX
@${app_name}
(pause 1)
end
(log Done: ${app_name})
Log-output in Console:
Start: Messages
Process: Mail ## Variable changed from "Messages" to "Mail"
Done: Messages
Start: Slack
Process: Mail ## Variable changed from "Slack" to "Mail"
Done: Slack
Start: Mail
Process: Mail
Done: Mail
As you can see, the log output inside the condition uses the value "Mail" for the app_name variable in all three cases, even though the log message before and after the condition displays the expected value.
Question:
Is this expected? If yes, how can I "persists" a variable value inside a condition?
The text was updated successfully, but these errors were encountered:
I'll need to dig back in and see if I can have it read the snippet fresh
on each iteration, replacing the variable each time rather than
permanently once and then not updating it on successive reads. So, in
short, expected behavior, but not ideal behavior. Will dig back into
this as I'm able.
On 27 Jan 2024, at 11:23, Philipp Stracker wrote:
I pass a variable to a snippet. The snippet uses the variable inside a
condition, but in side that condition, the variable value is different
from outside the condition.
Sample code:
```bunch
---
title: Condition test
---
<<#SingleWindow
- app_name=Messages
<<#SingleWindow
- app_name=Slack
<<#SingleWindow
- app_name=Mail
___
---[SingleWindow]
(log Start: ${app_name})
if app_name
(log Processing: ${app_name})
${app_name}
- XX
@${app_name}
(pause 1)
end
(log Done: ${app_name})
```
Log-output in Console:
```
Start: Messages
Process: Mail ## Variable changed from "Messages" to "Mail"
Done: Messages
Start: Slack
Process: Mail ## Variable changed from "Slack" to "Mail"
Done: Slack
Start: Mail
Process: Mail
Done: Mail
```
As you can see, the log output inside the condition uses the value
"Mail" for the app_name variable in all three cases, even though the
log message before and after the condition displays the expected
value.
**Question:**
Is this expected? If yes, how can I "persists" a variable value inside
a condition?
--
Reply to this email directly or view it on GitHub:
#316
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
I pass a variable to a snippet. The snippet uses the variable inside a condition, but in side that condition, the variable value is different from outside the condition.
Sample code:
Log-output in Console:
As you can see, the log output inside the condition uses the value "Mail" for the app_name variable in all three cases, even though the log message before and after the condition displays the expected value.
Question:
Is this expected? If yes, how can I "persists" a variable value inside a condition?
The text was updated successfully, but these errors were encountered: