Notifications
Clear all
[Closed] How to exit if condition is met
Nov 15, 2021 5:26 am
am trying to exit a script when the condition is met
(
if a==1
then
exit
)
else
(
a=1
)
i want to do something like this the first time it runs it skips to and evaluate the (else) lines
then the next run it will evaluate the ( then ) lines and exits without re-evaluating the (else) lines
is this even possible ?
7 Replies
Nov 15, 2021 5:26 am
if you re-run the script the a value will be zero again
what am trying to do is to check if its = 1 if not then make it = 1
then when the script is re-run again it will remain 1 and will fall in the condition and exit without the need to evaluate the code under else again
i hope i could explain what am after
Nov 15, 2021 5:26 am
a = 0
once_set = false
(
if a != 1 do
(
if not once_set do
(
a = 1
once_set = true
)
)
if a == 1 do
(
-- ...........
)
)
Nov 15, 2021 5:26 am
(
global a
if a != 1 do
(
a = 1
-- Evaluate your code here
print "Hello World"
)
)
From a function:
(
global a
fn EvaluateCode = if a != 1 do
(
a = 1
-- Evaluate your code here
print "Hello World"
)
EvaluateCode()
)
Nov 15, 2021 5:26 am
thanks alot ,can you please explain what once_set is and whats its doing ?
1 Reply