Dave,
First off, good luck with the job hunt.
The only time I use procedure pointers is for call-back processing. Using it in place of a Select, as you say, seems like it would only add code and provide no benefit.
Added code being that instead of:
Select;
When x = 1;
sortByCust();
When x =2 ;
sortByOrder();
EndSl;
You'd have:
Select;
When x = 1;
p_Sort = PADDR_SORT_BY_CUST;
sort();
When x =2 ;
p_Sort = PADDR_SORT_BY_ORDER;
sort();
EndSl;
I suppose they might have a program that can run in 3 (arbitrary number) "modes." At the beginning of the program they could point the procedures they'll be using at the ones appropriate for the mode. Then within the code all the varied procedures would share a common name. I don't know how likely it is to actually write a program like this, but maybe that's what they're doing.
-Kurt Anderson
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Dave
Sent: Monday, January 21, 2013 1:40 PM
To: RPG programming on the IBM i / System i
Subject: Unbound procedure call
Hi all,
I was asked in an interview how I would go about coding a call to a procedure so that no binding to that procedure would occur at compilation.
I said I would need to have the addresses of the callable procedures and I would have a generic prototype based on a pointer that called the procedure indicated by its address. Depending upon what the program needed to do I would initialise that pointer so the right procedure would be called.
This was a test to get an idea of my RPG skills, but I discovered that this was a technique favoured by the shop. I did not dare ask why would they want to use this technique, so I'm asking : why would you really want to do it this way? Why not just use a SELECT statement?
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.