Execute or Print Windows File |
Top Previous Next |
This function allows you to either execute a Windows file or print it. Windows associates files extensions with applications, so for example, when you double click on a .DOC file, Windows knows that you want to launch Microsoft Word to view the file. You can also use this function to launch other Windows applications by using the .EXE extension.
This escape sequence accepts embedded environment variables for the file name. Example To execute Word on the file "C:\My Documents\Hi There!.doc": PRINT CHR$(27);CHR$(12); PRINT "O"; PRINT "C:\My Documents\Hi There!.doc";CHR$(0); INPUT "";A$ ! wait for ZTERM to finish
To print the same file: PRINT CHR$(27);CHR$(12); PRINT "P"; PRINT "C:\My Documents\Hi There!.doc";CHR$(0); INPUT "";A$ ! wait for ZTERM to finish
To launch another copy of ZTERM: PRINT CHR$(27);CHR$(12); PRINT "O"; PRINT "C:\Program Files\COOL.STF\ZTERM 2000\ZTERM32.EXE";CHR$(0); INPUT "";A$ ! wait for ZTERM to finish
A cool use for this function is to generate a file on the host computer, automatically send it over to the PC and then launch an application associated with the file generated. Say for example you have report that is generated with AlphaBASIC. Like most reports, it contains columns of information: OPEN #1,"BORING.LST",OUTPUT PRINT #1 "Sample Report - Generated by an AlphaBASIC program" PRINT #1 PRINT #1 "Counter Random #1 Random #2" PRINT #1 "------- --------- ---------" PRINT #1 FOR I=1 TO 10 PRINT #1 USING & "####### 0.####### 0.#######" & ,I, RND(1), RND(1) NEXT CLOSE #1 XCALL SPOOL ....
If you have a little knowledge of HTML and are using ZTERM, you can generate the report in HTML, automatically transfer it to the PC and then launch the web browser and point it at the file. Try cutting this program out to a file, transfer it over and give it a try - the result is very cool! OPEN #1,"SYS:COOL.HTM",OUTPUT PRINT #1,"<HTML>" PRINT #1,"<TITLE>COOL.STF Corportation</TITLE>" PRINT #1,"<BODY BGCOLOR=FFFFFF>" PRINT #1,"<H1>Sample Report - Generated by an AlphaBASIC program</H1>" PRINT #1,"<TABLE BORDER>" PRINT #1,"<TR BGCOLOR=DDFFDD>" PRINT #1,"<TH>Counter</TH><TH>Random #1</TH><TH>Random #2</TH>" PRINT #1,"</TR>" FOR I=1 TO 10 PRINT #1,"<TR BGCOLOR=FFFFDD>" PRINT #1,"<TD ALIGN=RIGHT>";STR(I);"</TD>"; PRINT #1,"<TD>";RND(1) USING "0.#######";"</TD>"; PRINT #1,"<TD>";RND(1) USING "0.#######";"</TD>"; PRINT #1,"</TR>" NEXT PRINT #1,"</TABLE>" PRINT #1,"</BODY>" PRINT #1,"</HTML>" CLOSE #1 PRINT CHR$(27);CHR$(1);CHR$(127);"0"; & "SYS:";CHR$(0); &
PRINT CHR$(27);CHR$(1);"0SYS:COOL.HTM";CHR$(0);"C:\COOL.HTM";CHR$(0); INPUT "";A$ PRINT CHR$(27);CHR$(12);"OC:\COOL.HTM";CHR$(0); INPUT "";A$
You can optionally provide parameters if you use this sequence to launch an executable file. To do this, terminate the name of the file with CHR$(1) rather than CHR$(0) and then send the parameters followed by CHR$(0). For example: PRINT CHR$(27);CHR$(12); PRINT "O"; PRINT "C:\My Programs\MyProg.exe";CHR$(1); PRINT "/automatic";CHR$(0); INPUT "";A$
In this case, we pass the parameter "/automatic" to the MyProg.exe program. If you use this sequence to launch a file, the parameters are ignored by Windows. This sequence is not supported on Windows CE versions of ZTERM. Also See |