× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



David

When you use CONST or VALUE, you are allowed to pass an expression in the parameter, a variable is not required. I have a feeling that any expression includes a single variable. Therefore, you are not going to be protected the same way as if you had not used CONST. In THAT case, using a 9,0 variable would probably have caused a compile error.

If you use CONST and the variable that comprises the "expression" is 9,0 packed, then it is possible that its value is greater than that of a 9,2 packed parameter - that makes it a runtime error - you would probably want some error handler around that call to take care of it. But what you really need to do is be sure not to pass a value greater than 9999999.99 - ever!!

HTH
Vern

David FOXWELL wrote:
David FOXWELL
Service Informatique
Tél : 03 90 23 91 63
david.foxwell@xxxxxxxxx
-----Message d'origine-----
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Dennis Lovelady

both CONST and VALUE will cause a conversion from your input data type to your procedure's required data type. In this case, you have a field that can hold a value of plus/minus 999 million and change. Your procedure has a limit of plus/minus
9 million and change. Your usage of CONST made the compiler accept the difference, providing a temporary (same size as specified in the proto) that would be passed to the procedure.

Fascinating. So, I'm guessing that the program crashed when it was copying the value of the 9,0 field to the temporary 9,2 field, which is why I could not step into the procedure. I wonder if I'd been able to detect that event while displaying the job.
If you want to be "protected" from such mistakes, remove the CONST (and don't be tempted to replace it with VALUE). But then you will lose a different kind of protection.

Well, now I'm wondering about the value of using CONST at all. I don't see that that's much protection against anything unless you don't test. It seems we only really need it to indicate which parameters are intended to be used as input only. The kind of problem I've had without using CONST could be waiting to happen in many other procedures.

Thanks.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.