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



Trust me I learned this the hard way LOL  I was overwriting (luckily on
the dev box & only my own memory) & it caused several problem one of
which was losing the OPEN file indicator so the program thought the file
was closed even though the file had already been opened!!!

So did I! It tooks me 2 days finding out that a simple clear of an output parameter defined with Option(*VarSize) caused the address field in my subfile program being partly cleared and even worse a numeric field (my subfile counter) was replaced with *Blanks.

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: "Holden Tommy" <Tommy.Holden@xxxxxxxxxxxxxxxxx>
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
Sent: Friday, October 13, 2006 18:43
Subject: RE: %trim and %trimr Not Working on a 32767A Field




Thanks,
Tommy Holden


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Mike
Sent: Friday, October 13, 2006 11:36 AM
To: RPG programming on the AS400 / iSeries
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
only
refer 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
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.




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

Replies:

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.