WinPTE.com

 

Run Command

This article describes how to create a user defined command that will let you run a script or a program and capture its standard output as a text file.

A version of this macro included in releases 3.00.445 and prior but its message with the timing would not be visible after running commands that load files. This one works correctly with all commands. This version will be included in the next release.

Macro Features:

Takes the rest of its command line and runs them as a WinPTE command. Combined with the Run Command will let you do rough timing of script execution time.

Instructions:

If the instructions are not clear then you may want to read the Quick Review on the parent page, failing that e-mail support and the instructions will be clarified.

To give it a test flight:

To make it available every time you run WinPTE:

Trying it out

type 'timeit dir' and hit ENTER, you will see the elapsed time it took to run the dir command and load the contents.

You should see the directory listing loaded in a new file (same name as the batch file with a . prefixed to it).

Macro Text

 Line 
       
 8914 
 8915 
 8916 
 8917 
 8918 
 8919 
 8920 
 8921 
 8922 
 8923 
 8924 
 8925 
 8926 
 8927 
 8928 
 8929 
 8930 
 8931 
 8932 
 8933 
 8934 
* File: main.pte, lines 8914 to 8934
 
begindef timeIt 'timeIt'
    [set envir 200][command line]
    [clear command]
    [extract left 200]'= ' * remove the timeit command word
    [extract left 200]'- ' * remove the timeit command word
    [if equal]''[envir 200]
        [error 0b00011101]'syntax: timeIt {any command}'[abort]
    [endif]
 
    [eval]'$201=@system.ticks'
    [execute][envir 200]
    [update 2]
    [set envir 99][concat][eval]'@system.ticks-$201'' ms --> '&[envir 200]
    [error 0b10011110][envir 99]
     
    * just in case the command resets and hogs the error message
    [execute]'def timer=[error 0b00011110][envir 99][execute]\'set timer off\'[execute]\'def timer=\''
    [execute]'set timer 2'
enddef
 
command timeit timeIt  
 
Site Map | Privacy Policy | Contact Us | ©2004 Winpte.com