What is this really doing???

I've inherited some 10+ year old code without benefit of the original programmer... can anyone explain the usefulness of this code segment, or at least reduce to something more sensible?

                                                       Display Module Source                                                        
                                                                                                                                   
C  N31USERN         CABNE     *ALL' '                            3131--                                  

Thanks in advance ;)
aelessedilAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
I don't know RPG but from a quick google, looks like compare and branch:
https://www.ibm.com/support/knowledgecenter/SSPSQF_9.0.0/com.ibm.etools.iseries.langref.doc/evferlsh266.htm
David Johnson, CD, MVPOwnerCommented:
The code is probably 20-40 years old. RPG is very column sensitive.. The last time I worked in RPG II was in 1980.
C (we will be doing a compare
N31USERN      Operand 1 variable
CABNE  - compare and branch if not equal
*ALL' '      compared to this is a literal not a variable
3131--        Tag or variable                            


http://www.go4as400.com/rpgle-opcodes/as400.aspx?cid=205
tliottaCommented:
First, it uses the indicator (boolean) labelled 31 (or IN31). The indicator can either be set to *ON or set to *OFF. If set to *OFF, it may be referenced as "N31". The "conditioning indicator" at the left says that this statement will execute if indicator 31 is *OFF.

The op-code is CABNE -- Compare and Branch if Not-Equal. Because no branch target is present, the only actual result will be setting IN31 to *ON or *OFF. The compare is done against the variable USERN and a value of all blanks.

Finally, the three possible results of a compare are greater-than, less-than and equal. On the right, IN31 is specified twice, once for greater-than and once for less-than. The equal state causes no change.

Pseudo-code might be like:
if IN31 = *OFF;
   if USERN <> ' ';
      IN31 = *ON;
   end-if;
end-if;

Open in new window

I'm not sure why, but I've seen the CABNE op-code three times in the past week in various forums. It's been practically obsolete for more than a couple decades. If you go back in time much more than that, it was a way to say a lot in a very compact way and had a few advantages.

As systems became more powerful, it was just another op-code that outlived it's usefulness.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aelessedilAuthor Commented:
Thanks everyone! It seems I purged all this knowledge during Y2K, and frankly never used left-side indicators in conjunction with a factor variable.

I've a long uphill battle to update these programs to /Free... without the /Free of course ;)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
RPG

From novice to tech pro — start learning today.