[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
FREADSTR()

    FREADSTR() reads characters from a DOS file.

Syntax

    FREADSTR(<expN1>,<expN2>)

Argument

    <expN1> is the file handle obtained from FOPEN(), FCREATE(), or
    predefined by DOS.

    <expN2> is the number of bytes to read beginning at the current DOS file
    pointer position.  This can be a positive or negative number depending
    on the direction (forward or backward) you want to read from the
    current pointer position.

Returns

    A character string.

    FREADSTR() returns a string up to 65,535 (64K) bytes.  A null return
    value ("") indicates an error or end-of-file.

Usage

    FREADSTR() reads from the current DOS file pointer position, the number
    of characters specified by <expN2> or until a null character (ASCII 0)
    is encountered.  Like FREAD(), all characters are read including
    control characters.

Example

    The following example displays the ASCII value of the first 16 bytes of
    the text file, New.txt:

    handle = FOPEN("Temp.txt")                           
    IF FERROR() <> 0                                     
       ? "File open error."                              
       RETURN                                            
    ELSE                                                 
       buffer = FREADSTR(handle,16)                      
       ? "Length: ", LEN(buffer)                         
       ?                                                 
       FOR i = 1 TO LEN(buffer)                          
          ?? TRANSFORM(ASC(SUBSTR(buffer, i, 1)),; "99") 
       NEXT                                              
       FCLOSE(handle)                                    
    ENDIF                                                
    RETURN                                               

WARNING: This function allows low level access to DOS files & devices.
             They should be used with extreme care and require a thorough
             knowledge of the operating system.

See Also: FCLOSE FCREATE FERROR FOPEN FREAD FSEEK FWRITE
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson