Works Process: If-Syntax

Hi
I would like to query the signal of another component with the “if” syntax,- not use the expression as counter as in the example.
Is it possible ?

Hi,

I would like that too. Did you manage to do that? Is it possible? Thanks in advance.

Hello, About your question, I have the answer.

If- Syntax

Just Remember, first need define our Variables in the section UserVariables, with correct type, and this variables no restart automatically

with WriteSignal you can use in one if and communicate with other works with waitsignal to start a new condition

Thanks for your answer! Can you please explain it more clearly? I still don’t understand how can I use these two commands to make If with them.

Apologies. There was a delay in approving the first post of Quintan.E.

The expression of the If task cannot refer to a signal in another component. There are workarounds.

My suggestion:

  • Use a WaitSignal task instead of an If task to query the signal value of another component.
  • In the WaitSignal task SignalValue property, use a question mark (?) to make a conditional argument. That is, do something based on the signal value.
  • If you do not want the WaitSignal to listen for an event/trigger before evaluating the signal, set the WaitTrigger property of the WaitSignal task to false.
Refer to WaitSignal task in the Works Task Reference Guide, found on this forum.

https://forum.visualcomponents.com/forums/topic/works-library-tasks-reference-guide/

The May 3, 2019 version of that guide has the task description on page 128.

There appears to be interest in the ability to reference signal values in expressions for conditional tasks. Possibly a new feature or expression function for Works, e.g. If:signal(Works Process#2,SensorBooleanSignal):True?False. However, the WaitSignal task can do the job, and I think someone might have already modified an If task to do what you want. I do know others would like the ability to read robot IO, so let’s see where this goes.

Hi zesty! Thanks for the tip! Unfortunately I didn’t have much succes with the WaitSignal, because I needed multiple conditional WaitSignals, but in value there can be only True?False, so signals from different components lead to same result. (or i did something wrong)

Fortunately, I finally managed to make custom task for it. In the layout is custom Works Process with IfSignal task in it. Inputs are Component name, Signal name, Then and Else. If the signal value is True, “Then” executes, otherwise it executes “Else”. It should be working.

ifsignal-test-1.vcmx (1.22 MB)

1 Like

I understand now. Yes, a WaitSignal task evaluates signal from one component. The conditional values can be numerous based on the signal type. With Boolean, true or false, but with strings and integers you have a bit more freedom. Good that you were able to make a custom task, and even better that you provided us with the example :slight_smile: