Help with "Expression" and "Web Link" syntax


#1

Are there any examples on how to use the “Expression” element in the Application view? I know how to use regular expressions but not sure how to use this IDE element to accomplish a simple task.

I want to check if the string value I am getting from the Buzzer via the BLE Characteristic is “true” or “false”.
I tried setting the expression field to true or readData=="true" but no luck.

I would share the .atmo file but this form won’t let me add anything other than image files. Here is a screenshot of what I mean:

In the above example, the Label field correctly updates to true or false depending on the buzzer state that I set by pushing a button. I am using the same thing to feed the Expression element.

Any ideas or help would be greatly appreciated.


#2

First thing I notice is the argument you are passing to the Set Text ability of Text you want to be a static string so you will want to wrap that in quotes so it should have "Buzzer is ON"

So you can use a expression to do this, how ever a condition element would be easier. You can just in the connector going into the Condition element handle the conversion to a boolean and then use the Condition True, and Condition False triggers. Also you might just want the set the BLE Characteristic’s read type as a Boolean instead of a string then you wouldn’t need to do the string comparison in that app.


#3

Thank you for the detailed response. Although I couldn’t get the Expression block to work, I was able to get the Condition block to work.

Next, I want to trigger opening a URL that plays a message on my speaker. I’ve confirmed that calling it directly in Safari on my phone and desktop works as expected. I made a google URL shortened link to track how many times it gets called.

I know that there is a WebIO block for more complex actions but I used a Web Link block since all I wanted was to open a URL. This however did not work. I am using this configuration:

I see the trigger succeed on the Label but no URL is opened. Can you please help?

FYI, Before using the RL shortener, I tried using the original link. It also failed so I thought it might be that it was too long for the Web Link block to handle (almost 200 characters).