WinPTE.com

 

Batch Mode "Find Missing }" for ProvideX

 

Macro Features:

Instructions:

If the instructions are not clear then you may want to read the Quick Review on the parent page.

If the files you want to check are p-code files then you need to convert them to text first. This macro works only on text files and the automatic conversion facility from p-code to text will not work for this macro.

It is recommended that you keep this macro in a separate file and only load it when you want to batch verify files. Any new files that you are editing in WinPTE will be checked for this error when you save (Enable the option on the ProvideX context menu). So this macro will only be useful to your older files:

Now you need a list of files (preferably full path specified, and any paths with spaces must be enclosed in double quotes). The easiest way to generate a file list is to execute (on the WinPTE command line, as usual):

edit /L filePathWithWildCards

The command will generate a list of WinPTE edit commands in a file called ".editlist", with a line for each file that matched the file name pattern. List of files will look similar to:

Sample File List:

 Line 
       
    1 
    2 
    3 
    4 
    5 
 File: .editlist, lines 1 to 5
 
     
    edit D:\Data\Src\WinPTE\SampleSource\PVX\ro_class.pvo 
    edit D:\Data\Src\WinPTE\SampleSource\PVX\Pvx_co.pvt 
    edit D:\Data\Src\WinPTE\SampleSource\PVX\pvx_deco.pvt 
      

With the file list displayed press the Alt+4 key and when the macro is done you may have a .errors file (dark red tab). If you don't then the files in the list passed the test. If you do then it will list all files that have missing closing braces and the first line number of the opening brace not matched by a closing brace. The list will look something like this (of course with your files listed):

Sample Result Errors:

 Line 
       
    1 
    2 
 File: .errors, lines 1 to 2
 
    (55): Info : "D:\Data\Src\WinPTE\SampleSource\PVX\ro_class.pvo"(76,26) 
      

 

In the above sample result file ro_class.pvo had an opening brace without a matching close on line 76, column position 26. If you place the cursor somewhere on the file name and hit Ctrl+Shift+O key you will be taken straight to the file line listed in (). You can equally right click on the file name and select "Open File..." from the context menu (first item from the top).

Macro Text

 Line 
       
    1 
    2 
    3 
    4 
    5 
    6 
    7 
    8 
    9 
   10 
   11 
   12 
   13 
   14 
   15 
   16 
   17 
   18 
   19 
   20 
   21 
   22 
   23 
   24 
   25 
   26 
   27 
   28 
   29 
   30 
   31 
   32 
   33 
   34 
   35 
   36 
   37 
   38 
   39 
   40 
   41 
   42 
   43 
   44 
   45 
   46 
   47 
   48 
   49 
   50 
   51 
   52 
   53 
   54 
   55 
* File: findbracefiles.pte, lines 1 to 55
 
     
    begindef findMissingBraceMsg 
        [push cursor][data cursor]
        [top][begin line]
        [do]
            [if not][locate]'{' 's' [exit loop][endif]
            [if not][locate nested]'{''}''s'
                [set envir 200][envir 250]
                [extract left 200]'= '
                [extract right 200]'= '
                [set envir 201][envir 251]
                [extract left 201]'= '
                [extract right 201]'= '
                [set envir 202][envir 241]'"^f"('&[envir 201]&','&[envir 200]&')'
                [exit loop]
            [endif]
        [loop]
        [pop cursor]
        [return][envir 202]
    enddef
     
     
    begindef findMissingBraceInFiles 
        [push cursor][data cursor]
        [top]
        [do]
            [if blank line][else]
                * if edit preceeds the file name skip it
                [begin line]
                [if string is 8]'edit'[right 5][endif]
                [if string is]'"'[right][endif]
                [clear flag 199][push cursor][call editName]
                [if flag 199][error]'editName failed'[pop cursor][pop cursor][return][endif]
                [set envir 200][call findMissingBraceMsg]
                [toggle bookmark 1]
                [if modified]
                [else]
                    [execute]'!quit'
                [end if]
     
                [pop cursor]
                [if not equal]''[envir 200]
                    * have one in this file
                    [execute]'set debug on'
                    [error 0b1000][envir 200]
                    [execute]'set debug off'
                [endif]
            [endif]
            [if not][down][exit loop][endif]
        [loop]
        [pop cursor]
    enddef
     
    def a-4=[call findMissingBraceInFiles]
      

 

 

 
Site Map | Privacy Policy | Contact Us | ©2004 Winpte.com