User Tools

Site Tools


skip_bypass_records_in_sequence_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== SKIP (bypass records in sequence) ====== Previous pageReturn to chapter overviewNext page

SKIP( entity, count )

blk2blue.jpg

SKIP Bypasses records during sequential processing.
entity The label of a FILE or VIEW declaration.
count A numeric constant or variable. The count specifies the number of records to bypass. If the value is positive, records are skipped in forward (NEXT) sequence; if count is negative, records are skipped in reverse (PREVIOUS) sequence.

The SKIP statement is used to bypass records during sequential processing. It bypasses records, in the sequence specified by the SET statement, by moving the file pointer count records. SKIP is more efficient than NEXT or PREVIOUS for skipping past records because it does not move records into the RECORD structure data buffer. If SKIP reads past the end or beginning of file, the EOF( ) and BOF( ) procedures return true. If no SET has been issued, SKIP posts error 33 (Record Not Available).

Errors Posted:

33 Record Not Available
37 File Not Open

Example:

ViewOrder  VIEW(Customer)                        !Declare VIEW structure

           PROJECT(Cus:AcctNumber,Cus:Name)

           JOIN(Hea:AcctKey,Cus:AcctNumber)     !Join Header file

            PROJECT(Hea:OrderNumber)

            JOIN(Dtl:OrderKey,Hea:OrderNumber)  !Join Detail file

             PROJECT(Det:Item,Det:Quantity)

             JOIN(Pro:ItemKey,Dtl:Item)         !Join Product file

              PROJECT(Pro:Description,Pro:Price)

             END

            END

           END

          END

SavOrderNo LONG

CODE

OPEN(Customer,22h)

OPEN((Header,22h)

OPEN(Detail,22h)

OPEN(Product,22h)

SET(Cus:AcctKey)

OPEN(ViewOrder)                                 !Top of file in keyed sequence

LOOP                                            !Process all records

 NEXT(ViewOrder)                                !Get a record

 IF ERRORCODE() THEN BREAK END

 IF Hea:OrderNumber <;> SavOrderNo               !Check for first item in order

  IF Hea:OrderStatus = 'Cancel'                 !Is it a canceled order?

  SKIP(Items,Vew:ItemCount-1)                  !SKIP rest of the items

   CYCLE                                        !and process next order

  END                                           !end ifs

 END                                            !end ifs

 DO ItemProcess                                 !process the item

 SavInvNo = Hea:OrderNUmber                     !save the invoice number

END                                             !End loop

See Also:

SET

RESET

NEXT

PREVIOUS

skip_bypass_records_in_sequence_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1