subroutine question


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Posts
    14

    Default subroutine question

    i want to create a selection that automaticly goes into the right sub menu

    for example is counter=1 then gosub routine1, counter=2 then gosub routine2, counter=3 then gosub routine3 etc.

    something like this:

    main routine:

    counter=counter+1
    'do whatever i wanna do

    gosub routine(counter)

    'and on
    goto main

    routine1:
    'do 1st:return

    routine2:
    'do 2nd:return

    routine3:
    'do 3th:return

    can this be done simple in picbasic, so i can keep my main program short !

    thanx allready for your ideas and suggestions

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    use BRANCH or BRANCHL. But don't forget, it's multiple goto, not gosub.

    OR use SelectCase

    Code:
    Select Case Counter
        Case 1 : Gosub Routine1
        Case 2 : Gosub Routine2
        Case 3 : Gosub Routine3
        '
        '
        End Select
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Oct 2005
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    thanx for helping my on the way again,

    i tested with BRANCH and it works

Similar Threads

  1. Using "END" in a subroutine?
    By Byte_Butcher in forum General
    Replies: 6
    Last Post: - 13th February 2010, 16:32
  2. Multiple RETURNS within a single subroutine
    By BrianT in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st June 2009, 16:43
  3. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49
  4. Another MSCP ICD question
    By keithdoxey in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 31st July 2006, 00:07
  5. TMR1 interrupt question
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th February 2006, 03:02

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts