gosub - return


Closed Thread
Results 1 to 5 of 5

Thread: gosub - return

  1. #1
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153

    Default gosub - return

    I need to use the following code two different ways I need to gosub to this section and also in another section either goto or just let it continue through to this section from the code just above it. With this second idea of the code rolling through will the return be skipped or will it get in the way somehow??

    Power_On:
    Value = 100
    counter =0
    gosub Send_command
    pause 500
    Return

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Why not just move it somewhere out of the way and place a GOSUB Power_On where it used to be?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default gosub-return

    Yes this is what I did,
    but I would still like to know what it does and if it would mess up somehow

  4. #4
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I haven't tried it personally because its never really necessary.

    If you want to know what happens, try it
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  5. #5


    Did you find this post helpful? Yes | No

    Default Multiple entry points to a subroutine

    DoSomeTimes:
    code block 1
    DoOften:
    code block 2
    Return

    The above structure lets you have two separate entry points with a single return. I use this structure when I want to recalibrate a sensor for example.

    Calling GOSUB DoOften gets the result of the sensor.
    Calling GOSUB DoSomeTimes starts with a calibration routine then gets the results of the sensor.

    your mileage may vary but the idea works for me.

    HTH
    BrianT

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