s (Subindex) Processing Code

The s (Subindex) processing code is used to update an index that uses a file translation if the value in the translate file changes. This processing code is set from Attribute 8 of the File Definition Item for the data section of a translate file.

System Processors

N/A

Code Type

File Defining

Dictionary Attributes

Correlative

Syntax

s<File1>;<AMC>;a<n>(t<File2>;<c>;;<AMC>)

Parameter(s)

<File1>

A file having the index:

a<n>(t<File1>;<c>;;<AMC>)

<AMC>

The attribute in the translate item containing the translated data.

<n>

The primary attribute number for the index.

<File2>

The translate file.

<c>

Translate subcode.

Example(s)

CREATE-FILE MYMAIN 1 1

CREATE-FILE MYTRANS 1 1

CREATE-INDEX MYMAIN A1(TMYTRANS;X;;1)

Put the subindex processing code on attribute 8 of DICT MYTRANS MYTRANS.

sMYMAIN;1;A1(TMYTRANS;X;;1)

To see it used, create two items in the MYTRANS file:

   1

001 same

   2

001 diff

... then create several items in the MYMAIN file:

   a

001 1

   b

001 2

   c

001 1

   d

001 2

... then create the following program and compile it:

    bp subidx

001 root "mymain", "A1(TMYTRANS;X;;1)" to rX else stop

002 sKey=''

003 sId=''

004 loop

005   key('n',rX,sKey,sId) else stop

006   print sId

007 repeat

Traversing the index at this point, using the above program, the item-id order should be "b,d,a,c" since "diff" sorts before "same". Here is the output of the program at this point:

:run bp subidx

b

d

a

c

Change item 2 in MYTRANS from "diff" to "update", and the change should be reflected in the index.

:ed mytrans 2

top

.

001 diff

eoi 001

.r

001 update

eoi 001

.fi

[221] '2' filed.

Now, traversing the index from the start should return the item-ids in the order, "a,c,b,d", since "same" sorts before "update". Here is the output of the program now:

:run bp subidx

a

c

b

d

:

See Also

Processing Codes