Shop OBEX P1 Docs P2 Docs Learn Events
Question about declaring subroutines and functions in SX/B — Parallax Forums

Question about declaring subroutines and functions in SX/B

RobotWorkshopRobotWorkshop Posts: 2,307
edited 2007-01-10 18:46 in General Discussion
Hello, I have read through the Elements of style guide for SX/B and have a question about declaring subroutines and functions in SX/B. In the example is shows:

WAIT_MS SUB 1,2
GET_TEMP FUNC 2

I read that subroutines can return a byte value and that functions can return a byte or word. It also sounds like you can pass more than one parameter to a subroutine or function.

What I have yet to find a reference to is just what the meaning/significance of the numbers are following the SUB and FUNC in the examples above. Does it specify how many are passed to the routine, How many are returned, or if it is a byte or word that is passed and returned?

Can anyone shed some light on what the meanings of these values are?

Thank You,

Robert

Comments

  • BeanBean Posts: 8,129
    edited 2007-01-10 17:21
    In the help file under Reference->Definition about 2/3 down is "Subroutine Declaration" then "Function Declaration"

    Subroutine Declaration:
    Label SUB {Min{, Max}}

    Function Declaration:
    Label FUNC ReturnCount{, Min{, Max}}

    WAIT_MS SUB 1,2 ' Minimum of 1 byte, maximum of 2 bytes; byte or byte,byte or word
    GET_TEMP FUNC 2 ' Returns 2 bytes; no parameters

    Just remember that the values are BYTES. So if you want a FUNC that receives a WORD and returns a WORD you would use:

    MyFunc FUNC 2,2

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2007-01-10 17:23
    Thank you for the replies! That clears things up. Now I can get back to programming.....
  • BeanBean Posts: 8,129
    edited 2007-01-10 18:46
    Your welcome.
    Good luck with your projects.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
Sign In or Register to comment.