Shop OBEX P1 Docs P2 Docs Learn Events
Multi-Program download — Parallax Forums

Multi-Program download

Daniel M.Daniel M. Posts: 14
edited 2005-01-01 02:38 in BASIC Stamp
hey,
i have written multiple programs to preform different functions with a custom robot i built for school. Does anyone know of a way to load all of these programs at once and write another program that will allow me to choose which one to call with the debug terminal or by the setting of switches? Thanks

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-31 06:16
    Put your menu in slot 0, then -- based on you selection (switches, etc.) -- use the RUN instruction to jump to the desired program slot. When that slot finishes it should use RUN 0 to get back to the menu. I've done this with a couple robots and it works well (note you must have at least a BS2e to use RUN).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Daniel M.Daniel M. Posts: 14
    edited 2004-12-31 18:31
    I have just a BS2, is there another way to do something like that?
  • allanlane5allanlane5 Posts: 3,815
    edited 2004-12-31 18:39
    Sure, just create a 'main' routine that reads the DIP switches (or whatever) to select your program. Then 'GOTO' the appropriate program.

    Note with only 2K Bytes of EEPROM program storage, you'll be fairly limited in how different your programs can be.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-31 18:48
    Sure, there are a number of mechanism to do what you want.· I'd use something like this:

    Main:
      DO
        GOSUB Important_Background_Task
        GOSUB Get_Selection
        ON select GOSUB Task_0, Task_1, Task_2, ...
      LOOP
     
     
    Important_Background_Task:
      
      ' do stuff here that has to happen when you return from a task
     
      RETURN
     
     
    Get_Selection:
     
      ' read switches, etc., to determine what task to run
     
      RETURN
     
     
    Task_0:
     
      ' this will run when select = 0
     
      RETURN 
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Daniel M.Daniel M. Posts: 14
    edited 2005-01-01 02:38
    o, ok. Thank you
Sign In or Register to comment.