Scripting in VIEWON

I am reading an EWON tag and want display (in VIEWON) an ASCII string based on the integer value of the tag. The tag value ranges from 0-4 and I want to show the corresponding text in a label.

How do in do this?

Currently I’m using a ‘Text on measure’ animation to scale an Ewon value. I’m assuming I need to do some scripting but I’m not sure if this needs to be in the Text on measure animation or perhaps under Actions- execute Viewon script?


Just to make sure I am following correctly, you would like to update a status to reflect a corresponding string.

For example, when the value is a 0 the textfield should read: Stopped

Is this accurate?



Perfect! That is easy enough to accomplish.

Basically you were on the right path however you are correct in that you will need a script to accomplish this. You will use the animation Text --> Simple. In there we will create a script that will check the value of your eWON tag and then will assign a new string to the text based on that tag.

  1. Create a new Text element in your ViewOn dashboard.

  2. Select Animations -> Text -> Simple

  3. Inside of the animation properties, select the ic2 to select tags. You should be prompted with a little basic scripting dialog.

  4. Enter the following script but note this is written as a precanned example, you will want to update the values for your device.

IF YourTag@ = 0 THEN
    viewon! = "STOPPED"
    IF YourTag@ = 1 THEN
        viewon! = "CRANKING"
        IF YourTag@ = 2 THEN
            viewon! = "CRANK PAUSE"
            IF YourTag@ = 3 THEN
                viewon! = "IDLE"
                IF YourTag@ = 4 THEN
                    viewon! = "Running"

The big thing with the above is to replace YourTag@ with your actual tagname.

That worked great- thank you! Just curious- is there a CASE command available for VIEWON scripting? I might enter as many as 16 different conditions.

I would also like to generate 3-4 different email messages based on the DISPLAY_STATUS. Right now I have an alarm condition set up sending NOT RUNNING for an alarm level Low, and RUNNING for alarm level high. I’d really like a few more different messages to be sent depending on the value.

If DISPLAY_STATUS = 0, send an email indicating STOPPED

If DISPLAY_STATUS = 4, send an email indicating RUNNING

If DISPLAY_STATUS = 15, send an email indicating STANDBY

I have done very little scripting in the EWON. How difficult is this?


Unfortunately there doesn’t exist a Switch/Case statement in BASIC. You will need to write clauses for all possibilities.

As for the emailing, you can just use a SENDMAIL request to send a different email.

    SENDMAIL "to-email", "cc-email", "Subject", "Stopped message"

You would then simply repeat this for all other email options.

I am building a pretty long script for this, so i automated it using excel and have it ready but ViewOn does not allow me to paste it in?