You would use this command to execute a Windows .EXE program from within your TAS Professional program. This command is like a shell command and can use windows program associations.
|EXEC f/c/e||Required - This is the name of the program to be run. This must include any path if applicable.|
|WITH f/c/e||The program will pass this value as the 'tail' of the command line. For example:|
|WAIT||This option will stop running and wait however it will not shutoff visual events on your screen if you want to use this you will need to use the check_wait() function.|
//EXAMPLE 1 This is the command using the with option
EXEC 'WORDPAD' WITH 'TEST.SRC'
ret // would be the equivalent of executing the program WORDPAD.EXE and passing a single parameter of TEST.SRC.
// End EXAMPLE1
// EXAMPLE2 \ for wait and wait_check()
// If the user was to click the exit button before you were done and you do not protect your programming
// like this you will get an error because the program would be gone.
EXEC 'WORDPAD' with 'TEST.SRC' WAIT
if wait_check() > 0
msg 'you have not finished your editing yet you can not exit from this program.'
// END EXAMPLE2
//EXAMPLE3 use the mail to program assocuation in windows.
// lets say you want to put a button on your program to email someone.
//EXAMPLE4 maybe you want to have a button call up your website.
//EXAMPLE5 maybe you want to have button execute a program with file windows file association. This example
// would open the zip file in windows.
//Here is how you can get it to wait
exec '.\sample\testbatch.bat' wait
if wait_check() <> 0
goto testexec.click // Program will loop until batch file is done.
Control returns to the TAS Professional program immediately. It does not wait for the other Windows program to finish executing unless you use the wait option in the command.
NOTE: You can pass a P type pointer (or any other numeric value) to the program you're running. It is automatically converted to an alpha string before it is passed.
NOTE: You can only execute another Windows program with this command. It will not execute a DOS program or command. However you can execute DOS programs from a PIF file.
NOTE: Windows no longer uses .pif so to control a cmd window you can use a .lnk file.
A file shortcut in Microsoft Windows is a small file containing a target URI or GUID to an object, or the name of a target program file that the shortcut represents. The shortcut might additionally specify parameters to be passed to the target program when it is run. Each shortcut can have it's own icon. Shortcuts are very commonly placed on a desktop, in an application launcher panel such as the Windows Start menu, or in the main menu of a desktop environment. you can use tas professional to execute one of these files. Shortcut files can be used to launch programs in minimized or maximized window states if the program supports it.
You say why would I need to do this in some cases you do not have control of the program your trying to run an example was We had to execute this cmd program and every time it ran it would pop up a cmd window to prevent this I used the .lnk file to tell windows to run this program minimized.
NOTE: one other feature of the EXEC command is that it will use windows file association.
This sample uses both a batch file and a .link file
define fnpath type a size 250
define tiffH,tiffW type r size 10 // going to use a record type i think this info is an Integer just in case we will use a rec type
define linedata type a size 250
define linenum type I
define findX type I //this is the pos of the X in the string
define ok type I
define logical type L
func get_tiff_data fnpath
TiffH = 0
TiffW = 0
Logical = .f.
linenum = 0
if .n. FILE_EXISTS(fnpath)
msg 'Image file not found!'
if .n. FILE_EXISTS('Exiftool.exe')
msg 'Exiftool.exe is missing!'
set_object get_form_name() property 'no_refresh' value .t.
// to keep from displaying a cmd box we exec this tiffbatch.lnk
// the link exicutes the get_tiff_info.exe
// this is a compiled batch file. the tifbatch.lnk file is set to run minimized !!!
// YOU WILL NEED TO EDIT THE PROPERTIES OF THIS tifbatch.lnk file TO USE THE RIGHT TARGET
// REM SRC for get_tiff_data.exe
// exiftool %1 > c:\temp\temptiffdata.txt
exec 'tifbatch.lnk' with fnpath wait
WHILE WAIT_CHECK() > 0
// WE HAVE TO WAIT TO GET OUR DATA !!!
// now we have a temp data file we can read with TAS... We used a string list to load the data then parse it out to the data we needed.