RobotStudio event

Check for integer

I have a situation where I need to check to see if a calculated num value is an integer. I am struggling to find an easy way to do this. Suggestions?

Comments

  • DenisFR
    DenisFR ✭✭✭
    Hello,
    :=(Trunc(<code>numValue)=<code>numValue);
    <code>bIsInt





  • lemster68
    lemster68 ✭✭✭
    Try NumToStr, then StrMatch for a ".", the decimal.
    Lee Justice
  • lemster68
    lemster68 ✭✭✭
    DenisFR said:
    Hello,
    :=(Trunc(<code>numValue)=<code>numValue);
    <code>bIsInt


    I think I get that @DenisFR.  Nice



    Lee Justice
  • DenisFR said:
    Hello,
    :=(Trunc(<code>numValue)=<code>numValue);
    <code>bIsInt





    Nice simple code! I knew there would be an easy way to do it. Thanks!
  • Micky
    Micky ✭✭✭
    edited July 2019
    Hello,

    RAPID offers the instruction "TryInt" to check if a number is an integer.
    <p>VAR num myint := 5.2;</p><p><br></p><p><b>TryInt</b> myint;<br></p><p>ERROR<br></p><div><p>IF ERRNO = ERR_INT_NOTVAL THEN</p><p><br></p><p>  myint := Round(myint);</p><p><br></p><p>  RETRY;</p><p><br></p></div><div><p><span>ENDIF<br></span></p></div>
    /BR
    Micky