IDMS ADS/O
ARITHMETIC FUNCTIONS


  ABS(VAL)   ABS-VAL  ABSOLUTE
      Returns the absolute value of a numeric value.
      EXAMPLE:  MOVE SUB(EMP-NAME),1,ABS(WK-LENGTH) TO WK-FNAME.

  INVERT(VAL)   INVERT-SIGN  INV
      Returns the specified numeric value with the opposite sign.
      EXAMPLE:  MOVE INVERT(WK-AMT) TO WK-AMT.

  LOG10(VAL)   LOG-BASE-10  LOGCOM  COMLOG
      Returns the common logarithm of the specified value.
      VAL must be greater than 0.
      EXAMPLE:  MOVE LOG10(WK-VALUE) TO WK-LOG-EQUIVALENT.

  LOGE(VAL)   LOG-BASE-E  LOGNAT  NATLOG
      Returns the natural logarithm of the specified value.
      VAL must be greater than 0.
      EXAMPLE:  MOVE LOGE(WK-VALUE) TO WK-LOG-EQUIVALENT.

  MOD(DIVIDEND,DIVISOR)   MODULO
      DIVIDEND  - numeric value that is divided by DIVISOR.
      DIVISOR   - numeric value that is divided into DIVIDEND.
      Returns the modulus (remainder) of one numeric value divided by another.
      EXAMPLE:  MOVE MOD(WK-VALUE1,WK-VALUE2) TO WK-REMAINDER.

  NEXTINTEH(VAL)   NEXT-INT-EQHI  NEXIH
      Returns the smallest integer that is equal to or greater than a numeric
      VALue.
      EXAMPLE:  MOVE NEXTINTEH(WK-BAL-DUE) TO WK-NEW-BAL.

  NEXTINTEL(VAL)   NEXT-INT-EQLO  NEXIL
      Returns the largest integer that is equal to or less than a numeric
      VALue.
      EXAMPLE:  MOVE NEXTINTEL(VAL) TO WK-FIELD.

  RANDOM(SEED)   RANDOM-NUMBER  RAN
      Returns a pseudo-random number based on SEED numeric value.
      The returned random number is greater than zero and less than 1,
      and has a length of 9 decimal places.

      To obtain random numbers, perform the following steps:
        1.  Set the initial random number seed value at execution time to
            some varying value, such as time.  The random seed must not
            be zero.
            If the result is set to a fixed value, each execution of the dia-
            log will result in the generation of the same series of pseduo-
            random numbers.
        2.  Move the pseudo-random number returned by the random number
            function to the seed variable data field.  The number returned be-
            comes the next seed value.  In this way, the random number func-
            tion can generate a non-repeating sequence of 536,870,912 numbers.
        3.  Define the seed value with a picture of 9(9) and move the result
            of the function to a variable with a picture of V9(9).
            The result can be moved back to the seed variable by using the re-
            sult as a redefinition of the see value, as follows:
      EXAMPLE: 03 SEED-VALUE PICUTRE 9(9).
               03 RESULT-VALUE REDEFINES SEED-VALUE PICTURE V9(9).
               03 RANDOM-TABLE PICTURE V9(9) OCCURS 10 TIMES.

               MOVE TIME TO SEED-VALUE.
               MOVE 1 TO WK-COUNT.
               WHILE WK-COUNT LE 10
                 REPEAT.
                   MOVE RANDOM(SEED-VALUE) TO RESULT-VALUE.
                   MOVE RESULT-VALUE TO RANDOM-TABLE(WK-COUNT).
                   ADD 1 TO WK-COUNT.
                 END.

  SIGV(VAL)   SIGN-VALUE  SIGN-VAL
      Returns a +1, 0, or -1 depending on whether the specified numeric
      value is positive, zero, or negative, respectively.
      EXAMPLE:  MOVE -453.29 TO WK-AMT.
                MOVE SIGV(WK-AMT) TO TRANS-CODE.     -1

  SQRT(VAL)   SQUARE-ROOT
      Returns the square root of a numeric value.
      EXAMPLE:  MOVE SQRT(WK-VAL) TO WK-RESULT.

