No exponents in dim

I was attempting to use an exponented equate in a DIM(). It compiled ok. But kept crashing.


DimQty EQUATE(5)
E1     EQUATE(DimQty*DimQty*DimQty)

B1     BYTE,DIM(E1)

!Try commenting out the OVER()
B2     BYTE,DIM(DimQty^3),OVER(B1)

  MESSAGE('DimQty=' & DimQty & '|E1=' & E1 & '|SIZE(B1)=' & SIZE(B1) & '|SIZE(B2)=' & SIZE(B2))

If you comment out the “OVER(B1)” portion of the B2 declaration, then the compile will fail (which is good).

But WITH the OVER(), it will give you random values for the SIZE(), and it clearly doesn’t work correctly.

By documentation, the parameter of DIM must be a positive numeric constant. DimQty^3 is a constant expression rather than a constant. It would be correct to report an error as in the case of no OVER. The compiler does not allow not-local variables with not-constant size - it reports the error

Variable-size must be constant

in this case on attempt of allocation that variable. Because variables with the OVER attribute are not allocating, not-constant parameter of DIM as in your example remains not detected and reported.

1 Like

Thanks a lot.

So then is DimQty*DimQty*DimQty considered to be a positive numeric constant?

If not, why does that “work”?

Thanks again for your explanation.

I think DimQty x DimQty x DimQty is calculated during preprocess phase so it is a constant actually.

The compiler computes constant numeric expressions if all parameters are either Integer or Real numbers (or EQUATEs of these types) and if they contain only following operators:

  • Addition +
  • Subtraction -
  • Multiplication *
  • Division /
  • Modulus %

The Modulus operator with Real type parameters also does not allow calculate the expression at compile time. If the compiler can compute the constant expression, it uses its result.


The Clarion compiler has no the preprocessing phase. Actually expressions are processing on parsing the source text according to grammar rules.

1 Like

Thanks so much. I appreciate it.