Subject: ARMRCALC23
Function: clr_bits(bits)       set_bit(index,bits)
Use this function to set a given bit-string to all zeroes.
The set_bit function stores a binary 1 in bit position addressed by the input value of index.
The input "index" need not be a data base field. It can also be a literal, intermediate variable, or an expression. The numerical value of index must be positive.
The function takes the numerical value of index to determine which bit position to set. Bit positions are numbered left to right as follows:
0 1 2 3 4 5 6 .... 0 0 0 0 0 0 0
Consider a data base with the following fields:
desc - a description field row - a row field flag - a flag field bits - a bit-string field group - a grouping field
The user will be presented with a series of ARXEDIT input screens with the view:
header= desc columns= row flag
For each page of description he will set the flag field to x denoting that the given rows are associated with the header's description value. A sample of four pages worth of user input is as follows:
desc: c1 desc: c2 desc: c3 desc: c4 -------- -------- -------- -------- row flag row flag row flag row flag --- ---- --- ---- --- ---- --- ---- r1 x r1 0 r1 x r1 0 r2 0 r2 x r2 0 r2 x r3 x r3 0 r3 0 r3 0 r4 0 r4 x r4 0 r4 x r5 x r5 0 r5 x r5 0
Although we are dealing with an N-tuplet data structure we need to look at the input in a matrix form in order to derive the final output. As the end result we desire a grouping index which collects rows of like flag value patterns. The following figure shows inherent grouping based on flag setting vis a viz row and description:
c1 c2 c3 c4 r1 x 0 x 0 group x1 same patterns as r5 r2 0 x 0 x group x2 same patterns as r4 r3 x 0 0 0 group x3 unique pattern r4 0 x 0 x group x2 r5 x 0 x 0 group x1
How does bit setting fit into that? Keep in mind that it would not be practical to set up data fields for each descriptive column in this case. On the other hand a bit vector can be introduced; the latter allows us to derive a matrix of 1's and zeros in a single field. When we are all done we will have a bit matrix which allows us to generate the group values as indicated above.
The clr_bits and set_bit function are used in the initial part of the process. An additional function (line_or) is described in the next document is required to finish the job.
For now we concentrate on the first part of the problem. The following calc program sets bits based on the table index of description:
; ;--------------------------------------------------- ; generate group as shown ;--------------------------------------------------- ; ; derive vector in bits where bit positions ; define description vector ; columns= desc calc_start= group=0 clr_bits(bits) calc_end= end= ; columns= desc prune_start= bracket_start= field= flag value= X match= flagX bracket_end= prune_end= calc_start= flagX set_bit(desc,bits) calc_end= end=
The output is stored in the bits field. Its values at this stage are as follows:
desc: c1 desc: c2 desc: c3 desc: c4 --------- --------- --------- --------- row bits row bits row bits row bits --- ----- --- ----- --- ----- --- ----- r1 01000 r1 00000 r1 00010 r1 00000 r2 00000 r2 00100 r2 00000 r2 00001 r3 01000 r3 00000 r3 00000 r3 00000 r4 00000 r4 00100 r4 00000 r4 00001 r5 01000 r5 00000 r5 00010 r5 00000
The above figure's view does not correspond to the processing view shown in the calc. The calc view is far simpler. Given that all bits are first set to zero via clr_bits(bits), we select the subset with flag=x and a columnar view of desc does the following:
desc bits for flag=x ---- ----- c1 set_bit 1 01000 clones are r1 r3 r5 c2 set_bit 2 00100 clones are r2 r4 c3 set_bit 3 00010 clones are r1 r5 c4 set_bit 4 00001 clones are r2 r4
The conclusion of the current example is described in the line_or documentation!