DATE FUNCTIONS


  DATECHG(DATE,FROM,TO)
      Converts input DATE from FROM format to TO format.
      FROM & TO values:  C - calendar    (mmddyy)
                         E - european    (ddmmyy)
                         G - gregorian   (yymmdd)
                         J - julian      (yyddd)
      EXAMPLE:  MOVE DATECHG(580128,'G','C') TO WK-RESULT.

  DATEDIF(DATE1,DATE2)
      Returns the number of days between two dates (gregorian format).
      EXAMPLE:  MOVE DATEDIF(580128,550811) TO WK-RESULT.   returns 901

  DATEOFF(DATE1,DATE2)
      Returns the date resulting from adding a specified number of days
      to a specified date.  The returned date is in gregorian format.
      EXAMPLE:  MOVE DATEOFF(580128,4) TO WK-RESULT.

  TODAY('FMT')
      Returns today's date in FMT.
       FMT = C - calendar  (mmddyy)
             E - european  (ddmmyy)
             G - gregorian (yymmdd)
             J - julian    (yyddd)
      EXAMPLE:  MOVE TODAY('C') TO WK-RESULT.

  TOMORROW('FMT')
      Returns tomorrow's date in FMT.
       FMT = C - calendar  (mmddyy)
             E - european  (ddmmyy)
             G - gregorian (yymmdd)
             J - julian    (yyddd)
      EXAMPLE:  MOVE TOMORROW('C') TO WK-RESULT.

  WEEKDAY(DATE,FMT)
      Returns the weekday name of DATE in FMT format.
       FMT = C - calendar  (mmddyy)
             E - european  (ddmmyy)
             G - gregorian (yymmdd)
             J - julian    (yyddd)
      EXAMPLE:  MOVE WEEKDAY(012858,'C') TO WK-RESULT. 'TUESDAY'

  YESTERDAY('FMT')
      Returns yesterday's date in FMT.
       FMT = C - calendar  (mmddyy)
             E - european  (ddmmyy)
             G - gregorian (yymmdd)
             J - julian    (yyddd)
      EXAMPLE:  MOVE YESTERDAY('C') TO WK-RESULT.

