IB enhancements for Comet32

From CometWiki

(Difference between revisions)
Jump to: navigation, search
Badge (Talk | contribs)
(New page: == SearchFile == '''Syntax:''' SearchFile (lun, format-statement-label) SearchString$ FieldSize FieldPosition Occurrences Flags [EXCP=statement-label] <p> '''Discussion:''' The SearchFi...)
Newer edit →

Revision as of 18:22, 19 May 2009

SearchFile

Syntax: SearchFile (lun, format-statement-label) SearchString$ FieldSize FieldPosition Occurrences Flags [EXCP=statement-label]

Discussion: The SearchFile statement searches the file open on the specified LUN for the search string. If the match is found, the record is returned to the variables in the format.

  • Example
  • CustRec: FORMAT CUSTNUM$;NAME$;ADDRESS$;CITY$;STATE$;ZIP$
  • .
  • .
  • OPEN (2) "CUSTFILE"
  • .

    .

    INPUT NAME$

    .

    SearchFile (2,CustRec) NAME$ NameLen NamePos 1 Flags

  • There are several options which make SearchFile very flexible. Possible Flag values are combinations of:

    1 - Search Next

    2 - Case-sensitive search

    4 - Field begins with search string

  • If you include 1 in your Flag value, the Search will begin from the position the previous search ended. If not set or if no previous search has been done since opening the file, the search starts at the beginning of the file.
  • If you include 2 in your Flag value the search will be case-sensitive. It is not by default.
  • If you include 4 in your Flag value, the search string will only be looked for beginning at the FieldPosition you choose. Without this flag value the search string may be found at any place beginning at the FieldPosition for the number of bytes specified by FieldSize.
  • FieldSize and FieldPosition may both be set to 0. In this case the entire record will be searched for the string rather than only one field in the record.
  • The Occurrences parameter specifies the number of occurrences of the search string it will attempt to find before returning.
  • Possible error values returned are:

    E02 - End of file was reached before the number of occurrences were found

    E45 - An invalid parameter was specified

    E99 - Memory allocation failed

  • Note: While SearchFile may be used on a text file if it contains a hex 0 character it will cause the search to stop at that character in the file.
  • This statement was introduced with Comet32.
  • Personal tools