November 20, 2022, 5:05pm
I was attempting to use an exponented equate in a DIM(). It compiled ok. But kept crashing.
!Try commenting out the OVER()
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.
November 20, 2022, 6:21pm
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.
November 20, 2022, 6:26pm
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.
November 20, 2022, 6:49pm
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:
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.
November 20, 2022, 6:53pm
The Clarion compiler has no the preprocessing phase. Actually expressions are processing on parsing the source text according to grammar rules.
November 20, 2022, 7:04pm
Thanks so much. I appreciate it.