STRING FUNCTIONS


  CONCAT(STRVAL...)   CONCATENATE  CON
      Returns the concatenation of a specified list of string vlaues.
      STRVAL specifies one or more string values that are conatenated to form
      a single string value.
      EXAMPLE:  MOVE CONCAT(EMP-FIRST-NAME,EMP-LAST-NAME) TO WK-NAME.

  EXTRACT(STRVAL)   EXT
      Returns the string that results from removing leading and trailing
      spaces from a string value.
      EXAMPLE:  MOVE EXTRACT('   GAR FIELD   ') TO WK-FLD.   'GAR FIELD'

  FIX20(STR)
      Returns a fixed length string of 20 characters.
      EXAMPLE:  MOVE FIX20('HELLO') TO WK-FLD. 'HELLO               '

  FIX40(STR)
      Returns a fixed length string of 40 characters.
      EXAMPLE:  MOVE FIX40('HELLO') TO WK-FLD. 'HELLO                                   '

  FIX60(STR)
      Returns a fixed length string of 60 characters.
      EXAMPLE:  MOVE FIX60('HELLO') TO WK-FLD. 'HELLO                                                       '

  FIX80(STR)
      Returns a fixed length string of 80 characters.
      EXAMPLE:  MOVE FIX60('HELLO') TO WK-FLD. 'HELLO                                                                           '

  INDEX(HAYSTACK,NEEDLE)   STRING-INDEX  INDX
      Returns the starting position of specified string NEEDLE within
      HAYSTACK.  If the specified string is not found, a zero is returned.
      EXAMPLE:  MOVE INDX('The condition is good','is') TO WK-SP.  15

  INITCAP(STR)
      Returns string that results when the fist letter in STR source string
      is capitalized and all other characters in the string are converted to
      lowercase.
      EXAMPLE:  MOVE INITCAP('THIS IS A TEST') TO WK-STR.  'This is a test'

  INSERT(HAYSTACK,NEEDLE,STARTPOS)
      Returns a string with NEEDLE insterted into HAYSTACK starting at STARTPOS.
      EXAMPLE:  MOVE INSERT('**','PARKIN',2) TO WK-STR.  '*PARKIN*'

  LEFT(STR)   LEFT-JUSTIFY  LEFT-JUST  LEFJUS
      Returns the strig that results from removing leading blanks from
      the left side of a string value, shifting the remainder of the string
      value to the left side, the filling the right side with as many blanks
      as were removed from the left side.
      EXAMPLE:  MOVE LEFT('    SMITH ') TO WRK-STR.  'SMITH     '

  LIKE(HAYSTACK,NEEDLE,ESCHAR)
      Tests for T (true) or F (false) when comparing a source string
      value with a supplied string.
      HAYSTACK - specifies the source string being tested.
      NEEDLE   - specifies the string to search for.
                 NEEDLE is compared with HAYSTACK, one character at a time,
                 starting with the leftmost character in each string. All
                 characters in the search string, except the mask characters
                 listed below, must match the contents of HAYSTACK exactly. The
                 mask characters are:
                 _ (underscore) matches any single character in the source
                   string.
                 % (percent sign) matches by any number of consecutive
                   characters zero or greater in the source string
      ESCHAR   - specifies a 1 character escape character that alows the
                 current LIKE expression to search for the underscore,
                 percent sign, and the escape character itself as actual
                 characters.
      EXAMPLE:  IF LIKE(ADDRESS,'%BOSTON%')

  SREPEAT(STR,NUM)   STRING-REPEAT  SREP
      Returns the string that results from repeating a string value a
      specified number of times.
      EXAMPLE:  MOVE SREPEAT('NAME',2) TO WRK-NAME.  'NAMENAMENAME'

  REPLACE(STRING,OLD,NEW)   REPL  REP
      Returns a string that results from replacing in a string each
      occurance of a specified search string (OLD) with a specified
      replacement string (NEW).  The replacement string can be a different
      length than the search string; if this is the case, the target
      string value is adjusted appropriately for each replacement.

      The resulting string cannot be greater than 1,024 characters.  Excess
      characters are truncated.
      EXAMPLE:  MOVE REPLACE('AABBCCBBBDD','BB','XXX') TO WK-STR.  'AAXXXCCXXXBDD'

  RIGHT(STR)   RIGHT-JUSTIFY  RIGHT-JUS
      Returns the string that results from removing blanks on the right
      side of a string, shifting the remainder of the string to the right
      side, then filling the left with as many blanks as were removed from
      the right side.
      EXAMPLE:  MOVE RIGHT('  SMITH  ') TO WRK-NAME.  '    SMITH'

  SUBSTR(STR,START,LENGTH)   SUBSTRING  SUBS
      Returns the substring of STR strarting at START column for LENGTH
      characters.
      EXAMPLE:  MOVE SUBSTR('MARK',2,3) TO WRK-STR.  'ARK'

  SLEN(STR)   STRING-LENGTH  SLEN
      Returns the length of STR.
      EXAMPLE:  MOVE SLEN('123456789') TO WK-LEN.  9

  TRANSLATE(STR,NEW,OLD)  TRANS
      Returns the string that results from translating character in a
      string.  There characters are translated to corresponding characters
      that are specified in a substitution string.
      Characters in a selection string correspond by position to characters
      in a substitution string.
      Each character in the string specified in the selection string is
      translated to the corresponding character contained in the substitution
      string.
      STR  - string on which the translate function is performed.
      NEW  - the substitution string.
      OLD  - selection string.  The following considerations apply:
             If selection string is longer than the substituion string,
             the excess characters in selection string correspond to blanks.
             If selection string is the same character more than once, the
             translate function uses the first occurance of the character.
             If selection string is not specified, the 256 character EBCDIC
             table is used, consisting of hexadecials 00 through FF.
      EXAMPLE:  MOVE TRANSLATE('B53A22B1E50D40C94',W YX','ABCD') TO WRK-CODE.
                               ' 53W22 1E50Z40Y94'

  TOLOWER(STR)
      Returns the string that results from converting all characters to
      lowercase.
      EXAMPLE:  MOVE TOLOWER(EMP-NAME) TO WRK-NAME.

  TOUPPER(STR)
      Returns string that results from converting all characters to upper case.
      EXAMPLE:  MOVE TOUPPER('mark') TO WRK-NAME.  'MARK'

  VERIFY(HAYSTACK,NEEDLE)   VER
      Returns the position of the first character in HAYSTACK that does
      not occur in NEEDLE.  If every character in HAYSTACK occurs in
      NEEDLE, a zero is returned.
      HAYSTACK - string on which the verification occurs.
      NEEDLE   - string value against whose characters are HAYSTACK's
                 characters are verified.
      EXAMPLE:  MOVE VERIFY('000500.43','0') TO WRK-POS.  4
                MOVE VERIFY('435345.234 ','1234567890 ') TO WRK-POS.  0
                MOVE VERIFY('435345.234E ','1234567890 ') TO WRK-POS. 12

  WORDCAP(STR)
      Returns the string that results when the first letter of each word
      in STR is capitalized and all other characters in STR are converted
      to lowercase.
      EXAMPLE:  MOVE WORDCAP('once upon a time') TO WRK-FLD.  'Once Upon A Time'