Page 1 of 1

Linking two programs

Posted: Mon Jan 16, 2006 4:20 pm
by Pete
Have at it, guys!
name: Russell L. Meyers

Comments: Hi Pete,

Is it possible to link a two programs together e.g., one program which is a Transportation Planner and the other is a Transportation List. Can you place a link between the two so you don't have to execute each one separately. Would I have to make a menu within the Transportation Planner executing the Transportation List so that it gathers the database file which has all the information in it from the Transportation Planner program. I hope I didn't confuse you. You see, the information of the Departure, Destination and so on is in the database files called Tranplan.db which is opened by the Transporation List program and then printed to the screen or printer all the information that is in that database file. I'm just trying to figure out if I can just use one program to enter the data and then list it. Just curious.

Thx. Russ ;-) Happy Programming!

Posted: Tue Jan 17, 2006 5:01 am
by MystikShadows
for this example I'll assume the following.
  • The database is in the same directory as the two executables.
    I'll omit any details on how tranplan.db is written or loaded.
    That you have the source code of both programs.
    That you want to do this in QB
Once the transporation planner has written the file you can simply, after that, enter a SHELL "tranlist.exe" at the end of the code and the second program should execute as it should.

If you don't have the source code, and just wondering how to execute to executables one after the other. You could create a batch file that would have

TRANPLAN.EXE
TRANLIST.EXE

And that would execute the programs. All you'd have to do is execute the batch file instead of the exe.

Linking Programs

Posted: Tue Jan 17, 2006 2:17 pm
by Zim
In addition to Shell, you can also use the Chain statement, or the Run statement. Of course, this only works if you have the source for each program and you can modify and re-compile them.

"Shell" will simply hold the current program in memory and allow the operating system to begin execution of the other program. When finished, the operating system will return to the next line in the original program.

"Run" will cause one basic program to terminate and execute another. There's no coming back. The advantage is that all memory used by the first program is freed up to be used by the second.

"Chain" is like run, but even more interesting. You can have arrays and variables dimensioned in a "common" area such that when the second program is started it has access to the values stored in those variables.

Years ago I worked in a dialect of Basic on the HP4000 mini-computer. That BASIC had an "Invoke" statement that executed another BASIC program as a subroutine. I wish QB had something like that! You can fake it with "Chain" however.