ReadValue
IntegerValue = ReadValue(ChannelIndex)
 
Parameters:

    ChannelIndex = Index of the file channel to read from
Returns:

    IntegerValue = The integer value that has been read from this file
 

      The ReadValue function will read the next line of text from an open file channel and return it as an integer value.

      ReadValue is short hand for the following Result= Val(ReadString$(1))



FACTS:


      * ReadValue only works with files opened with ReadFile command.
      * Integer values range from -2147483647 to 2147483647



Mini Tutorial:


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


  
; Create file name
  File$=TempDir$()+"PB_TestFile.txt"
  
; CReate a File for writing data to
  WriteFile File$,1
  
; Write a String of the Integer value 5000
  WriteString 1,"5000"
  
; Write a String of the Float Value 33.33
  WriteString 1,"33.33"
  
; Close this file channel
  CloseFile 1
  
  
  Print "============================"
  Print "Reading File:"+File$
  Print "============================"
  
  
; Open a file to READ with READFILE
  ReadFile File$,1
  
; Read and display the String value and a integer + 100
  ThisInteger=ReadValue(1)
  Print "  Integer Data:"+Str$(ThisInteger+100)
  
; Read and display the String value as a float + 100
  ThisFloat#=ReadValue#(1)
  Print "  Float Data:"+Str$(ThisFloat#+100)
  
; 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
  ============================
  Integer Data:5100
  Float Data:133.33
  

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


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