IB enhancements for Comet32

From CometWiki

(Difference between revisions)
Jump to: navigation, search
(New page: == SearchFile == '''Syntax:''' SearchFile (lun, format-statement-label) SearchString$ FieldSize FieldPosition Occurrences Flags [EXCP=statement-label] <p> '''Discussion:''' The SearchFi...)
Line 1: Line 1:
== SearchFile ==
== SearchFile ==
-
'''Syntax:'''  SearchFile (lun, format-statement-label) SearchString$ FieldSize FieldPosition Occurrences Flags [EXCP=statement-label] <p>
+
'''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.
'''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.
-
<li>
+
 
Example
Example
-
<li>
+
 
-
CustRec: FORMAT CUSTNUM$;NAME$;ADDRESS$;CITY$;STATE$;ZIP$<li>
+
:CustRec: FORMAT CUSTNUM$;NAME$;ADDRESS$;CITY$;STATE$;ZIP$<br>
-
.<li>
+
:.<br>
-
.<li>
+
:.<br>
-
OPEN (2) "CUSTFILE"<li>
+
:OPEN (2) "CUSTFILE"<br>
-
.<p>
+
:.<br>
-
.<p>
+
:.<br>
-
INPUT NAME$<p>
+
:INPUT NAME$<br>
-
.<p>
+
:.<br>
-
SearchFile (2,CustRec) NAME$ NameLen NamePos 1 Flags<p>
+
:SearchFile (2,CustRec) NAME$ NameLen NamePos 1 Flags
-
<li>
+
 
-
There are several options which make SearchFile very flexible. Possible Flag values are combinations of:<p>
+
There are several options which make SearchFile very flexible. Possible Flag values are combinations of:<br>
-
1 - Search Next<p>
+
1 - Search Next<br>
-
2 - Case-sensitive search<p>
+
2 - Case-sensitive search<br>
-
4 - Field begins with search string<p>
+
4 - Field begins with search string
-
<li>
+
 
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 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.  
-
<li>
+
 
If you include 2 in your Flag value the search will be case-sensitive. It is not by default.  
If you include 2 in your Flag value the search will be case-sensitive. It is not by default.  
-
<li>
+
 
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.  
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.  
-
<li>
+
 
 +
 
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.  
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.  
-
<li>
+
 
 +
 
The Occurrences parameter specifies the number of occurrences of the search string it will attempt to find before returning.  
The Occurrences parameter specifies the number of occurrences of the search string it will attempt to find before returning.  
-
<li>
+
 
-
Possible error values returned are:<p>
+
 
-
E02 - End of file was reached before the number of occurrences were found<p>
+
Possible error values returned are:<br>
-
E45 - An invalid parameter was specified<p>
+
E02 - End of file was reached before the number of occurrences were found<br>
-
E99 - Memory allocation failed<p>
+
E45 - An invalid parameter was specified<br>
-
<li>
+
E99 - Memory allocation failed<br>
 +
 
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.  
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.  
-
<li>
+
<br>
This statement was introduced with Comet32.
This statement was introduced with Comet32.

Revision as of 21:33, 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