Navigation:  Reference > Commands >

Chain

Print this Topic Previous pageReturn to chapter overviewNext page

 

Use this command to execute another TAS Professional program.

 

CHAIN f/c/e Required - The name of the program to run.  This needs to include the path also, if any.

 

WITH f/c1,f/c2,...,f/cx  A list of field values to be passed to the program.  The receiving program can test for these with the PARAM (Parameters) command.

 

       NOTE:  You may pass only actual fields or constants; expressions are not allowed.  Also, see the RESET option in the DEFINE command about another way of doing this.  For those who are familiar with previous versions of TAS Professional, passing constants was not allowed.

 

NEWRUNTIME If this is specified a new instance of TASRUNTIME will be created before the program is run.  This will allow the user to continue running other programs rather than being tied up waiting for this program to finish.  The perfect use of this option is when you're printing a large report that will take a long time to complete and wish to have it execute in the background.

 

       NOTE: there are two things to consider here If you Launch a program with new runtime the chain command act's like a GOTO Absolute without using newruntime the chain command becomes a gosub

COMMENTS

The original program, upon returning from the "chained-to" program, will continue execution at the next line.  All data files previously opened will still be so, and all data will be available (except for that data appearing strictly in the chained-to program).  There is no limit as to the depth, i.e., how many programs can CHAIN, one to the next.

 

If you include WITH fields/constants in the command the receiving PARAM command in the CHAINed to program can use (and, in the case of constants, must use) different field names.  See example below.

 

NOTE:  If the program you are CHAINing from is specified as the MainMenu (see Compiler Directives) then when you CHAIN to another program you should immediately do a RET.  When the CHAINed program exits it DOES NOT return to the MainMenu program.  This allows you to CHAIN to multiple programs without the control listed below.

 

NOTE:  When a 'normal' (not MainMenu) program CHAINs to another, the user cannot access the original program until the CHAINed to program exits.  This protects the programmer from having to worry about what the user might do with the original program before returning from the CHAINed program.  It's almost like the CHAINed to program is loaded in modal form, but only for the previous program.  It doesn't effect any other programs that have been loaded, unless they're previous in the same chain.

 

NOTE:  You must not execute a CHAIN command from within a UDF.  If you do, the program will not return to the proper location, and you will probably get an AV (Access Violation).

 

NOTE:  You must not execute a CHAIN when you are in a PRE event.

 

NOTE:  If you have specified the NEWRUNTIME option that program will continue running until you QUIT within the program or until the user closes the screen (if appropriate).

 

NOTE:  You can include the WITH option when you have specified NEWRUNTIME, however, the RESET and ROPEN commands will have no effect since this is a totally separate instance of TASRUNTIME.

 

NOTE: FAQ  Question : Is there a way to cancel/ESC once you have loaded SET_PRINT_BUFF command as it seems traps cease to operate after this command. What I am trying to do is abort from initial stages of a print job.

 

REASON : The reason for this problem is that when you're executing lines in a TAS Pro program the user cannot have any input. This includes keyboard and form (clicking on buttons, etc). This is why you don't want to create a loop that doesn't end or RET . If you do, the user will never gain control again.  

 

The option: NEWRUNTIME. When this option is included in the chain command it will actually create a new instance of TASRUNTIME.EXE. You can still pass values to the program using the WITH option, however, you cannot pass values back, or access files already opened, etc. And, when the program is finished (either reaches the end of processing and you use a QUIT command, or the user closes the form)  The new instance of  TASRUNTIME is automatically closed also. IN FACT, (VERY IMPORTANT!!!) by making this change your users will now be able to click on buttons on the form, etc. So, if you want to put a Cancel button on the form, you can.

 

So, what's the downside? Besides not being able to access data in other programs or previously opened files, and perhaps, running out of memory or resources, is that the form that is displayed on this new instance can get hidden behind the current main menu (depending on the size of the main menu form). Obviously, the new instance form can be moved anywhere on the desktop.

 

SEE ALSO

PARAM

 

EXAMPLE CODE

//in Program A you might have:

x = y+5

chain 'C:\TEST PATH\PROGRAMB' with x,'ABC',999

ret

 

//in Program B you would have:

       PARAM z, s, i

 

chain 'bksoa.rwn' with bkarcust.code

 

chain 'bksoa.rwn' newruntime with bkarcust.code

 

More information

RUN

This is a TAS Professional 3.0 command here for compatibility.  The preferred method is to use the

CHAIN command.

 

RUN program_name

program_name - f/c/e - Required - This is the name of the TAS Professional 5.1 program to

be run.  It must have been previously compiled.  You can specify the path if desired,

otherwise, it should reside in your current sub-directory.

COMMENTS

This is the equivalent of the TAS Professional 3.0 command Run.  The run command can be used to run a program in the same windows I believe this will only work with old RUN type program I di not thing you can use this to run a RWN.

 

 

 


Page url: http://www.cassoftware.com/tas/manual/chain.htm