Skip to main content
Question

Unexpected Behavior in DESCRINFO Function with Dimensioned Arrays

  • December 2, 2025
  • 0 replies
  • 19 views

rjo-au

Hello all!

I’m adding variable data type protection to a subroutine label in a program I’m working on. However, I’m experiencing unexpected behavior when using the `DESCRINFO` function.

Here is an example:

* Set up some stuff here...

IF RUN.MODE = "AUDIT" THEN
EQUATE NUM.REPORTS TO 10

DIM REPORT.COUNTS(NUM.REPORTS)
MAT REPORT.COUNTS = 0
GOSUB PREPARE.UTILITY.REPORTS
END

LOOP
* Do stuff here...
UNTIL IS.DONE
* Do other stuff here, maybe write to a report...
REPEAT

IF RUN.MODE = "AUDIT" THEN
GOSUB CLOSE.UTILITY.REPORTS
END

* Other code here...

STOP

PREPARE.UTILITY.REPORTS:
* Prepare reports, calling SETPTR and HEADING/FOOTING...

RETURN; * Internal

CLOSE.UTILITY.REPORTS:
* HERE LIES MY ISSUE; THIS RETURNS 1 (INTEGER) BECAUSE OF THE 'MAT' ABOVE
IF DESCRINFO(1, REPORT.COUNTS) # 5 THEN
RETURN
END

* Close reports, print 'no data found' message if count = 0...

RETURN; * Internal

* Some other subroutines here...

END; *Program

Here is another example, simplified:

DIM ARR.1(10)
DISPLAY DESCRINFO(1, ARR.1); * Will print 5 (for array)

DIM ARR.2(10)
MAT ARR.2 = ""
DISPLAY DESCRINFO(1, ARR.2); * Will print 3 (String)

DIM ARR.3(10)
MAT ARR.3 = 0
DISPLAY DESCRINFO(1, ARR.3); * Will print 1 (Integer)

DIM ARR.4(10)
* Ignoring setting the first index to allow DESCRINFO to return
* 5
FOR I = 2 TO 10
ARR.4(I) = I
NEXT I
DISPLAY DESCRINFO(1, ARR.4); * Will print 5 (array)

DIM ARR.5(10)
FOR I = 1 TO 10
ARR.5(I) = "A"
NEXT I
DISPLAY DESCRINFO(1, ARR.5); * Will print 1 (Integer)

END; * Program

If the array has any value assigned to the first element/index (1), then the return value of DESCRINFO will be whatever data type that value is. If nothing is assigned to the first index, then it will return the proper integer for an array (5). Why does this happen?

Has anyone else experienced this issue? Besides the obvious fix of removing extensive data type checks, what other alternatives have you tried, and what was the result?

Thank you in advance!