|
The ellipses in the printf prototype is just a mechanic to allow any number of parameters. It would be possible to emulate the same thing in RPG with creative pointer and string control. What C does with the printf and parameters is handled by the subroutine itself, not the compiler. As someone mentioned there is a lot of work that has to be done in the procedure to pull the parameters off the stack. If you think about how you could pass pointers to an RPG function (think of passing them as strings) you should realize that you could do the same thing calling the printf function! It's a bit of a kludge, but say I wanted to call something like: printf("The string is %s and the number is %i\n", SomeString, SomeNumber); C really doesn't care what parameters you pass it. In this case we are passing 2 pointers and a integer value (not positive if %i is correct for integer, but you get the point). The first pointer is to the constant we declared, which still gets passed as a pointer, the second is to the variable SomeString. The third is the binary SomeNumber. What if you just build this all in one string? I don't want to work out all the mechanics right here but may later, but something like C Eval PassString = StrPoint%("The string is %s and the number is %i\n") + C StrPoint%(SomeString) + StrInt(SomeNumber) C CallP PrintF(PassString) In theory StrPoint would return the pointer address to the string as a string, and StrInt would return the binary value of the integer as a string. Very easy if you think about it. D DS D StrPointer P 1 4 D ReturnStr A 1 4 I'm not saying it's easy, nor desirable, just possible. RPG allows us to do the same fudging of pointers and variable types as C does, through data structures and pointers. Regards, Jim Langston +--- | 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 mailing list archive is Copyright 1997-2025 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.