Shop OBEX P1 Docs P2 Docs Learn Events
Output - Input — Parallax Forums

Output - Input

Mike onlyMike only Posts: 15
edited 2007-01-18 06:00 in BASIC Stamp
Halo,
I'm new in PBasic programming and tried to make a program with BOE (BS2). This time, I'm using· INPUT and OUTPUT commads, but I've different result, when I put the INPUT command in front of OUTPUT command:

OUTPUT 8
OUTPUT 9
INPUT 10

Main:
···· OUT8=IN10
····· OUT9=IN10
GOTO Main

Is different result when I make a program as below:

OUTPUT 8
OUTPUT 9
INPUT 10

Main:
···· IN10=OUT8
···· ·IN10=OUT9
GOTO Main

Is it correct that I may not freely put the commands as I will, even though it's logically·the sameconfused.gif
Sorry for my poor english.

Thank you
Mike only

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-18 04:33
    These are not logically the same. The "=" operation is an assignment in PBasic, not the mathematical equivalence (equality).
    It is a little confusing since the same character is used to test for equality in the IF statement (but only in the IF statement
    or the WHILE or UNTIL portions of the DO statement).

    When you say "OUT8=IN10", you are saying "make the output pin 8 the same as the present value of input pin 10".
    When you say "OUT9=IN10", you are saying "make the output pin 9 the same as the present value of input pin 10".

    When you say "IN10=OUT8", you are actually doing something unusual since you are trying to set an input register bit
    to the value of an output register bit. The PBasic interpreter promptly ignores what you have tried to do and sets IN10
    to the actual value of the input pin. You can use OUT8 as a value since the output register contains the last value that
    you set for the output pin even if the direction of the pin is set to input.

    I hope this helps.
  • Mike onlyMike only Posts: 15
    edited 2007-01-18 06:00
    Thank you very much for your informationsmile.gif

    Best Regards,

    Mike only
Sign In or Register to comment.