Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Newbie with scripting data source

  • Hello,
    So i want to try using scripting data source. I try to make a tank level system, which fill itself 1 by 1, with a max value of 20, then go back to 0 all of this by pressing a button. If the button is disable, then the tank level value is 0. If I'm able to do that, next I want to be able to control the tank level max value using a slider. If someone has any idea how i should proceed it's awesome, for now here is my code and data points settings :
    Thanks to anyone that would help me !

  • This should be pretty easy. You can create Data Points on the Scripting Data Source for the Disable button and the max level setting and use those in your script. I would start by reading these links to start with and then ask any specific questions if you run into trouble

  • @joelhaggar Thanks a lot, i edit my first post because image where not displaying properly. So i looked at your link but i'm very new to all of this so i'm kinda lost. Do you have any idea if what i've done so far make sens or not ?

  • I think it makes sense but I'm not much of a coder myself. Does it work?

  • @joelhaggar Well.. no that's the problem :/ I might have missed a step or something. I mean, i added my binary button, the tank level and the slider (which from 0 to 20) and link all together using Data Points' XIDs but... nothing is happening, so yeah i'm kinda lost. But thanks a lot

  • For a start, your for loop needs to have
    var i=0; i<=421.value; i++
    Secondly, to set a value as can be read under "Mango JavaScript" you use the set function:

    if ( p420.value == true )
      for (var i=0; i<=421.value; i++)
    //1st case
        p422.set( p422.value + 1); //current value + 1*value of slider + 1
    else //else if not needed since you're either true or not true (==false)
      p422.set( 0 ); //Set to 0 

    Try rereading the docs provided by Joel to get a better grasp of what I have written and how it relates to the documentation provided.