IB enhancements for Comet32

From CometWiki

(Difference between revisions)
Jump to: navigation, search
 
(13 intermediate revisions not shown)
Line 1: Line 1:
-
== SearchFile ==
+
[[IB_Statements/SearchFile|'''Search File - C32''']]
-
'''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.
+
[[IB_Statements/InputFile_and_PrintFile|'''InputFile and PrintFile - C32''']]
-
Example
+
[[IB_Statements/GetFormat|'''GetFormat and SetFormat - C32''']]
-
:CustRec: FORMAT CUSTNUM$;NAME$;ADDRESS$;CITY$;STATE$;ZIP$<br>
+
[[IB_Statements/UserDefinedProcs|'''User Defined Procedures''']]
-
:.<br>
+
-
:.<br>
+
-
:OPEN (2) "CUSTFILE"<br>
+
-
:.<br>
+
-
:.<br>
+
-
:INPUT NAME$<br>
+
-
:.<br>
+
-
:SearchFile (2,CustRec) NAME$ NameLen NamePos 1 Flags
+
-
There are several options which make SearchFile very flexible. Possible Flag values are combinations of:<br>
+
Comet32 Numeric Processing
-
1 - Search Next<br>
+
* Comet32 provides much enhanced numeric handling over Comet16.
-
2 - Case-sensitive search<br>
+
* Numeric variables can be as long as 32 decimal places. This is twice the length of Comet16.
-
4 - Field begins with search string
+
* Expression results are calculated to length 64.32 so that partial results of expressions are preserved.
 +
* The following Comet16 Functionality is supported::
 +
            Add,          z = x + y
 +
            Subtract,      z = x - y
 +
            Multiply,      z = x * y
 +
            Divide,        z = x / y
 +
            Negate,        z = - x
 +
            Abs,          z = abs(x)      -- Return the absolute value of x
 +
            Int,          z = int(x)      -- Return the integer portion of x
 +
            Fpt,          z = fpt(x)      -- Return the fractional portion of x
 +
            Sgn,          z = sgn(x)      -- Return the sign of x (-1,0,+1)
 +
            Num,          z = num(a$,err) -- Return the string a$ converted to a number.
 +
            Asc,          z = asc(a$)    -- Return the ascii equivalent of the first character in a$.
 +
            Len,          z = len(a$)    -- Return the length of string a$.
 +
            BitwiseAnd,    z = x and y
 +
            BitwiseOr,    z = x or y
 +
            BitwiseXor,    z = x xor y
 +
            BitwiseNot,    z = not(x)
 +
            Mod,          z = x mod y    -- Divides int(x) by int(y) and return the remainder
 +
            Sqrt,          z = sqrt(x)    -- Return the Square Root of x
 +
            Rnd,          z = rnd()      -- Return a "random number" between 0 and 1
 +
Many additional math functions are supported in Comet32:
 +
            Cbrt,          z = cbrt(x)    -- Return the Cube Root of x
 +
            Log,          z = log(x)      -- Return the base-e logarithm of x, so x==exp(z)
 +
            Log10,        z = log10(x)    -- Return the base-10 logarithm of x, so x==pow(10,z)
 +
            Exp,          z = exp(x)      -- Return e raised to the power x, so x==log(z)
 +
            Pow,          z = pow(x,y)    -- Return x raised to the power y
 +
            Sin,          z = sin(x)      -- Return the sine of x, with x in radians
 +
            Cos,          z = cos(x)      -- Return the cosine of x, with x in radians
 +
            Tan,          z = tan(x)      -- Return the tangent of x, with x in radians
 +
            Asin,          z = asin(x)    -- Return the inverse sine of x, in radians
 +
            Acos,          z = acos(x)    -- Return the inverse cosine of x, in radians
 +
            Atan,          z = atan(x)    -- Return the inverse tangent of x, in radians
 +
            Atan2,        z = atan2(y,x)  -- Return the 4 quadrant inverse tangent of y/x
 +
            Sinh,          z = sinh(x)    -- Return the hyperbolic sine of x
 +
            Cosh,          z = cosh(x)    -- Return the hyperbolic cosine of x
 +
            Tanh,          z = tanh(x)    -- Return the hyperbolic tangent of x
 +
            Asinh,        z = asinh(x)    -- Return the inverse hyperbolic sine of x
 +
            Acosh,        z = acosh(x)    -- Return the inverse hyperbolic cosine of x
 +
            Atanh,        z = atanh(x)    -- Return the inverse hyperbolic tangent of x
 +
            Factorial,    z = factorial(x)-- Return the factorial of x
 +
            Floor,        z = floor(x)    -- Return the floor (next lowest integer value) of x.
 +
            Ceil,          z = ceil(x)    -- Return the ceil (next highest integer value) of x.
 +
            Gcd,          z = gcd(x,y)    -- Return the GCD (greatest common divisor) of x, y.
 +
            Lcm,          z = lcm(x,y)    -- Return the LCM (least common multiple) of x, y.
 +
Beware! The following code will not work the same for Comet32 as it did for Comet16:
 +
        For I = 0 to 99                   
 +
            A$ = "T" + sub(str(i+100),15,2)
 +
        Next i
-
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.  
+
Because the result of the addition is in the accumulator which has changed.
-
If you include 2 in your Flag value the search will be case-sensitive. It is not by default.
+
The following code will ALWAYS work for both Comet16 and Comet32:
-
 
+
        For I = 0 to 99
-
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.
+
              A$ = `T' + sub(strip(str(i+100)),2,2)
-
 
+
        Next I
-
 
+
-
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:<br>
+
-
E02 - End of file was reached before the number of occurrences were found<br>
+
-
E45 - An invalid parameter was specified<br>
+
-
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.
+
-
<br>
+
-
This statement was introduced with Comet32.
+

Latest revision as of 22:49, 5 December 2017

Search File - C32

InputFile and PrintFile - C32

GetFormat and SetFormat - C32

User Defined Procedures

Comet32 Numeric Processing

  • Comet32 provides much enhanced numeric handling over Comet16.
  • Numeric variables can be as long as 32 decimal places. This is twice the length of Comet16.
  • Expression results are calculated to length 64.32 so that partial results of expressions are preserved.
  • The following Comet16 Functionality is supported::
           Add,           z = x + y
           Subtract,      z = x - y
           Multiply,      z = x * y
           Divide,        z = x / y
           Negate,        z = - x
           Abs,           z = abs(x)      -- Return the absolute value of x
           Int,           z = int(x)      -- Return the integer portion of x
           Fpt,           z = fpt(x)      -- Return the fractional portion of x
           Sgn,           z = sgn(x)      -- Return the sign of x (-1,0,+1)
           Num,           z = num(a$,err) -- Return the string a$ converted to a number.
           Asc,           z = asc(a$)     -- Return the ascii equivalent of the first character in a$.
           Len,           z = len(a$)     -- Return the length of string a$.
           BitwiseAnd,    z = x and y
           BitwiseOr,     z = x or y
           BitwiseXor,    z = x xor y
           BitwiseNot,    z = not(x)
           Mod,           z = x mod y     -- Divides int(x) by int(y) and return the remainder
           Sqrt,          z = sqrt(x)     -- Return the Square Root of x
           Rnd,           z = rnd()       -- Return a "random number" between 0 and 1

Many additional math functions are supported in Comet32:

           Cbrt,          z = cbrt(x)     -- Return the Cube Root of x
           Log,           z = log(x)      -- Return the base-e logarithm of x, so x==exp(z)
           Log10,         z = log10(x)    -- Return the base-10 logarithm of x, so x==pow(10,z)
           Exp,           z = exp(x)      -- Return e raised to the power x, so x==log(z)
           Pow,           z = pow(x,y)    -- Return x raised to the power y
           Sin,           z = sin(x)      -- Return the sine of x, with x in radians
           Cos,           z = cos(x)      -- Return the cosine of x, with x in radians
           Tan,           z = tan(x)      -- Return the tangent of x, with x in radians
           Asin,          z = asin(x)     -- Return the inverse sine of x, in radians
           Acos,          z = acos(x)     -- Return the inverse cosine of x, in radians
           Atan,          z = atan(x)     -- Return the inverse tangent of x, in radians
           Atan2,         z = atan2(y,x)  -- Return the 4 quadrant inverse tangent of y/x
           Sinh,          z = sinh(x)     -- Return the hyperbolic sine of x
           Cosh,          z = cosh(x)     -- Return the hyperbolic cosine of x
           Tanh,          z = tanh(x)     -- Return the hyperbolic tangent of x
           Asinh,         z = asinh(x)    -- Return the inverse hyperbolic sine of x
           Acosh,         z = acosh(x)    -- Return the inverse hyperbolic cosine of x
           Atanh,         z = atanh(x)    -- Return the inverse hyperbolic tangent of x
           Factorial,     z = factorial(x)-- Return the factorial of x
           Floor,         z = floor(x)    -- Return the floor (next lowest integer value) of x.
           Ceil,          z = ceil(x)     -- Return the ceil (next highest integer value) of x.
           Gcd,           z = gcd(x,y)    -- Return the GCD (greatest common divisor) of x, y.
           Lcm,           z = lcm(x,y)    -- Return the LCM (least common multiple) of x, y.

Beware! The following code will not work the same for Comet32 as it did for Comet16:

        For I = 0 to 99                     
            A$ = "T" + sub(str(i+100),15,2)
        Next i 

Because the result of the addition is in the accumulator which has changed.

The following code will ALWAYS work for both Comet16 and Comet32:

       For I = 0 to 99
             A$ = `T' + sub(strip(str(i+100)),2,2)
       Next I
Personal tools