ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Can i compare fields character by character??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can i compare fields character by character??

    I have to compare two different fields form two different PF's. I have the requirement in which i have to break the field value into characters and compare them with the characters of the other field value (which is also broken into characters).

    The field contain only character data type.

    Is it possible to do that??

    thanks in advance!

  • #2
    Sure anythings possible

    You need to get the size of both fields.

    you can use the checkr opcode for this

    ' ' Checkr field length

    or eval len = %trim(%len(field1))

    now just move the fields into an array.

    and create a do loop:

    do len X

    eval pos2 = %scan(%subst(field1:X:1) : field2)
    if pos2 > *zeros
    then you found a char from field1 in field2
    enddo


    Sorry only have access to V4R5 system cant test this exacly but you can work it out.


    After re-reading maybe you are trying to find fields names in a physical file. If that is the case then download this and mod to make it work for you....Why write from scratch when you can borrow


    Take care,
    Jimmy

    Comment

    Working...
    X