Skip to main content

This article explains how to find where in the application an error may be occurring.

Problem:

When running an application the error 153 Subscript out of range is received. Is it possible to find out where in the program is the error occurring?

Resolution:

A subscript which you have used in your program is out of the defined range, that is, it is either less than one or it is greater than the number of occurrences of the item. The resolution is to recode the program, although it is difficult to isolate where the error is occurring. Look at the example program below:

subscript.cbl


  • working-storage section.
  • 01 ws-1 pic x(5) occurs 20.
  • 01 ws-2pic 99.
  • procedure division.
  • move 21 to ws-2.
  • move "hello" to ws-1(ws-2).
  • stop run.

Notice that ws-1 occurs 20 times, but the program is trying to move "hello" to the 21st occurrance, hence the 153 error.

The easiest way to find the error is to compile the program for animation cob -zvg subscript.cbl. Then, when you run it and the error occurs you will be given the line number the error occurred on, for example:

Object Code error : file 'a'

error code: 153, pc=0, call=1, seg=0

153 Subscript out of range (in subscript.cbl, line 6)

Old KB# 13977