Facility Control

 View Only
  • 1.  ogscript parsing

    Posted 08-11-2015 18:28
    I have a string parameter that I need to parse into an integer to do math with. I heard from here that ogScript uses javascript. If so then why isn't

    var yrdI = parseInt(yrd);

    working? ([I]yrd [/I]is a varible).


  • 2.  RE: ogscript parsing

    Posted 08-11-2015 18:33

    Can you post the part of the script where yrd is defined?

    You are correct that ogScript uses Javascript. We use parseInt quite often in our scripts.

    One possible reason:

    If you're defining yrd as:

    `var yrd =params.getParam('OID', 0);`

    That is a parameter object - not the value of the parameter.

    You should instead use:

    `var yrd = params.getValue('OID', 0);`

    OR

    `var yrd = params.getparam('OID', 0).getValue()`

    Note: If the parameter yrd is based on is already a number, you would also eliminate the need for parseInt.


    #DashBoard


  • 3.  RE: ogscript parsing

    Posted 08-11-2015 18:40
    var yrd = params.getValue('Yards', 0);
    if (yrd == 'Goal')
    {
    params.setValue('Yards',0,'Goal');
    }else
    {
    var yrdI = parseInt(yrd);
    yrdI+=10;
    params.setValue('Yards', 0, yrdI);
    }

    [I]Yards[/I] is the string and is either "Goal" or a number.


    #DashBoard


  • 4.  RE: ogscript parsing

    Posted 08-11-2015 18:44
    Haha, I feel so stupid. I forgot the .toString().

    #DashBoard