WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Syntax Checker

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Syntax Checker and Other Handy Utilities from Serge

Keywords: 	  syntax checker Allopcodes.wbt Allopcodessorted.wbt  mysortedopcodes.wbt 

The following zip file contains 6 utilities for use in WinBatch Studio.
  
     Zip file contains 5 files:  1) winutils.txt          96K   Utilities
                                 2) readme1st.txt         15K   this file
                                 3) Allopcodes.wbt        12K   See Syntax Checker Utility                    
                                 4) Allopcodessorted.wbt  12K               "
                                 5) mysortedopcodes.wbt    6K               "
 

 CONTENTS:


 A) About and Using the Utilities
 B) Short description of each Utility
 C) Detailed info on each Utility
 D) Installation info


 A)

     About and Using the Utilities

         Of the six Utilities included in this omnibus edition, four (Sort, COMMENTise, Shift
         and Syntax) have previously been released as v 1.x on the WinBatch script
         exchange. All have been upgraded to V 2.0 with an improved and uniform user
         interface, more efficient buffer allocations, and enhancements added.  

         After successful installation these utilities will be accessible via the Popup menus,
         (mouse right click, etc) in an open file in the respective environments, WinBatch Studio.
         It will create a new menu section which will have 6 menu items, one for 
         each of the utilities. A full installation will add about 1200 lines to the 
         Wspopup.mnu files. Extra start up time is
         negligible.

         Each Utility displays its progress in the message status bar at the bottom of the screen.
         This bar can be enabled via the View/Status Bar toggle switch in the command bar at the 
         top of the screen. The information displayed includes the current number of lines (in tens) 
         processed as well as the total number of lines to be processed. 

         Additional information in the status bar refers to the recovery of the original data
         in case the Utility terminates abnormally. Before initiating any processing all 
         Utilities save a copy of the original data in the clipboard. The original data can thus
         be recovered by pressing the Cntr and V keys. During execution all Utilities  
         remove the data to be processed from the screen        
         
         At end of processing the bar displays the start and end time as well duration in
         seconds. Some Utilities add additional information to the bar.

         If no lines or text has been selected by highlighting it, each Utility will process
         all of the open file. Selecting lines or text will restrict processing to the selected
         text/lines.


 B)  Short description of each Utility


     1) Column copy/delete/insert
          copy a column range to the clipboard
          delete a column range and save data in clipboard for further processing
          takes data from clipboard and inserts it into a column
 
     2) COMMENTise
          can insert, shift true semi-colon based comments into WinBatch scripts 

     3) Reformatter (for WIL scripts)
          Reformats a WIL script with proper indentation

     4) Shift Columns
          shifts columns

     5) Sort
          Sorts anything under the sun (nearly)

     6) Syntax Checker (for WIL scripts)
          Basic delimiter checking 
          variable cross-reference list with line numbers
          commands used list
      

 C)  Detailed info on each Utility

   
       Column copy/delete/insert


          This Utility can be used to copy, delete, or insert data into columns. A panel is
          displayed before each operation and is used to define the range of columns to be
          processed/operated on.

          The copy command will simply copy the range of columns defined to the clipboard
          for further user initiated processing. For example, to copy columns 1 to 10 and later
          insert them between column 80 and 81.

          The delete command works similarly to the copy command, except that the specified
          range of columns will be deleted. Again, the deleted data is saved in the clipboard
          for further processing. 

          The insert command inserts any data in the clipboard into the consecutively-numbered
          colunn range. This operation works on a line by line basis. Each line in the clipboard
          is inserted into the affected line in the open file between columns x and x+1. The @crlf
          comamnd of each inserted data is removed if present. Inserted data retain their @crlf if
          they are appended to a line. Lines with less columns than specified are  padded with
          blank spaces.

          A simpler way of describing this command is to set up 10 lines containing A-Z and 
          manipulating it by copying, deleted and inserting single or a range of letters.
        

       COMMENTise


          This Utility can be used to align all comments found in a WIL script to a particular
          column, or to just insert a semi-colon at this column. A specified minimum column 
          number is used to limit the collection range of semi-colons for realignment. Any 
          semi-colon within the limit column is left untouched. In all circumstances where
          a semi-colon is required, COMMENTise will ensure that at least one blank separates
          the body of the statement, however long, from the semi-colon.

          The COMMENTiser will only operate on real semi-colon comments. A literal strings
          containing a semi-colon is ignored. Selecting COMMENTise via the Popmenu and
          holding down the Shift key at the same time will insert a semi-colon at the 
          specified column into a/all blank line. Blank lines are normally exempted from
          comment processing.

          The selected minimum and current comment columns are remembered across restarts 
          by entries in a private ini file. By default this is called 'editfunctions.ini' 
          and resides in the WinBatch\System directory. The default minimum
          and comment columns are 20 and 60, respectively. The filename/location is also
          displayed in the column request display panel.


       Reformatter (for WIL scripts)


          The Reformatter Utility will restructure or indent any script starting in a specified
          column. This can be changed and is remembered across restarts. See COMMENTise for
          file location details. The filename/location is also displayed in the Reformatter
          request display panel.

          This Utility will report any invalidly-used ENDIF's and single statement versus
          structured IF conflicts.
          Requesting column 0 will force ALL lines to start in column one.


       Shift Columns 


          This Utility can be used to move a columns left or right a specified number of 
          columns.
  

       Sort


          This Utility can be used to sort data in ascending or descending order, starting
          at column x, with a sortkey or width y. If a line is greater then the maximum line
          length specified the following will occur. In addition to aborted the sort, the
          original data will be restored, and an error message produced displaying the line
          in error. 


       Syntx Checker (for WIL scripts)


          The Syntax Checker can be used in four different ways to process a WILL script:

               1) If your script contains two dozen or fewer statements use Mark 1 eye
                  balls; its quicker. If more than 50, read on.
               2) simple or basic delimiter error checking
               3) produce variable cross-reference list
               4) 3 and to produce a command used list


            1) This option does a simple check for equality in IF THEN statements. It
               attemps to verify that == is used instead of =. Although not foolproof,
               just a few lines of codes, it's been surprising effective in reducing
               my 3069 error count. The other basic check performed is to ensure that
               delimiters at least occur in pairs. Basic, yet highly effective. Shades of
               90%/10%. In both cases a panel is presented allowing instant corrections.

            2) This option produces a cross-reference listing of all variables found, their
               use count, and their line location. It determines the designation 'variable'
               by process of elimination. First, it eliminates or deletes all delimiters,
               literal strings, and comments. It then interrogates a file containing valid
               WIL commands, function names, and keywords. The remainder MUST be variables.

               The list produced in alphabetical order is displayed at the end of the
               selected text on the screen. An example is shown below. As can be seen in
               the example, 'variables' BinaryIncr4 and BinaryPeek4 are included in the
               variables list because the command file has not yet been updated.

               100% efficient in detecting unused variables, misspelled variables and other
               bug-inducing anomalies. An absolute must have variable documentation
               facility. 

               The constant fn="f:\winbatch\mysortedopcodes.wbt" in Syntax Checker
               is currently used to point to the command file. If missing, a dummy/buffer
               is allocated during processing, which can result in a fairly long list
               of strangely familiar-looking 'variable' names.

               Command files included in this zip file are:

               Allopcodes.wbt        12K     nearly all command                   
               Allopcodessorted.wbt  12K     nearly all command but sorted
               mysortedopcodes.wbt    6K     reduced list, shorter run time


                   Example of variable list produced using the BinaryHashRec example from
                   the WIL Reference Manual, and the commands used list option.
     
                     Variables               (times used) & line number
                      acount                       (2)    33 35
                      afruit                       (4)    16 17 32 35
                      BinaryIncr4                  (1)    18
                      BinaryPeek4                  (1)    33
                      countoffset                  (4)    11 18 20 33
                      countsize                    (3)    8 9 20
                      fruitcount                   (2)    6 16
                      fruits                       (3)    5 6 16
                      hash                         (10)   14 17 18 20 25 26 29 32 33 37
                      nameoffset                   (2)    10 17
                      namesize                     (4)    7 9 17 32
                      offset                       (13)   17 18 21 23 24 26 29 31 32 33 34
                      recsize                      (6)    9 13 17 20 26 34
                      Report                       (4)    22 35 38
                      tableentries                 (2)    12 13
                      tablesize                    (3)    13 14 23
                      x                            (1)    15
                     
                     Commands used
                      @ascending 
                      @crlf 
                      @fwdscan 
                      @word4 
                      binaryalloc 
                      binaryfree 
                      binaryhashrec 
                      binaryindex 
                      binarypeek 
                      binarypeekstr 
                      binarysort 
                      break 
                      else 
                      endif 
                      endwhile 
                      for 
                      if 
                      itemcount 
                      itemextract 
                      message 
                      next 
                      random 
                      strcat 
                      then 
                      to 
                      while  

                                                          
            3) Option three can addionally produce a list of all WIL 'static' variables
               used.
               
     
 D)    Installation Info
 
               
          If certain Utilities are not required they can be edited out of the main file.
    
          1) Back up the Wspopup.mnu in the WinBatch\System directory as *.bkp in the same directory.
          2) In WinBatch Studio open the respective *.bkp file and save as *.new
             immediately without performing any edit functions.
          3) With the open *.new file, open the file containing the Utilities.
          4) Select all and press Ctrl+c to copy the Utility file onto the clipboard.
          5) Return to the *.new file and select the insertion point. A suggested place 
             might be the blank line between wEdUndo() and ;Redo in the case of the 
             Wspopup file. See extract below. A similar possible insertion point can be 
             found in the Wepopup file.

                         
                         _Undo              ; Undoes the last editing action
                             wEdUndo() 
                         
                         ;Redo              ; Redoes the last editing action
                         ;    wEdRedo()
                         _Keyword Lookup      \ +{F1}         ; Load help topic for word at cursor
                                 call(strcat(DirHome(),"wshelp.dll"),"KEYWORDHELP")


          6) After selecting a/the suitable line, place the mouse cursor on it and left
             click. Press the home key and the cursor should now be column one of the
             blank line. VERY IMPORTANT. 
          7) Press ctrl and v keys and the Utility file will be stored at the insertion 
             point. 
          8) Ensure that the underscore is in column 1, the C of Column in column 2, and 
             the next few visible lines in column 5.
          9) Save the file, still as *.new, and quit. 
         10) In Explorer rename the current *popup.mnu file as *.old.
         11) Rename *.new as *popup.mnu and restart the application. 
         12) The Utilities should now be available.


End of Readme1st.txt

To Download the zip file: Serge's examples


Article ID:   W14401
Filename:   Syntax Checker and Other Utilities from Serge.txt
File Created: 2017:08:29:11:08:48
Last Updated: 2017:08:29:11:08:48