Shop OBEX P1 Docs P2 Docs Learn Events
Help with programming — Parallax Forums

Help with programming

goofybud16goofybud16 Posts: 9
edited 2010-01-13 13:51 in BASIC Stamp
Is there such a thing as a Method or function in PBASIC? I am a beginner. I need help. Thanx. smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--
goofybud16

Comments

  • DufferDuffer Posts: 374
    edited 2010-01-12 02:33
    GOSUB, but you can't pass parameters. Duffer
  • vaclav_salvaclav_sal Posts: 451
    edited 2010-01-12 17:19
    Subroutine will accept parameters.
    They are however "common" variables of the program, not specific to subroutine.
    Here is an example

    'Variable Declaration·
    Test VAR Word
    .....
    'Variable assigment
    Word = 42
    .....
    'Subroutine
    GOSUB Label

    'Now Test·= 43

    .....

    ' subroutine
    Label:
    ···· Test = Test + 1
    return
    ·
  • allanlane5allanlane5 Posts: 3,815
    edited 2010-01-13 13:51
    No, a "subroutine using parameters" would look like:

    Gosub MySub, A, B, C

    PBasic does not have this -- all variables are global. However, you can implement something like this using
    "Temp1" and "Temp1" variables. In which case this looks like:

    Temp1=5: Temp2 = 6
    GOSUB MySub ' Temp2 = Temp2 + Temp1


    MySub:
    Temp2 = Temp2 + Temp1
    RETURN
Sign In or Register to comment.