Announcement

Collapse
No announcement yet.

INPUT won't read commas

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • INPUT won't read commas

    I'm trying to read console input (to search for text). I found that PBCC 5.0 will not read a comma "," and says the length of the INPUT string is 0. If I enclose the comma with quotes on the input line then it reads just fine. The following code demonstrates the problem.

    #COMPILE EXE
    #DIM ALL

    FUNCTION PBMAIN () AS LONG
    DIM t$
    PRINT "Inputting a comma returns an empty string."
    PRINT
    INPUT "input: "; t$
    PRINT "output: "; t$
    PRINT "Length = ";LEN(t$)
    WAITKEY$
    END FUNCTION

    Is that a feature or a bug? I'd like to read those commas directly without having to explicity include the quotes.

    Thanks!
    Tom

  • #2
    Short answer: Change

    INPUT "input: "; t$ to

    LINE INPUT "input: ";t$

    Longer answer: It's not a bug. INPUT was designed to handle comma delimited data files. For example, suppose you have a data base consisting of LastName, FirstName, and TelephoneNumber. You would structure the input something like:

    INPUT #1,lName$, fName, tNumber. In this instance, $crlf would be treated as a comma.

    Line Input, OTOH, only sees $crlf as the delimiter. It enters everything up to that point into a string.
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      Thanks, Mel! That works. I thought there might be some connection with handling comma delimited fields but didn't think to use LINE INPUT.
      Tom

      Comment

      Working...
      X