DFPART()

DFPART()

Top  Previous  Next

 

The DFPART() function returns a file variable that references an individual part of a distributed file.

 

 

Format

 

DFPART(dist.file, part)

 

where

 

dist.fileis the file variable referencing a distributed file.

 

partis the part number of the part to be accessed.

 

 

The DFPART() function allows a QMBasic program to refer to a specific part within a distributed file. It is of use, for example, with FILEINFO() to obtain details of a specific part or when constructing programs that need to merge index entries from multiple part files.

 

A list of part numbers can be obtained using the FILEINFO() function with key FL$PARTS. These part numbers can then be used with DFPART() to access the individual part files. If the part argument does not reference a valid part number, the program will abort with a run time error.

 

 

Examples

 

OPEN 'ORDERS' TO ORD.F ELSE STOP 'Cannot open file'

PARTS = FILEINFO(ORD.F, FL$PARTS)

FOR EACH PT IN PARTS

  DISPLAY 'Part ' : PT : ' modulus ' : FILEINFO(DFPART(ORD.F,PT), FL$MODULUS)

NEXT PT

 

The above program reports the modulo values for each part file in the ORDERS distributed file.

 

 

OPEN 'ORDERS' TO ORD.F ELSE STOP 'Cannot open file'

PARTS = FILEINFO(ORD.F, FL$PARTS)

LIST = ''

FOR EACH PT IN PARTS

  AK.F = DFPART(ORD.F,PT)

  SETLEFT 'VALUE' FROM AK.F

  LOOP

     SELECTRIGHT 'VALUE' FROM AK.F SETTING AK.KEY TO 1

  UNTIL STATUS()

  UNTIL AK.KEY > 100

     READLIST S FROM 1 THEN LIST<-1> = S

  REPEAT

NEXT PT

 

The index scanning operations are not available for distributed files because the indices are separate for each part file. The above program effectively merges index data from each part file within the ORDERS distributed file. In this example, LIST is created as a list ids for records where the VALUE item is less than 100.