|
Thanks a lot to all. Some of that I'd assumed and some not really clicked on. Some I didn't get at all. Now it's much more clear. With your and Bob's help I can picture a lot better the relationship of the parms and how the system is interpreting what I do. I've learned a lot the past couple days. Now to re-code and improve! JPW The bitterness of poor quality remains long after low pricing is forgotten! Cautillo, Leon M. -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement Sent: Wednesday, 1 March 2006 10:11 To: RPG programming on the AS400 / iSeries Subject: RE: QWCCVTDT Weirdness, solved! > I understand how you use alloc to get more space assigned to the > variable than the d-spec definition would normally allow. Since I prefer > the user space method, how would I set that up? The only difference between the user space and alloc method is the way you allocate the space. Instead of calling %alloc() to get the space, you call QUSCRTUS and QUSPTRUS (and maybe QUSCUSAT, if you want it to auto-extend) > Let's say my user space pointer is USP_Ptr. > I'll need to define a variable based on that. > So, > > D MyVar ??????A Based(USP_Ptr). > > How big do I make the variable. I kept thinking that if I make it the > largest I could define on the D-spec (32767) that's all the API would > return for me. The API doesn't know how big your variable is. It doesn't have any way to read your source code and check that. All it knows is a) The spot in memory where it's stored (since that's what gets passed when you pass a parameter) b) The length that you pass in the "length of receiver variable". > Or - is the 'length of receiver variable' (staying with the QMHRDQM API > example) the key? Will the API use however much space I tell it to in > that variable, regardless of the definition of MyVar. Correct, it'll use as much space as you the "length of receiver variable". (Unless of course, it needs less space than that... but it'll never use more) Example. > > D MyVar 1A Based(USP_Ptr). > D MyVarLen 10I 0 Inz(1048544) *-or whatever > size I want-* > > Then when the API is called, it will start putting data into MyVar but > continue as far as the MyVarLen lets it go? If this is the case, I can > run with that. That's correct. (Assuming that you actually pass these as parameters to the API, rather than just declaring them on the D-spec) > I think that's a little obscure myself, but I'll agree that it's a > little more clear than my weird pointer structure I'd forced to work > before. You have to accept the notion that the ONLY thing that gets passed when you pass a parameter is the memory address. (And this isn't an attribute of APIs -- it's just how parameters work on the iSeries. It's the same notion that's used when you pass parameters from program or program or from the command line to a program.) As long as you've accepted that fact, then it makes perfect sense why passing a parameter and a separate length for that parameter, will allow the API to deal with any size field.
As an Amazon Associate we earn from qualifying purchases.
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.