Shop OBEX P1 Docs P2 Docs Learn Events
if loops and numbers and serin :/ — Parallax Forums

if loops and numbers and serin :/

trendtrend Posts: 112
edited 2004-12-06 16:19 in BASIC Stamp
What is the currect way of getting numbers from the computer (via hyperterm or visual basic6)?

I have been:

·· serin 16, baud, [noparse][[/noparse]number]
···if number = "13" then debug "works"

but then I get a compile error.. "expected 'then'"

I could always do:
·· serin 16, baud, [noparse][[/noparse]number]
···if number = 13 then debug "works"

but then.. 13 doesn't equal "13".. so the if loop doesn't get completed :/

any ideas?

thanks-Lee





Post Edited (trend) : 12/5/2004 11:47:15 AM GMT

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2004-12-06 16:19
    There is no "string compare" operator on the BS2, so you have to compare values.

    SERIN 16, baud, [noparse][[/noparse]number]

    will recieve a single byte. If you sent it a CR character (Ctrl-J? Ctrl-M? one of those two) then the compare
    IF number = 13 THEN Debug "Got it"

    should work.

    You COULD do:
    SERIN 16, baud [noparse][[/noparse]DEC number]

    THEN send it the three characters '1', '3', CR.

    I believe this would put the value '13' into 'number', with the 'DEC' parsing your sent two characters into the value.
Sign In or Register to comment.