ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Can we know the specific position of a string in a record ??

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

  • Can we know the specific position of a string in a record ??

    Is there any way to determine that at what position the 'N-LN Num' and 'O-LN Num' starts.

    Following is the outcome of CMPPFM CMD of two PFs. I have to run this command in a loop and then process it to display in specified format. This output of CMPPFM is not fixed, it varies according to the length of the data.

    Can any one help me out
    Attached Files

  • #2
    find start position

    You may use the %Scan opcode to find the position of N-NL

    startNNL is defined as lets say 4,0

    Code:
    C                   eval      startNNL = %scan('N-NL' : Fieldnamehere)
    Start will equal the position in the string where the first "N" is located.

    Do the same for the O-LN

    Good luck
    Jimmy

    Comment


    • #3
      What's wrong here ??

      fxlnout uf a e disk rename(XLNOUT : XLNOU)
      f prefix(x)
      fxln o e disk
      dvar s 5
      .
      .
      .
      c eval var = %SCAN('NUM':xxlnout:7)
      .
      .

      Error:
      *RNF7416 30 1 The types of the right and left hand side do not match in the EVAL operation.

      What i am doing wrong here ??

      Thanks

      Comment


      • #4
        hum asrpg400 its a simple size problem

        The SCAN operation scans a string (base string) contained in factor 2 for a substring (compare string) contained in factor 1. The scan begins at a specified location contained in factor 2 and continues for the length of the compare string which is specified in factor 1. The compare string and base string must both be of the same type, either both character, both graphic, or both UCS-2.
        dvar s 5 must be a numeric value since will will get the position

        heheh
        hope it helped
        "It's like a koala pooped a rainbow on my head and I can taste the colors."

        Comment

        Working...
        X