|
Hi Mike,if you use the keyword Options(*VarSize) independend wether you add CONST or not, you should add the keyword OPDESC in the PR-line to allow passing operational descriptors. With passed operational descriptors and calling the API CEEDOD, it is possible to determine the length of the passed parameters. With this information you can substring the passed values from the parameter fields and trim the results.
As you see, it's rather complicated. Defining the parameter fields with the keyword varying is much easier, i.e. you do not have to check anything. Because you added the keyword CONST, a temporary field with varying length is created to hold the parameter values as soon as you pass a parameter with fixed length. Adding the keyword Operations(*Trim) will also help to remove passed leading or trailing blanks from your fixed length parameter fields.
Mit freunlichen Grüßen / Best regards Birgitta Hauser"Shoot for the moon, even if you miss, you'll land among the stars." (Les Brown)
"If you think education is expensive, try ignorance." (Derek Bok)----- Original Message ----- From: "Mike" <koldark@xxxxxxxxx>
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx> Sent: Friday, October 13, 2006 18:35 Subject: Re: %trim and %trimr Not Working on a 32767A Field
So Scott... are you saying to use varying then? On 10/13/06, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote:WARNING you are using *VARSIZE in an unsafe manner. You are risking accessing other areas of memory that you shouldn't be. That can potentially crash your program, but most of the time you'll just end up with extra garbage in the parameters. *VARSIZE is a dangerous option, make sure you understand how it works before using it! This would be much worse if you were changing the variables.Whenever you use *VARSIZE you must also pass the LENGTH of the variable as a separate option, or get the length from an operational descriptor. Then you have to write your code in a special manner that ensures that you onlyrefer to the length passed in. When you use *VARSIZE, the procedure doesn't know how long the data actually is. It thinks it's always the maximum size (the size defined on the D-spec) and when you pass something shorter, it tries to just "keep reading" and goes beyond the end of the variable into other areas of memory. -- Scott Klement http://www.scottklement.com On Fri, 13 Oct 2006, Mike wrote: > Just as the subject says. I am wring a subproceedure that can take in any > length of field. I am trying to trim down the field to the proper size, but > it isn't. Here is the code: > > P SendBatchEmail B EXPORT > D SendBatchEmail PI > D fromAddress 100A CONST > D OPTIONS(*VARSIZE) > D toAddress 32767A CONST > D OPTIONS(*VARSIZE) > D ccAddress 32767A CONST > D OPTIONS(*VARSIZE) > D bccAddress 32767A CONST > D OPTIONS(*VARSIZE) > D subject 32767A CONST > D OPTIONS(*VARSIZE) > D body 32767A CONST > D OPTIONS(*VARSIZE) > > /free > > cmd = 'SBMJOB CMD(CALL PGM(BATCHEMAIL) ' + > 'PARM(''' + %trim(fromAddress) + ''' ''' + > %trim(toAddress) + ''' ''' + > %trim(ccAddress) + ''' ''' + > %trim(bccAddress) + ''' ''' + > %trim(subject) + ''' ''' + > %trim(body) + ''') JOB(SNDEMAIL)'; > > ExecClCmd(cmd); > > /end-free > P SendBatchEmail E > > After the assignment to cmd, it contains "SBMJOB CMD(CALL PGM(BATCHEMAIL) > PARM('me@xxxxxxxxxxxxxxxxxx' 'me@xxxxxxxxxxxxxxxxxx> ..." A ton of spaces and no ending quote mark. Any ideas? I am sure I > am> doing something stupid, I just can't see it. > > -- > Mike Wills > Blog - http://mikewills.name > Podcasts - http://theriverbendpodcast.com > -- > This is the RPG programming on the AS400 / 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. > --This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing listTo 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.-- Mike Wills Blog - http://mikewills.name Podcasts - http://theriverbendpodcast.com -- This is the RPG programming on the AS400 / 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.
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.