Is there a way to do this with EVAL?
Example of one of the statements:
C MOVEL COPH1 PREFIX
C MOVE COPH1 SUFIX
C EVAL APNOT2 = '(' + ' ' + COAC1 + ')' + ' ' +
C PREFIX + '-' + SUFIX
Is there something I am doing wrong maybe?
It seems that not being able to create these kinds of combinations would
be a LARGE limitation of EVAL.
Thanks for any help!
--
Richard Knechtel
EDS
(Systems Engineer/System Administrator)
(Aspiring AS/400 GURU)
The contents of this message express only MY opinion.
This message does not necessarily reflect the policy or views of
my employer, EDS. All responsibility for the statements
made in this posting resides solely and completely with the
ME. I Ex-Spaminate spammers!
http://AS400BKS.rochester.ibm.com:80/cgi-bin/bookmgr/bookmgr.cmd/BOOKS/QBJAQE01/4.1.1.5
and
http://AS400BKS.rochester.ibm.com:80/cgi-bin/bookmgr/bookmgr.cmd/BOOKS/QBJAQE01/4.1.1.5.1
for examples, if you are on a RISC box with V3R7 or V4R1.
HTH.
--
Francis Lapeyre flap...@communique.net
____________________________________________________________
| |
| "The probability of life originating from accident is |
| comparable to the probability of the Unabridged Dictionary |
| resulting from an explosion in a printing factory." |
| |
| --Prof. Edwin Conklin |
|____________________________________________________________|
****** Unsolicited commercial e-mail is not tolerated here. *******
****** Senders of such mail do so at their own peril. *******
****** A copy, complete with header, is forwarded to the *******
****** originating ISP for action. *******
Opinions are my own. Otherwise, they are someone else's.
>I am working on a database conversion program. In the database are 40
>length character fields that hold the contents of a mixture of character
>and numeric fields from another file. I am attempting to use the EVAL
>opcode vs. using MOVE/MOVEL . But it seems EVAL won't let you handle
>compbining character and numeric strings.
>When I compile I get the following errors:
>*RNF7421 30 355 019300 Operands are not compatible with the type
>of operator.
>*RNF7416 30 358 019600 The types of the right and left hand side
>do not match in the EVAL operation.
>(I am not sure what this all means exactly)
>
>Is there a way to do this with EVAL?
>
>Example of one of the statements:
>C MOVEL COPH1 PREFIX
>C MOVE COPH1 SUFIX
>C EVAL APNOT2 = '(' + ' ' + COAC1 + ')' + ' ' +
>C PREFIX + '-' + SUFIX
>
>Is there something I am doing wrong maybe?
>It seems that not being able to create these kinds of combinations would
>be a LARGE limitation of EVAL.
>
>
>Thanks for any help!
>
>--
>
>Richard Knechtel
>EDS
>(Systems Engineer/System Administrator)
>(Aspiring AS/400 GURU)
>
> The contents of this message express only MY opinion.
> This message does not necessarily reflect the policy or views of
> my employer, EDS. All responsibility for the statements
> made in this posting resides solely and completely with the
> ME. I Ex-Spaminate spammers!
>
Not until we get a %digits function or write one yourself for RPG.
Bradley V. Stone
bvs...@usa.net
http://prairie.lakes.com/~bvstone/
1992 Yamaha FJ1200
1969 Suzuki T250
"I was on fire.... and I was dry!"
Thanks,
(I am on a CISC V3R1) :-(
I went and moved the numerics into character fields then did the EVAL.
This worked ok.
I was hoping EVAL could do this (Oh well.....)
Thanks Guys!
The Eval will not do type conversions. You still need to use move / movel.
Also, just as a note, when using Eval to do arithmatic make sure your result
field is large enough to hold the result, other wise the program will blow up
when running (it will compile find, without warning.)
Mark
In article <349FF8...@eds.com>, Richard Knechtel
> it seems EVAL won't let you handle
>compbining character and numeric strings.
In general, all the operands in a single expression should be the same
type (e.g., numeric or charater). IOW, one EVAL may compute a
mathematical equation by using multiple numeric operands but no
character operands. Another EVAL may perform string concatenation by
combining literals and character operands.
Chapter 21 of the V3R7 RPG/ILE reference manual has a section devoted
to data types. It explains what combinations of data types are
supported for each type of operation. For example, * (multiplication)
only allows numeric operands. The "+" operation can be used for
addition, concatenation, or pointer arithmetic; the operand types
determine the context to determine what "+" means.
>Is there a way to do this with EVAL?
>It seems that not being able to create these kinds of combinations would
>be a LARGE limitation of EVAL.
With concatenation, the operands must be all the same type, with the
only allowable types being character or graphic. Remember, string
concatenation is just that, concatenating *strings* not character and
numeric variables.
This is not as large a limitation as it may appear to be to you. All
you need to do is change the numeric value to a character operand.
There are a few ways of doing this, but probably the most generic is
to use either a built-in function or user-defined subprocedure which
accepts a numeric argument and returns a character result.
For example, the %editc() and %editw() functions return a character
result which could be concatenated with other strings.
>Example of one of the statements:
>C MOVEL COPH1 PREFIX
>C MOVE COPH1 SUFIX
>C EVAL APNOT2 = '(' + ' ' + COAC1 + ')' + ' ' +
>C PREFIX + '-' + SUFIX
>
>Is there something I am doing wrong maybe?
At least one of the fields in the EVAL is numeric, which as discussed
above is not allowed with string concatenation.
Your message doesn't tell us what type of fields these are. I am
guessing that COPH1 and COAC1 are numeric, and PREFIX, SUFIX, and
APNOT2 are character. If this is the case, the EVAL does not like the
COAC1 field since it is numeric.
If both COAC1 and COPH1 are numeric, you could use something like:
C EVAL APNOT2 = '(' + %editc( COAC1 : X ) + ') ' +
C %editw( COPH1 : '0 - ')
Or if both COAC1 and COPH1 are character, then your problem was PREFIX
and/or SUFIX were defined as numeric. If you changed these to
character, then all operands would be character and it would work.
But then you wouldn't need PREFIX or SUFIX either, you could just:
C EVAL APNOT2 = '(' + COAC1 + ') ' +
C %subst( COPH1: 1: 3 ) +
C '-' + %subst( COPH1: 4: 4)
HTH.
Doug:
Maybe my reply (and his reply to it) didn't hit your news server -- he
has a CISC machine, which versions of RPG IV don't have the %EDITC or
%EDITW built-in functions. On V3R7 (for sure) and above, you can use
that.
Francis
>Maybe my reply (and his reply to it) didn't hit your news server -- he
>has a CISC machine, which versions of RPG IV don't have the %EDITC or
>%EDITW built-in functions. On V3R7 (for sure) and above, you can use
>that.
Sorry ... you are right that neither your reply or his made it to my
news server. All I had was his original post. I also see so many
messages which are obviously replies to posts I never saw that it
makes me wonder how often people post messages but never see a reply
that was actually sent.
If he is CISC, he can still roll his own subprocedures under V3R2.
I Ended up adding extra code that moved the numeric fields into
character fields. (I was hoping to be able to be able to save some lines
of code, but Guess I couldn't.)(I am trying to learn how to do more wiht
less, if this makes any sense?) (I am attempting to teach myself RPG IV
so there is somewhat of a learning curve.)
I am using V3R1M0 on our AS/400. Does this version have the
%EDITC/%EDITW features in it? The manual we have for the RPGIV basically
SUCKS! (But that's IBM I guess.) I have been using Bryan Myers book "RPG
IV Jump Start" (Since I know RPG III well enough already). Is there a
more advanced RPG IV book out there that would cover more in depth RPG
IV? (I have basically gotten down the stuff covered in the afore
mentioned book)
Thanks all,
--
Richard Knechtel
EDS
(Systems Engineer/System Administrator)
(Aspiring AS/400 GURU)
The contents of this message express only MY opinion.
This message does not necessarily reflect the policy or views of
my employer, EDS. All responsibility for the statements
made in this posting resides solely and completely with the
ME.
I Ex-Spaminate spammers!
See US Code Title 47, Sec.227(a)(2)(B), Sec.227(b)(1)(C)
and Sec.227(b)(3)(C).
Richard Knechtel wrote:
>
> Francis Lapeyre wrote:
> >
> > Douglas Handy wrote:
> > >
> >
> > Doug:
> >
> > Maybe my reply (and his reply to it) didn't hit your news server -- he
> > has a CISC machine, which versions of RPG IV don't have the %EDITC or
> > %EDITW built-in functions. On V3R7 (for sure) and above, you can use
> > that.
> >
> > Francis
>
> I Ended up adding extra code that moved the numeric fields into
> character fields. (I was hoping to be able to be able to save some lines
> of code, but Guess I couldn't.)(I am trying to learn how to do more wiht
> less, if this makes any sense?) (I am attempting to teach myself RPG IV
> so there is somewhat of a learning curve.)
See Midrange Computing at http://www.midrangecomputing.com and look at
their book catalog -- I have an RPG IV book from them that's about 3
years old. I'm sure they've updated it since then.
> I am using V3R1M0 on our AS/400. Does this version have the
> %EDITC/%EDITW features in it?
Afraid not. For that, you need to upgrade to a RISC processor with at
least V3R6 (now, what you get is V4R1).
> The manual we have for the RPGIV basically
> SUCKS! (But that's IBM I guess.) I have been using Bryan Myers book "RPG
> IV Jump Start" (Since I know RPG III well enough already). Is there a
> more advanced RPG IV book out there that would cover more in depth RPG
> IV? (I have basically gotten down the stuff covered in the afore
> mentioned book)
See above..
Thanks much!