0

Should this code execute and assign the value of "bar" into the variable baz?

foo = "bar"
baz = "bazza"
cmd = "baz = foo"
node.input(cmd)  
print("this is foo "..foo)
print("this is baz "..baz)

Would expect output to be:

this is foo bar
this is baz bar

It doesn't is there something I'm missing?

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85

1 Answers1

0

Ahh hah moment, after looking at the source it appears that a timer is used to execute the command, so after waiting a little bit I do get the expected result. This works

function launch()
  foo = "bar"
  baz = "bazza"
  cmd = "baz = foo"
  node.input(cmd)  
  print("this is foo "..foo)
  print("this is baz "..baz)

  tmr.alarm( 1 , 50 , 0 , somethingElse )

end

function somethingElse()
  print("this is foo "..foo)
  print("this is baz "..baz)
end

tmr.alarm( 0 , 15000 , 0 , launch )