jumping out of a gosub reminder


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: jumping out of a gosub reminder

    Quote Originally Posted by richard View Post
    franken code ?
    Not necessarlly, Lot of hi level programing language have this already implemented. eg in .net: On Error GoTo, Try, catch, etc...
    Same could be done for HW. If something external happened then you need unconditionally goto something, and start program from known place.

    It is not easy to implement, by any means. But it could very useful.
    What longpole001 have exactly on his mind, I can't tell...

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: jumping out of a gosub reminder

    You could count your gosub nesting level in another variable.
    Increment for every gosub, and decrement for every return.
    You don’t know about PBP's own gosubs, but they are supposed to be the compiler’s problem, and aren’t your responsibility.

    So you would know if the value wasn’t zero when you thought it should be.

  3. #3
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: jumping out of a gosub reminder

    When compiler gosub, it will always return. Unless you use ISR to modify stack, which I wouldn't recommend.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    Did you find this post helpful? Yes | No

    Default Re: jumping out of a gosub reminder

    Quote Originally Posted by pedja089 View Post
    Not necessarlly, Lot of hi level programing language have this already implemented. eg in .net: On Error GoTo, Try, catch, etc...
    hmm, in python at least a sub with a "try" still returns , even if the processing aborts and executes an "try" error routine.
    i see no goto or stack popping going on.

    a couple of python subs with try
    Code:
    def process_d(tname,q):    while exitflg==0:
            dx=ser.readline()
            try :
                rt='s'
                
                ff= string.rstrip(dx)   
                int(ff,16)   ##non hex chr will cause ValueError
                if dx[0]=='A':
                     rt='w'
                
                #print dx
                ts=str(datetime.datetime.now())[:19]
                r_x=[ts,dx,rt]
                queueLock.acquire()
                q.put(r_x)
                queueLock.release()
            except ValueError:
                    #print dx
                    dx=[]
    
    
    def bag_reading ():
        global readings
        bag_data_time =datetime.datetime.now()
        if len(readings)>0:
             
           try:
               conn=sqlite3.connect('/media/CORSAIR/wh2.db') 
               curs=conn.cursor()
               curs.executemany("INSERT INTO log values((?),(?),(?),(?))", (readings))
               # commit the changes
               conn.commit()
               conn.close()
               print 'write ',len(readings),'  ',readings[-1][0]
               readings=[]
               bag_data_time += datetime.timedelta(minutes=5)
           except sqlite3.OperationalError as err :
               print 'db busy',err
               bag_data_time += datetime.timedelta(minutes=1)  
        return   bag_data_time
    Warning I'm not a teacher

Similar Threads

  1. programming jumping game
    By bokken in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th February 2012, 06:40
  2. jumping out of subroutine with goto
    By helloo in forum General
    Replies: 4
    Last Post: - 3rd January 2012, 10:37
  3. OWIN not jumping to label
    By MOUNTAIN747 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th March 2011, 15:30
  4. A reminder for all Forum Users
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 40
    Last Post: - 6th December 2008, 18:56
  5. Pot reading jumping like crazy!!!
    By champion in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 20th November 2006, 21:24

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