View Single Post
  #4   Spotlight this post!  
Unread 24-06-2002, 02:26
archiver archiver is offline
Forum Archival System
#0047 (ChiefDelphi)
 
Join Date: May 2001
Location: Pontiac, MI
Posts: 21,214
archiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond repute
Re: Ahh! Program trick confusing!

Posted by Travis Hoffman at 03/18/2001 9:00 AM EST


Engineer on team #48, Delphi E.L.I.T.E., from Warren G. Harding High School and Delphi Automotive Systems .


In Reply to: Ahh! Program trick confusing!
Posted by Gui Cavalcanti on 03/17/2001 1:01 PM EST:



: OK... wait. I've just read that entire segment dedicated to the extended programming trick that involves multiple programs.. but i'm confused. Do you add subroutines before or after the "RUN" command line in your programs? For example, i'll give you the following..

It depends on your definition of "subroutine". All subroutines within a particular program called with the GOSUB instruction from the program body must be placed AFTER the RUN statement in that program:

'Program 1 body

pump = on
GOSUB Pumptimer

RUN 2

'Pumptimer subroutine

Pumptimer:
'pumptimer code
RETURN

If, by "subroutine", you are instead referring to a smaller piece of your original unmodified program body that you placed in one of the subprograms of the new method, then this code should go BEFORE the RUN statement, just like any other regular code:

Original Program:

:Initialization Code

MainLoop:

:SERIN
:LIGHT CODE
RIVE CODE
:LIFT CODE
:SEROUT

GOTO MainLoop
*************************************

New Method:

rogram 0
:Initialization Code
:RUN Program 1
:------------
rogram 1
:SERIN
:LIGHT CODE
:RUN Program 2
:------------
rogram 2
RIVE CODE
:LIFT CODE
:SEROUT
:RUN PROGRAM 1 'Equivalent to GOTO MainLoop
:------------

You can see how program execution flows in exactly the same manner as the original program. The only difference is you have boatloads more program space to work with

Also, shouldn't PROGRAM 0 be your first program? I could be wrong, but I thought it had to be. Program 0 is where you modify the Basic Stamp directive to include the names of programs 1-7. I have my initialize code in program 0. I then loop back to program 1 at the end of my highest-numbered program.

Travis











: Program 1:
: Initialization
: SERIN command
: light subroutine

: RUN Program 2:
: -----
: Program 2:
: Initialization
: Major subroutines

: RUN Program 3:
: -----
: Program 3:
: Initialization
: minor subroutine
: SEROUT command

: RUN Program 1:
: -----

: Is that right, or did I really screw something up?

: -Gui Cavalcanti
: 422 (Mech Tech)


__________________
This message was archived from an earlier forum system. Some information may have been left out. Start new discussion in the current forums, and refer back to these threads when necessary.