Previous: utidl Up: ../plot79_u.html Next: utidt
SUBROUTINE UTIDR (NUMBER,NEXT,ERROR,FIELD,LENGTH,FLUSH) C$ (Decode Roman Numerals From Character Form) C$ Convert an integer value represented as a string of Roman C$ numerals in FIELD(*) to internal (binary) format. Leading C$ blanks and tabs are ignored. Unlike FORTRAN formatted C$ input, blanks are significant. To permit free-form input, C$ the conversion will continue until a character which is C$ neither a sign nor a valid Roman numeral is found, or else C$ the end of FIELD(*) is reached. Lower-case letters are C$ acceptable input. A pointer is set to the next unprocessed C$ character in FIELD(*) (which might be FIELD(LENGTH+1)) so C$ that the caller may check for valid syntax. The arguments C$ are: C$ C$ NUMBER........Integer value (returned). C$ NEXT..........On exit, index of the character in FIELD(*) C$ which follows the last character processed. C$ On input, it should point to the first C$ character to be processed. C$ ERROR......... .TRUE. - No valid characters found (NUMBER C$ .EQ. 0), or illegal syntax in C$ Roman numeral (NUMBER .NE. 0). C$ The latter condition can occur if C$ adjacent numerals occur with the C$ smaller first, and they are not one C$ of the valid pairs "CM", "CD", C$ "XC", "XL", "IX", OR "IV". C$ Examples of illegal pairs are "IC" C$ (99), "ID" (499), and "VL" (45). C$ Since numeric values can be C$ determined for these pairs C$ following the usual subtraction C$ rule, conversion continues. C$ .FALSE. - No error occurred. C$ FIELD(*)......Character string to be decoded (A1 FORMAT). C$ LENGTH........Number of characters in FIELD(*). C$ FLUSH......... .TRUE. - Flush any leading invalid C$ (non-blank, non-tab) characters. C$ .FALSE. - Do not flush leading invalid C$ characters. C$ C$ The flush option is useful to allow successive calls to C$ retrieve Roman numerals separated by commas, spaces, etc. C$ The caller must realize, however, that this might cause C$ skipping over incorrectly-coded items (e.g. "II,III,IW,V" C$ for "II,III,IV,V"). C$ C$ The algorithm is adapted from D.E. Knuth, TEX - A System C$ for Writing Technical Text, extracted from the Pascal C$ source code. C$ (02-FEB-82)