Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How does the CONST keyword work with Procedure parameters?

0
Posted

How does the CONST keyword work with Procedure parameters?

0

If you are certain that the called procedure will NOT modify a parameter, the CONST keyword can provide several benefits. • It automatically converts a field of a similar data type, to the length and type required by the parameter. What this means, is say a parameter is a 15 position pack field, with 5 decimals. Normally, you’d have to specify a Pdk(15,5) field for the parameter. However, if the parameter is read-only, you can specify CONST on the Prototype and Procedure Interface for the parameter. When you do this, the compiler automatically converts the value (say it’s a literal of 27) to the size and type required by the parameter. This works really cool with DATE fields. A date for any format can be passed as a parameter value when that parameter value is CONST. • Performance is improved because the compiler can generate more optimized code for the CONST parameter. CONST can be used on calls to procedures or programs. We use it all the time when calling QCMDEXC from within RPG IV.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123