Shop OBEX P1 Docs P2 Docs Learn Events
If Then Question — Parallax Forums

If Then Question

ArchiverArchiver Posts: 46,084
edited 2001-02-24 06:38 in General Discussion
Hi Guys,

I am used to useing a Bx-24 chip, but have to use a stamp for class
and so this is probably a simple question but I can't figure it out.
What I want is to have an If-Then statement that is the statement is
true it calls a subroutine, and then returns after the subroutine is
finished running. However, when I write

If Condition = True then Subroutine
Rest of code

it executes the subroutine but doesn't return. I even put the return
line in the subroutine. It does return if I use the Gosub comand,
but for an If-Then statement you don't use Gosub.

Is there a work around for this?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-02-24 04:52
    Since an IF statment can only branch to a label the messy work around is
    this

    if condition then dogosub
    goto skipgosub
    dogosub:
    gosub label
    skipgosub:

    I know its messy but it should work...


    Original Message
    From: <radtke@h...>
    To: <basicstamps@yahoogroups.com>
    Sent: Friday, February 23, 2001 11:44 PM
    Subject: [noparse][[/noparse]basicstamps] If Then Question


    > Hi Guys,
    >
    > I am used to useing a Bx-24 chip, but have to use a stamp for class
    > and so this is probably a simple question but I can't figure it out.
    > What I want is to have an If-Then statement that is the statement is
    > true it calls a subroutine, and then returns after the subroutine is
    > finished running. However, when I write
    >
    > If Condition = True then Subroutine
    > Rest of code
    >
    > it executes the subroutine but doesn't return. I even put the return
    > line in the subroutine. It does return if I use the Gosub comand,
    > but for an If-Then statement you don't use Gosub.
    >
    > Is there a work around for this?
    >
    >
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-02-24 06:38
    [font=arial,helvetica]In a message dated 2/23/01 10:47:02 PM Central Standard Time,
    radtke@hotmail.com writes:


    I am used to useing a Bx-24 chip, but have to use a stamp for class
    and so this is probably a simple question but I can't figure it out.
    What I want is to have an If-Then statement that is the statement is
    true it calls a subroutine, and then returns after the subroutine is
    finished running. ·However, when I write

    If Condition = True then Subroutine
    Rest of code

    it executes the subroutine but doesn't return. ·I even put the return
    line in the subroutine. ·It does return if I use the Gosub comand,
    but for an If-Then statement you don't use Gosub.



    PBASIC is designed for embedded apps (VB isn't...), so it's a little slimmer
    than what you're used to. ·You can do it this way:

    ·IF NOT (condition) THEN Skip
    ·GOSUB YourSubNameHere
    Skip:[/font]
Sign In or Register to comment.