Qbasicnews.com

Full Version: Input from file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
in this code
Code:
CLS
OPEN "C:\en.txt" FOR INPUT AS #1
INPUT #1, a$
CLOSE #1
PRINT a$

if en.txt contains
Code:
Hello, Bob
It will only have "Hello" how can i get past this?

Silent-Death

In the text doc. (en.txt) if you remove the comma then it prints
Code:
Hello bob
Yeah but i dont want to disallow the comma when i use this in my program.

Silent-Death

What are you trying to do??? IF your trying to get it to say Hello, bob then put commas around the whole thing...
Use LINE INPUT #1, a$ ... It comes in the almighty QB help Wink

Code:
LINE INPUT # - a file I/O statement that reads an entire line without
               delimiters from a sequential file to a string variable
Syntax
  LINE INPUT #filenumber,stringvariable
    â–  filenumber is the number of an open sequential file
    â–  stringvariable will hold all characters from the sequential file
      from the current position in the file up to, but not including, the
      next carriage-return-line-feed sequence. No carriage-return-line-feed
      sequences are ever input.
Quote:Use LINE INPUT #1, a$ ... It comes in the almighty QB help

Thanks na_th_an that was just what i needed(+a little tweak)
Code:
OPEN fi$ FOR INPUT AS #1
fi$ = ""
DO
LINE INPUT #1, doot$
fi$ = fi$ + doot$ + CHR$(13)
LOOP UNTIL EOF(1)
CLOSE #1

Ok, my project shall be unveiled in a little while.
Quote:... Ok, my project shall be unveiled in a little while.

We'll all be waiting with bated breath! :wink:
*****
is it some super cool Win32 compiler for QB?
Maybe an e-greeting card Tongue
:roll: :roll:
Pages: 1 2 3