Passing arguments to subroutines


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891

    Default Passing arguments to subroutines

    Hello,

    Is there a way to pass one or more arguments when calling, i.e., a subroutine?

    Example: I want to call a subroutine that does something according to a changing value.

    It would look like "GOSUB SubRoutine, 123" where 123 is the changing value.

    Is this possible in PBP?
    Roger

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Lightbulb Super Roger ...

    Hi, Roger

    If you like assembler ... just have a look to PbPxx Libs., Functions sections. That will show you how the arguments are passed to the functions.

    My souvenirs tell me the full lib must fit into page 0 for 14 bits prog. devices ...

    read you later

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default ...

    Hello Alain,

    Thanks for your super-quick reply

    Well then, I go back to my dreams since assembly will not be able to find some place in my brain in this life, I'm afraid... My brain is like the swiss cheese: lots of holes and only few consistent matter

    Have a nice day.

    NB: dommage, ça m'aurait été super-utile!
    Roger

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Talking

    Yes , Roger

    BUT ... is it so difficult to set the variables to be used to their values just before jumping to your sub ???

    < NB: dommage, ça m'aurait été super-utile!>

    Just choose the convenient processor ... after all !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default

    ...I'm too lazy

    Seriously, I was looking to avoid this way of doing (because this is what I actually do).

    Once again, you prove there is ALWAYS a solution... and thank you for this.
    Roger

  6. #6
    Join Date
    Sep 2006
    Location
    Mexico
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    Hello, try with this code:
    b0 var byte

    Main:

    ... some code
    b0=123
    gosub test
    ...some code
    goto Main

    test:
    if b0=123 then
    ...code
    endif
    return

Similar Threads

  1. Subroutine Variable Passing
    By GoldStar in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th May 2009, 08:55
  2. PIC18F4550 Error[128] Missing Arguments
    By damalu in forum mel PIC BASIC
    Replies: 9
    Last Post: - 17th November 2008, 22:47
  3. Functions in Pic Basic Pro
    By bumlife in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 4th April 2007, 22:59
  4. Shorter Subroutines for MAX7219
    By exelanoz in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th March 2007, 12:35
  5. Measuring speed of a passing vehicle
    By kitcat in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 12th July 2005, 17:50

Members who have read this thread : 1

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