Shop OBEX P1 Docs P2 Docs Learn Events
PBASIC equivalent of INKEY$ command in QUICKBASIC? — Parallax Forums

PBASIC equivalent of INKEY$ command in QUICKBASIC?

ArchiverArchiver Posts: 46,084
edited 2003-06-27 17:37 in General Discussion
Is there a command equivalent to INKEY$ available in BASIC? Is there
a way to achieve this in PBASIC code to be run in BS2p?
THanks
Mohammed

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-06-27 15:27
    You can use SERIN or DEBUGIN (you must have PBASIC 2.5 for DEBUGIN).

    DEBUG "Press a key", CR
    DEBUGIN inKey
    DEBUG CR, CR, "You pressed --> ", inKey, " (with ASCII value: ", DEC
    inKey, ")"

    To the Stamp, a character is just a byte -- it's presentation in the
    DEBUG window depends on any modifiers. With none, the DEBUG window
    prints the character represented by that byte. With formatters (DEC,
    HEX, BIN, etc.), the value is converted to a string of characters. In
    the example above, if you press "A", you'll get:

    You pressed --> A (with ASCII value: 65)

    The manual has a good description of how all this works and you can
    download it at no charge.

    -- Jon Williams
    -- Parallax


    Original Message
    From: mohammedrasiq [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=BKrC85yf8XKX2FGNcmzvO6TJd0hOM4Cb4OhUtVyKEf3nHz3fle46SJ0RyV9mpzZ3qB4QmmsxmawKUZX7KQ]mohammedrasiq@y...[/url
    Sent: Thursday, June 26, 2003 11:04 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] PBASIC equivalent of INKEY$ command in
    QUICKBASIC?


    Is there a command equivalent to INKEY$ available in BASIC? Is there
    a way to achieve this in PBASIC code to be run in BS2p?
    THanks
    Mohammed


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-27 16:05
    Thanks Jon for your detailed reply. However, the INKEY$ function in
    QUICKBASIC does not hold the normal execution of the program. The
    INKEY$ function stores the last pressed key, whenever that is
    pressed. In the case of BASICSTAMP using SERIN & DEBUG, the program
    execution has to wait until the user enters a key. Any ways around it
    in BASIC STAMP?
    Thanks a lot
    Mohammed
    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > You can use SERIN or DEBUGIN (you must have PBASIC 2.5 for DEBUGIN).
    >
    > DEBUG "Press a key", CR
    > DEBUGIN inKey
    > DEBUG CR, CR, "You pressed --> ", inKey, " (with ASCII value: ",
    DEC
    > inKey, ")"
    >
    > To the Stamp, a character is just a byte -- it's presentation in the
    > DEBUG window depends on any modifiers. With none, the DEBUG window
    > prints the character represented by that byte. With formatters
    (DEC,
    > HEX, BIN, etc.), the value is converted to a string of characters.
    In
    > the example above, if you press "A", you'll get:
    >
    > You pressed --> A (with ASCII value: 65)
    >
    > The manual has a good description of how all this works and you can
    > download it at no charge.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: mohammedrasiq [noparse][[/noparse]mailto:mohammedrasiq@y...]
    > Sent: Thursday, June 26, 2003 11:04 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] PBASIC equivalent of INKEY$ command in
    > QUICKBASIC?
    >
    >
    > Is there a command equivalent to INKEY$ available in BASIC? Is
    there
    > a way to achieve this in PBASIC code to be run in BS2p?
    > THanks
    > Mohammed
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-27 16:57
    The Basic Stamp, being a non-multi-tasked,
    non-interrupt beast, can do only one thing
    at a time.

    The PC, having an interrupt-driven keyboard
    reader piece-of-code, can receive input from
    the keyboard and hold it until another piece
    of PC code (inkey$) can read it.

    The Stamp has to explicitly read each piece
    of input coming in to it. So the only
    way you can do this with a Basic Stamp is
    to explicitly try to get the byte and
    wait for it.

    You can, however, use a timeout on the SERIN
    command so if a byte is not being transmitted
    just now, your program can go do something
    useful and try again in a little bit.

    You can also use the CTS signal as a
    SERIN 'flag pin'. This allows the BS2 to
    signal a sender (when the SERIN instruction
    runs) that it is now OK to send the byte.


    --- In basicstamps@yahoogroups.com, "mohammedrasiq"
    <mohammedrasiq@y...> wrote:
    > Thanks Jon for your detailed reply. However, the INKEY$ function in
    > QUICKBASIC does not hold the normal execution of the program. The
    > INKEY$ function stores the last pressed key, whenever that is
    > pressed. In the case of BASICSTAMP using SERIN & DEBUG, the program
    > execution has to wait until the user enters a key. Any ways around
    it
    > in BASIC STAMP?
    > Thanks a lot
    > Mohammed
    > --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    > wrote:
    > > You can use SERIN or DEBUGIN (you must have PBASIC 2.5 for
    DEBUGIN).
    > >
    > > DEBUG "Press a key", CR
    > > DEBUGIN inKey
    > > DEBUG CR, CR, "You pressed --> ", inKey, " (with ASCII
    value: ",
    > DEC
    > > inKey, ")"
    > >
    > > To the Stamp, a character is just a byte -- it's presentation in
    the
    > > DEBUG window depends on any modifiers. With none, the DEBUG
    window
    > > prints the character represented by that byte. With formatters
    > (DEC,
    > > HEX, BIN, etc.), the value is converted to a string of
    characters.
    > In
    > > the example above, if you press "A", you'll get:
    > >
    > > You pressed --> A (with ASCII value: 65)
    > >
    > > The manual has a good description of how all this works and you
    can
    > > download it at no charge.
    > >
    > > -- Jon Williams
    > > -- Parallax
    > >
    > >
    > >
    Original Message
    > > From: mohammedrasiq [noparse][[/noparse]mailto:mohammedrasiq@y...]
    > > Sent: Thursday, June 26, 2003 11:04 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] PBASIC equivalent of INKEY$ command in
    > > QUICKBASIC?
    > >
    > >
    > > Is there a command equivalent to INKEY$ available in BASIC? Is
    > there
    > > a way to achieve this in PBASIC code to be run in BS2p?
    > > THanks
    > > Mohammed
    > >
    > >
    > > To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@yahoogroups.com
    > > from the same email address that you subscribed. Text in the
    > Subject
    > > and Body of the message will be ignored.
    > >
    > >
    > > Your use of Yahoo! Groups is subject to
    > > http://docs.yahoo.com/info/terms/
    > >
    > >
    > >
    > >
    > > This message has been scanned by WebShield. Please report SPAM to
    > > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-27 17:08
    Thanks Allan for your reply. That answers my question.
    Mohammed
    --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    wrote:
    > The Basic Stamp, being a non-multi-tasked,
    > non-interrupt beast, can do only one thing
    > at a time.
    >
    > The PC, having an interrupt-driven keyboard
    > reader piece-of-code, can receive input from
    > the keyboard and hold it until another piece
    > of PC code (inkey$) can read it.
    >
    > The Stamp has to explicitly read each piece
    > of input coming in to it. So the only
    > way you can do this with a Basic Stamp is
    > to explicitly try to get the byte and
    > wait for it.
    >
    > You can, however, use a timeout on the SERIN
    > command so if a byte is not being transmitted
    > just now, your program can go do something
    > useful and try again in a little bit.
    >
    > You can also use the CTS signal as a
    > SERIN 'flag pin'. This allows the BS2 to
    > signal a sender (when the SERIN instruction
    > runs) that it is now OK to send the byte.
    >
    >
    > --- In basicstamps@yahoogroups.com, "mohammedrasiq"
    > <mohammedrasiq@y...> wrote:
    > > Thanks Jon for your detailed reply. However, the INKEY$ function
    in
    > > QUICKBASIC does not hold the normal execution of the program. The
    > > INKEY$ function stores the last pressed key, whenever that is
    > > pressed. In the case of BASICSTAMP using SERIN & DEBUG, the
    program
    > > execution has to wait until the user enters a key. Any ways
    around
    > it
    > > in BASIC STAMP?
    > > Thanks a lot
    > > Mohammed
    > > --- In basicstamps@yahoogroups.com, "Jon Williams"
    <jwilliams@p...>
    > > wrote:
    > > > You can use SERIN or DEBUGIN (you must have PBASIC 2.5 for
    > DEBUGIN).
    > > >
    > > > DEBUG "Press a key", CR
    > > > DEBUGIN inKey
    > > > DEBUG CR, CR, "You pressed --> ", inKey, " (with ASCII
    > value: ",
    > > DEC
    > > > inKey, ")"
    > > >
    > > > To the Stamp, a character is just a byte -- it's presentation
    in
    > the
    > > > DEBUG window depends on any modifiers. With none, the DEBUG
    > window
    > > > prints the character represented by that byte. With formatters
    > > (DEC,
    > > > HEX, BIN, etc.), the value is converted to a string of
    > characters.
    > > In
    > > > the example above, if you press "A", you'll get:
    > > >
    > > > You pressed --> A (with ASCII value: 65)
    > > >
    > > > The manual has a good description of how all this works and you
    > can
    > > > download it at no charge.
    > > >
    > > > -- Jon Williams
    > > > -- Parallax
    > > >
    > > >
    > > >
    Original Message
    > > > From: mohammedrasiq [noparse][[/noparse]mailto:mohammedrasiq@y...]
    > > > Sent: Thursday, June 26, 2003 11:04 PM
    > > > To: basicstamps@yahoogroups.com
    > > > Subject: [noparse][[/noparse]basicstamps] PBASIC equivalent of INKEY$ command in
    > > > QUICKBASIC?
    > > >
    > > >
    > > > Is there a command equivalent to INKEY$ available in BASIC? Is
    > > there
    > > > a way to achieve this in PBASIC code to be run in BS2p?
    > > > THanks
    > > > Mohammed
    > > >
    > > >
    > > > To UNSUBSCRIBE, just send mail to:
    > > > basicstamps-unsubscribe@yahoogroups.com
    > > > from the same email address that you subscribed. Text in the
    > > Subject
    > > > and Body of the message will be ignored.
    > > >
    > > >
    > > > Your use of Yahoo! Groups is subject to
    > > > http://docs.yahoo.com/info/terms/
    > > >
    > > >
    > > >
    > > >
    > > > This message has been scanned by WebShield. Please report SPAM
    to
    > > > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-27 17:13
    QBASIC is taking advantage of the PC keyboard buffer -- something you
    don't have in the BASIC Stamp. The only way to prevent missing
    characters is to use flow control (so characters can't be sent until
    you're ready for them) or use an external UART as a buffer.

    -- Jon Williams
    -- Parallax


    Original Message
    From: mohammedrasiq [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=T-BhIpbrPxWYRTsfWad_eLRGcOz3jYiOFnzHWD5PDcvNiEVLxh99v7dF0tLMYENoRuX76vf1vg5wjIKDIg]mohammedrasiq@y...[/url
    Sent: Friday, June 27, 2003 10:05 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: PBASIC equivalent of INKEY$ command in
    QUICKBASIC?


    Thanks Jon for your detailed reply. However, the INKEY$ function in
    QUICKBASIC does not hold the normal execution of the program. The
    INKEY$ function stores the last pressed key, whenever that is
    pressed. In the case of BASICSTAMP using SERIN & DEBUG, the program
    execution has to wait until the user enters a key. Any ways around it
    in BASIC STAMP?
    Thanks a lot
    Mohammed
    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > You can use SERIN or DEBUGIN (you must have PBASIC 2.5 for DEBUGIN).
    >
    > DEBUG "Press a key", CR
    > DEBUGIN inKey
    > DEBUG CR, CR, "You pressed --> ", inKey, " (with ASCII value: ",
    DEC
    > inKey, ")"
    >
    > To the Stamp, a character is just a byte -- it's presentation in the
    > DEBUG window depends on any modifiers. With none, the DEBUG window
    > prints the character represented by that byte. With formatters
    (DEC,
    > HEX, BIN, etc.), the value is converted to a string of characters.
    In
    > the example above, if you press "A", you'll get:
    >
    > You pressed --> A (with ASCII value: 65)
    >
    > The manual has a good description of how all this works and you can
    > download it at no charge.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: mohammedrasiq [noparse][[/noparse]mailto:mohammedrasiq@y...]
    > Sent: Thursday, June 26, 2003 11:04 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] PBASIC equivalent of INKEY$ command in
    > QUICKBASIC?
    >
    >
    > Is there a command equivalent to INKEY$ available in BASIC? Is
    there
    > a way to achieve this in PBASIC code to be run in BS2p? THanks
    > Mohammed
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-27 17:37
    Thanks, Jon.
    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > QBASIC is taking advantage of the PC keyboard buffer -- something
    you
    > don't have in the BASIC Stamp. The only way to prevent missing
    > characters is to use flow control (so characters can't be sent until
    > you're ready for them) or use an external UART as a buffer.
    >
    > -- Jon Williams
    > -- Parallax
    >
    >
    >
    Original Message
    > From: mohammedrasiq [noparse][[/noparse]mailto:mohammedrasiq@y...]
    > Sent: Friday, June 27, 2003 10:05 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: PBASIC equivalent of INKEY$ command in
    > QUICKBASIC?
    >
    >
    > Thanks Jon for your detailed reply. However, the INKEY$ function in
    > QUICKBASIC does not hold the normal execution of the program. The
    > INKEY$ function stores the last pressed key, whenever that is
    > pressed. In the case of BASICSTAMP using SERIN & DEBUG, the program
    > execution has to wait until the user enters a key. Any ways around
    it
    > in BASIC STAMP?
    > Thanks a lot
    > Mohammed
    > --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    > wrote:
    > > You can use SERIN or DEBUGIN (you must have PBASIC 2.5 for
    DEBUGIN).
    > >
    > > DEBUG "Press a key", CR
    > > DEBUGIN inKey
    > > DEBUG CR, CR, "You pressed --> ", inKey, " (with ASCII value: ",
    > DEC
    > > inKey, ")"
    > >
    > > To the Stamp, a character is just a byte -- it's presentation in
    the
    > > DEBUG window depends on any modifiers. With none, the DEBUG
    window
    > > prints the character represented by that byte. With formatters
    > (DEC,
    > > HEX, BIN, etc.), the value is converted to a string of characters.
    > In
    > > the example above, if you press "A", you'll get:
    > >
    > > You pressed --> A (with ASCII value: 65)
    > >
    > > The manual has a good description of how all this works and you
    can
    > > download it at no charge.
    > >
    > > -- Jon Williams
    > > -- Parallax
    > >
    > >
    > >
    Original Message
    > > From: mohammedrasiq [noparse][[/noparse]mailto:mohammedrasiq@y...]
    > > Sent: Thursday, June 26, 2003 11:04 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] PBASIC equivalent of INKEY$ command in
    > > QUICKBASIC?
    > >
    > >
    > > Is there a command equivalent to INKEY$ available in BASIC? Is
    > there
    > > a way to achieve this in PBASIC code to be run in BS2p? THanks
    > > Mohammed
    > >
    > >
    > > To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@yahoogroups.com
    > > from the same email address that you subscribed. Text in the
    > Subject
    > > and Body of the message will be ignored.
    > >
    > >
    > > Your use of Yahoo! Groups is subject to
    > > http://docs.yahoo.com/info/terms/
    > >
    > >
    > >
    > >
    > > This message has been scanned by WebShield. Please report SPAM to
    > > abuse@p...
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
Sign In or Register to comment.