Macro Features:
- Takes a list of ProvideX source code text files, one file per line. If the files contain spaces in the path then these file paths should be enclosed in double quotes.
- Will open every file in the list and if it has an opening brace without a matching brace it will add the path and line number to the .errors file
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:
- Select and copy the Macro Text below to the clipboard and add it to a new file in WinPTE.
- Save the file in the WinPTE installation directory (this is not a requirement but will avoid the need to type in the full path for the macro file when you want to load it). You may want to use the findBraceFiles.pte file name if you wish.
- Execute the macro command below (type the text on the WinPTE command line and hit ENTER):
macro findBraceFiles.pte
This will define the Alt+4 key to run the macro on a file list.
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
- Do not leave out the /L parameter this instructs the edit command to create a List of commands instead of loading the files. Otherwise you will load all the files into WinPTE.
- Enclose the file path in double quotes if it contains spaces otherwise the parts separated by spaces will be treated as individual file paths.
- You can execute the edit command with a different path to append to the existing .editlist file or you can specify multiple paths as additional parameters separated by spaces to the same edit command.
- The .editlist file is just another file so you can edit the list of files and remove any that are not ProvideX source text files.
- The macro ignores blank lines so having blank lines between lines listing a file name will not affect its operation. It will also skip the leading edit command if it is present, otherwise it will assume that the first thing on the line is the file path. So feel free to create this list anyway you want.
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]
|