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



Hello,

Bill Wragg wrote:
Setll (VMAPVN) Zaptr; Reade (VMAPVN) Zaptr;
(Vmapvn) is a field NOT a key list. Am on V5R3.


Coding the parenthesis is equivalent to coding the KLIST op-code. It doesn't mean that VMAVPN is a keylist, it means that an unnamed/hidden keylist is build, under the covers, and it contains VMAPVN as a key field.

All of the free format opcodes work exactly the same way they did in RPG III, the syntax is just different. For example, the CHAIN op-code could always accept either an RRN, a field, or a keylist (including a keylist with only one KFLD) in it's factor1. The only difference in free format is that the factor1 comes after the op-code, and you can use parenthesis to create a temporary keylist on-the-fly.

For example, chaining with an RRN in fixed format (and RPG III) worked like this:

FMYFILE IF E DISK

C RRN CHAIN MYFILE


To do the same thing in free format, simply move the RRN after the op-code:
chain RRN MYFILE;


You could also chain by a field if the file is keyed.

FMYFILE IF E K DISK

C FIELD CHAIN MYFILE


You do the same thing in free format, just put the factor1 after the op-code:

chain FIELD MYFILE;

Free format offers the ability to declare keylists on the fly, and this is a really simple and easy to use feature -- you just have to get it into your head that PARENTHESIS=KLIST. Don't add parenthesis in a situation where you wouldn't have used a keylist.

So traditional RPG had this:

FMYFILE IF E K DISK

C KEYLIST KLIST
C KFLD KEY1
C KFLD KEY2

C KEYLIST CHAIN MYFILE

And in free format, we can skip creating the KEYLIST field (it's only useful for the CHAIN anyway) and have the system create a keylist on the fly:

chain (KEY1:KEY2) MYFILE;

The one that seems to really confuse people is when you have only one field in a KLIST. It's not any different from the previous example, other than that there's only one field. PArenthesis is still equivalent to KLIST:

FMYFILE IF E K DISK

C KEYLIST KLIST
C KFLD KEY1

C KEYLIST CHAIN MYFILE


And in free format:

chain (KEY1) MYFILE;


For some reason, this single key in a keylist thing seems to absolutely baffle RPG programmers. They just can't seem to wrap their heads around the idea that the parenthesis actually means KLIST.

When you access a file by RRN, you'd never, ever try to do the following, would you?

FMYFILE IF E DISK

C KEYLIST KLIST
C KFLD RRN

C KEYLIST CHAIN MYFILE

That wouldn't work for RRN access, would it? You can't use a keylist for an RRN -- everyone knows that. Nobody would even try to do the above code.

That being the case, then why would you try the following code which is the free format equivalent?

chain (RRN) MYFILE;

Because I put parenthesis, I've told it that I want a keylist (with only one field in it.) If we know that the fixed format code with the KLIST op-code won't work, *why* would we assume that the one with the parenthesis *will* work? The only reason I can come up with is that people don't really understand that parenthesis=klist. If you remember that, it's actually very easy to understand.

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.