× 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.



Mike,

The ValFldNum procedure receives a pointer to a memory location and, 
because the procedure interface says this points to a 20A field, 
interprets 20 bytes as a 20A field. OPTIONS(*VARSIZE) tells the compiler 
not to worry when you pass a field of different length, so you get away 
with passing a 5A field. What is missing is a way for the ValFldNum to 
find out the actual length of the parameter. 

Possibilities:
- Use an extra parameter to pass the length ('the API way');
- Use a VARYING parameter; then the parameter itself contains the actual 
length;
- Use operational descriptors; then the procedure can use an API to 
determine the actual length.

For performance choose the extra parameter; for a clean interface use a 
VARYING parameter in combination with CONST.

Joep Beckeringh






"Mike Pantzopoulos - (H/O)" <mpantzopoulos@xxxxxxxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
07-09-2005 06:04
Please respond to RPG programming on the AS400 / iSeries
 
        To:     <rpg400-l@xxxxxxxxxxxx>
        cc: 
        Fax to: 
        Subject:        Procedure parameters


I have an EDI aoplication which needs to validate that certain character
fields are actually numeric.

These character fields can all be different lengths and I had some
problems in using the fields directly as parameters until I realized
that the options(*varsize) can be used witht the parameter to tell the
compiler to ignore size differences on the invocation.

I now have a program which invokes a procedure to manage validation that
a character field is in fact numeric.
The prototype is:

     D ValFldNum       PI             1N
     D FldNme                          14A   CONST
     D FldVal                            20A   Options(*Varsize)

I pass in the field name so that I can generate a message indicating
which field is in error if necessary.


This procedure calls another procedure which determines if the character
field is actually a valid numeric:

     D FldIsNum        PR             1N 
     D  String                            20A   Options(*Varsize) 

A typical call from the top level is:

     C                   CALLP     ValFldNum('HDR_KSAID': HDR_KSAID)

Where HDR_KSAID is 5 bytes long.

And the ValFldNum invokes:

    C                     IF        FldIsNum(FldVal)

I expected that the field used by the FldIsNum procedure would contain
just the 5 bytes, but when I debug it, I actually get the 20 bytes
starting from the start of the HDR_KSAID field.

I'm sure I've seen a BIF which returns the actual length of the
parameter at execution time but I can't seem to remember/find it.

Am I completely lost? Or is there a simple answer?

Thanks

Mike Pantzopoulos



*********************************************************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. 
If you are not the intended recipient, any use, disclosure or copying of 
this message is unauthorised. If you have received this message in error, 
please reply using the sender's email address. 

This footnote confirms that this email message has been scanned for 
computer viruses. EIG-Ansvar Limited does not accept liability for any 
loss or damage, whether caused by our own negligence or not, that results 
from a computer virus or defect in the transmission of this email or any 
attached file. 
EIG-Ansvar Limited - Australia (A.B.N. 21 007 216 506)
Email : insure@xxxxxxxxxxxxxxxx

Eig-Ansvar Limited - New Zealand
Email : insure@xxxxxxxxxxxxxxxx

*********************************************************************************************************


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.