Weird Input# 
Author Message
 Weird Input#

    Hello folks. I am coding a Pascal compiler in VB5. Here's the situation
and the problem:

    User is supposed to select a source file (txt) and compile it. My code
just retrieves each line of the source file (in a loop of course) and start
looking for spaces (CHR(32)) and of course, Left/Right Trims them before
processing... I use the INPUT# statement but get something really {*filter*} when
the line to be read is something like:

    " 1 - Anything to be read"

    My code would then retrieve -with the input statement- 2 words/items
instead of one from this, the first one being "1" and the second one being
" - Anything to be read".

    I have checked the books (Language Ref) and found nothing that would
make me think that there is any variable or list separator in the example
line that would make the statement to stop reading (it must as I know so
far, read a CR/LF, no matter how far it might have been typed), I find weird
the fact that VB would break the line in 2.

    Curiously...when I try to read " Program Test" I won't have any problem
with it...even with a preceding <TAB> as a starting char before "Program"

    Is it a bug or am I doing something wrong?

    The problem is not too important since this troublesome case is not very
common (I hope so), but I am still curious and worried, because it might
"bug" on something else.



Mon, 02 Apr 2001 03:00:00 GMT  
 Weird Input#
What do you get using LINE INPUT ???

LFS

Quote:

>     User is supposed to select a source file (txt) and compile it. My code
> just retrieves each line of the source file (in a loop of course) and start
> looking for spaces (CHR(32)) and of course, Left/Right Trims them before
> processing... I use the INPUT# statement but get something really {*filter*} when
> the line to be read is something like:

>     " 1 - Anything to be read"

>     My code would then retrieve -with the input statement- 2 words/items
> instead of one from this, the first one being "1" and the second one being
> " - Anything to be read".



Mon, 02 Apr 2001 03:00:00 GMT  
 Weird Input#
Look at the description of write # and print # in the VB help.  My guess
is that the 1 is interpreted as a number and the rest as a string.  Does
the same thing happen whenever a valid number surrounded by whitespace
occurs in other locations in the line?  I agree with the Line Input
choice.  VB says that write # should be used to write files expected to
be read with input # because write # uses commas to delimit fields in
the data.

Doug Moore



Mon, 02 Apr 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How capture weird input from keyboard?

2. A WEIRD, really weird question!

3. input for input (2)

4. **Need Help with User INPUT, ASCII Codes, INPUT String length

5. Formatting date input in Input Box

6. Input vs Input$

7. Help: INPUT / INPUT # for gopher/UNIX files

8. API Call - Minimized App To Test Input of Mouse And Key Input

9. how to detect how long without any input since last input action

10. code similar to Qbasic INPUT and LINE INPUT keywords

11. Input# and Line Input#

12. How to disable/enable keyboard input and mouse input

 

 
Powered by phpBB® Forum Software