Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - ival() convert a string to its numeric representation http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ival()              Convert a string to its numeric representation
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   func long ival extern
   param const char cNumberString

 Arguments
   cNumberString is the character string to convert.

 Return
   A numeric representation of the input string.

 Description
   The ival() function converts cNumberString to a long value. ival()
   continues to convert the character string until the end of the string or
   a non-numeric value is reached. If no valid number is contained within
   the string, ival() returns zero.

   The ival() function removes any preceding tabs or spaces from the string
   cNumberString.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   proc Test_ival
   // Convert a command line parameter to a number.
   vardef
      uint nIterations      // Although istr() returns
                               //  a long, Force compiler
                               //  converts the result to
                               //  an int automatically
   enddef
   
   nIterations := ival( argv( 1 ) ) // convert command line parameter
   do while nIterations > 0
      ? nIterations  // do appropriate processing here
      nIterations--  // decrement counter
   enddo
   
   // Any non-numeric character terminates istr() processing, not just
   // white space
   ? ival( "1234P" )   // 1234 is printed
   
   endproc

   proc main
   Test_ival()
   endproc

See Also: istr() val()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson