Shop OBEX P1 Docs P2 Docs Learn Events
error message — Parallax Forums

error message

SAMYTRIXSAMYTRIX Posts: 11
edited 2006-03-26 15:45 in BASIC Stamp
I'm typing in a simple code such as the following and I get an error "Expected a variable, text, or a DEBGUG command" and it highlights the DEC command, when I try to run the code:

' {$STAMP BS1}
' {$PBASIC 1.0}
' What's a Microcontroller - FirstProgramYourTurn.bs1
' BASIC Stamp sends messages to Debug Terminal.
DEBUG "Hello, this is your BASIC Stamp!"
DEBUG CR, "What's 7 X 11?"
DEBUG CR, "The answer is: "
DEBUG DEC 7*11

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-03-26 14:22
    You can't display in DEBUG the result of a computation this way.· You need to declare some variables, perform the computation, then display/DEBUG that result:
    SYMBOL A = B2
    SYMBOL B = B3
    SYMBOL C = B4
     
    A = 7
    B = 11
    
    DEBUG "Hello, this is your BASIC Stamp!"
    DEBUG CR, "What's 7 X 11?"
    DEBUG CR, "The answer is: "
    C = A * B
    DEBUG CR, C
    



    Post Edited (PJ Allen) : 3/26/2006 2:26:36 PM GMT
  • ForrestForrest Posts: 1,341
    edited 2006-03-26 14:27
    Debug expressions aren't allowed on a BS1. The Debug command is more limited on a BS1 compared to the BS2.

    FYI the What's a Micontroller book was written for a BS2. Many of the programs in the book won't work on a BS1.
  • SAMYTRIXSAMYTRIX Posts: 11
    edited 2006-03-26 14:27
    pj aLLEN THAT CODE GIVES ME a result of 0, but it should be 77. However I did it this way:

    SYMBOL A = 7
    SYMBOL B = 11
    SYMBOL C = B4

    DEBUG "Hello, this is your BASIC Stamp!"
    DEBUG CR, "What's 7 X 11?"
    DEBUG CR, "The answer is: "
    C = A * B
    DEBUG CR, C

    and I got 77. Is that a correct coding?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-03-26 14:34
    Sorrrry.··blush.gif·

    I edited my program, where I'd had· C = A * C instead of A * B.
    Am I all messed up?· My BS1 is all tied up doing something else right now.

    Yours is "correct", but the A and B are constants instead of variables, if you're good with that then so am I.

    Post Edited (PJ Allen) : 3/26/2006 2:37:54 PM GMT
  • ForrestForrest Posts: 1,341
    edited 2006-03-26 14:39
    PJ Allen's program should work as listed. The Symbol command links a variable with a RAM locations (SYMBOL A=B2). Next numbers are stored in the variable location (A=7)
  • SAMYTRIXSAMYTRIX Posts: 11
    edited 2006-03-26 15:37
    Also, another quick question please? Where can I buy the servo motor thing. I ordered my BS1 from parallax but now I just wanted to get the servo motor. Do they sell that separately? or does it have to come with a kit and stuff...
  • ForrestForrest Posts: 1,341
    edited 2006-03-26 15:45
    You can buy servo's here www.parallax.com/html_pages/robotics/component/robo_components_shop.asp

    There are also many other sources for Servo's - use Google to find them.
Sign In or Register to comment.