ReadChr$
String$ = ReadChr$(ChannelIndex, Length)
 
Parameters:

    ChannelIndex = Index of the file channel to read from
    Length = The number of characters to read
Returns:

    String$ = The string that has been read from this file
 

      The ReadChr$ function will read a fixed number of characters from an open file channel. You can also make it read a zero terminated string, by setting the Length parameter to zero.




FACTS:


      * ReadChr$ only works with files opened with ReadFile command.

      * Setting the Length parameter to zero, will make ReadChr$ read a Zero terminated string.



Mini Tutorial:


      This example creates a simple file with some various bits of data store in it, then read it's back again.


  
  File$=TempDir$()+"PB_TestFile.txt"
  
; CReate a File for writing data to
  WriteFile File$,1
  
; Write a String to file channel 1, of the word
; "Play Basic"
  WriteChr 1,"Play Basic",10
  
; Close this file channel
  CloseFile 1
  
  
  Print "============================"
  Print "Reading File:"+File$
  Print "============================"
  
  
; Open a file to READ with READFILE
  ReadFile File$,1
  
; Start a For/Next loop for the length of this file
  For lp=1 To FileSize(file$)
   ; read and Display 1 character from this
   ; file channel per loop
     Print ReadChr$(1,1)
  Next
  
; Close this file channel
  CloseFile 1
  
  If FileExist(file$) Then DeleteFile file$
  
; Display the screen and wait for a key press
  Sync
  WaitKey
  



This example would output.

  
  ============================
  Reading File:C:Windows\temp\Pb_TestFile.txt
  ============================
  P
  l
  a
  y
  
  B
  a
  s
  i
  c
  

 
Related Info: CloseFile | ReadByte | ReadChrAt$ | ReadFile | ReadFloat | ReadInt | ReadString$ | ReadValue | ReadValue# | ReadWord :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com