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


  • Subject: Re: Prototyping printf()
  • From: "Simon Coulter" <shc@xxxxxxxxxxxxxxxxx>
  • Date: Tue, 26 Sep 00 11:30:56 +1000

Œ
Hello Jon,

You wrote:
>I wonder if the lack of operational descriptors for most data types isn't
>somewhat connected - C knows what to expect because of the format string,
>but your own code (without adding similar support) needs descriptors to do
>it properly.  Even then you still need to tell the compiler how many bytes
>(and into what format) to pull off the stack.  You'd need some new op-code
>I suspect.

Full operational descriptor support would allow me to write a wrapper for 
printf() like 
functions but I'd still be stuck with prototyping variations on the interface.

I don't think C, per se, uses the format string.  printf() is not part of C, 
it's part of 
the standard library, therefore I doubt the compiler does anything special when 
it 
encounters a printf() statement.  It just does its normal thing -- oh this is a 
pointer? 
OK, pass its value (i.e., the address contained IN the pointer, not the address 
OF the 
pointer) -- ah, here is an int, OK, pass its value, and so on.  Even though the 
prototype 
doesn't describe the attributes of parameters defined by ellipses the compiler 
can 
determine the type of the argument actually being passed on the function call 
since it 
was declared somewhere in the code and build an appropriate argument list.

What we need is some way to specify a parameter of unknown type in an RPG 
prototype that 
supports the VALUE, CONST, etc keywords.  Then we could do:

        D printf        PR              10I 0
        D   format                        *     VALUE OPTIONS(*STRING)
        D   arg1                          ?     VALUE
        D   arg2                          ?     VALUE

or perhaps

        D printf        PR              10I 0
        D   format                        *     VALUE OPTIONS(*STRING)
        D                                 ?     VALUE OPTIONS(*VARG:*STRING)    

which says that any number of parameters (within system limits) can appear 
after the 
format parameter and they can be of any supported data type.  If the data type 
is 
character then a null will be appended but not for numeric data types.  It 
probably needs 
a bit more thought than my 1-minute effort but would be useful and I doubt it 
would be 
all that difficult.  I gets messy if you try to support varying argument lists 
where some 
values are passed by value and others by reference but I'd accept a limitation 
of one or 
the other.

Regards,
Simon Coulter.

«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»
«» FlyByNight Software         AS/400 Technical Specialists       «»
«» Eclipse the competition - run your business on an IBM AS/400.  «»
«»                                                                «»
«» Phone: +61 3 9419 0175      Mobile: +61 0411 091 400           «»
«» Fax:   +61 3 9419 0175      mailto: shc@flybynight.com.au      «»
«»                                                                «»
«» Windoze should not be open at Warp speed.                      «»
«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.