### SLA_INTIN

Decode an Integer Number

ACTION:
Convert free-format input into an integer.
CALL:
CALL sla_INTIN (STRING, NSTRT, IRESLT, JFLAG)
##### GIVEN:
 STRING C string containing number to be decoded NSTRT I pointer to where decoding is to commence IRESLT I current value of result

##### RETURNED:
 NSTRT I advanced to next number IRESLT I result JFLAG I status: $-$1 = $-$OK, 0 = +OK, 1 = null result, 2 = error

NOTES:
(1)
The reason sla_INTIN has separate ‘OK’ status values for + and $-$ is to enable minus zero to be detected. This is of crucial importance when decoding mixed-radix numbers. For example, an angle expressed as degrees, arcminutes and arcseconds may have a leading minus sign but a zero degrees field.
(2)
A TAB is interpreted as a space. n.b. The test for TAB is ASCII-specific.
(3)
The basic format is the sequence of fields $±n$, where $±$ is a sign character ‘+’ or ‘$-$’, and $n$ means a string of decimal digits.
(4)
Spaces:
• Spaces between the sign and the number are allowed.
• Trailing spaces are ignored; the first signifies end of decoding and subsequent ones are skipped.
(5)
Delimiters:
• Any character other than +,$-$,0-9 or space may be used to signal the end of the number and terminate decoding.
• Comma is recognized by sla_INTIN as a special case; it is skipped, leaving the pointer on the next character. See 9, below.
• Decoding will in all cases terminate if end of string is reached.
(6)
The sign is optional. The default is +.
(7)
A null result occurs when the string of characters being decoded does not begin with +,$-$ or 0-9, or consists entirely of spaces. When this condition is detected, JFLAG is set to 1 and IRESLT is left untouched.
(8)
NSTRT = 1 for the first character in the string.
(9)
On return from sla_INTIN, NSTRT is set ready for the next decode – following trailing blanks and any comma. If a delimiter other than comma is being used, NSTRT must be incremented before the next call to sla_INTIN, otherwise all subsequent calls will return a null result.
(10)
Errors (JFLAG=2) occur when:
• there is a + or $-$ but no number; or
• the number is greater than ${2}^{31}-1$.
(11)
When an error has been detected, NSTRT is left pointing to the character following the last one used before the error came to light.
(12)