timeout of Hserin, goto, gosub or both?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Difficult to give suggestions without knowing what you have in mind to achieve. The below is a simple way to get out of the While/Wend loop.

    Code:
    StrLIst    var byte[10] ' for example not knowing the true dimension
    gotchar   var byte
    
    
    BUfferChar:
    gotchar=0
    return_code=0
    low HIGH RED_LED
    While return_code<>13 or gotchar >9
      Hserin 50, NoData, [return_code]
      StrLIst[gotchar]=return_code
      gotchar=gotchar+1   
      WEND
    RETURN
    
    
    Nodata:
    HIGH RED_LED   ; Show Error led (use the high state of this pin to workout   the timeout in the main routine)
    Return
    Al.
    Last edited by aratti; - 27th October 2009 at 08:16.
    All progress began with an idea

  2. #2
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    well, I believe as you suggest that it's ok to break a While loop...

    but what's tickle me is the GOTO timeout of Hserin, he would break out of a GoSub.

    If it's really a GOTO, there must not be any trace of where it was initiated in the stack, so NoData will not know where to return...
    And even more buggy, the BufferChar Gosub will not be completed.
    hence creating a bug.

    So in the end, I would believe it's not safe to use either a GOTO or a HSerin inside a Gosub.
    Last edited by flipper_md; - 28th October 2009 at 01:08. Reason: more taughs

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    If it's really a GOTO, there must not be any trace of where it was initiated in the stack, so NoData will not know where to return...
    And even more buggy, the BufferChar Gosub will not be completed.
    hence creating a bug.
    When your program jumps to NoData label, in the stacker is still pending the last GOSUB instruction (the one that directed the program flow to the routine under BUfferChar label), so no matter how many GOTO you will use, the first RETURN will clear the last pending gosub and pointer will return the program flow to the main program routine (if the gosub had been executed there). And this is what will happen with the RETURN under NoData label.

    Al.
    All progress began with an idea

  4. #4
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    very interres-thing!

    thanks much for this Al

    So it means goto's are safe inside a gosub, as long as there is a return in the end. I like that!

Similar Threads

  1. Graphic LCD with PICbasic pro
    By amindzo in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th November 2012, 11:45
  2. Making a menu
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 36
    Last Post: - 12th November 2008, 19:54
  3. Problems with RC2 and RC3
    By Christopher4187 in forum General
    Replies: 11
    Last Post: - 29th May 2006, 17:19
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. ds1307 from f877 to f452 not work
    By microkam in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th July 2005, 00:02

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