Author Topic: VA Pause from within inline function  (Read 3615 times)

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
VA Pause from within inline function
« on: July 07, 2017, 12:21:54 PM »
Is it possible to have an inline function use the Pause command or momentarily pause VA's command execution?

I have an inline function that doesn't finish executing until either the function is called a second time or the user presses a termination key. I'd like to have VA wait until the function is fully running before VA continues its execution. So basically there would be no pause in the inline function but a slight pause in VA's command execution. Yes I know I can just disable the option for having VA wait for the function to finish and then do this:

Code: [Select]
Inline C# Function: my inline function (no waiting to finish)
Pause 0.5 seconds
Do more stuff in VA

...but I'd rather my function be self-contained and handle all that it needs to in order to work properly. Thoughts?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: VA Pause from within inline function
« Reply #1 on: July 07, 2017, 01:05:42 PM »
If you want the inline function to decide when executing continues, you could use a loop to idle the command:
Code: [Select]
Inline C# Function: my inline function
Start Loop While : [~loopcontinue] Equals False
End Loop
Do more stuff in VA
And use the "SetBoolean" method inside the inline function to change "~loopcontinue" to "True", so the command proceeds.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VA Pause from within inline function
« Reply #2 on: July 07, 2017, 01:41:24 PM »
That would definitely be one way to do it and at least it gives control of the pause duration to the inline function :)

Still, it would be great to know if this could be done without additional pause syntax within the VA commands.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: VA Pause from within inline function
« Reply #3 on: July 07, 2017, 01:57:24 PM »
Are you asking if there's a way in the inline function to make VA pause across the board (all commands)?  If not, what Pfeil suggested by using variables is the way to communicate between VA and the inline function.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VA Pause from within inline function
« Reply #4 on: July 07, 2017, 02:23:51 PM »
Yes can the inline function effectively perform a self-contained Pause command?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: VA Pause from within inline function
« Reply #5 on: July 07, 2017, 03:51:05 PM »
can the inline function effectively perform a self-contained Pause command?
I would say no.

You can use the "Wait for inline function to finish before continuing" to "pause", but the function must complete before execution can continue; You can call "return" anywhere in your code to complete the function, but anything beyond that point will not execute.

You could split your command into two, and have the inline function execute the second part, but I don't feel that's less convoluted than a while loop(on the contrary).

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: VA Pause from within inline function
« Reply #6 on: July 08, 2017, 09:47:12 AM »
I think you're right Pfeil. Well after doing some more testing so far I've found my inline function initializes before the next line of VA code is reached, so I guess I'll keep plugging along :)