Jump to content

A couple of handy tools for AutoIt coders


Mbee
 Share

Recommended Posts

As I was developing the stuff I posted here: New Multi-Monitor UDF and Applications (moved) ,  I was changing the elements in the tables quite frequently until the final design. One of the irritating things about coding in any language when declaring sequential variables -- especially indices into tables -- is having to manually re-sequence them when an element is added or removed. So I wrote a string processing util wherein the coder simply copies a set of declarations, runs my util, then pastes the result (over the original, once you begin to trust this thing). The resulting output will have the variables numbered in the order in which they appear; i.e., you simply move the variable names around until they're in the order you want, run the tool, and now everything's been renumbered in sequential order.

The variables do not need to be in any particular format other than not using strange delimiters and the like. They will handle all comments, and the variables can be present in any number of lines. In fact, the variables need not actually be assignments or even declarations, but it will not handle any other language keywords or functions and so forth. It's intended just for variables. For example, if you have nothing but variable names without the type keywords or values, this util will return a set of full-length lines (i.e., multiple assignments per line) with everything neat and clean. If the source does contain declarations, such as "Local", "Global Const", etc, the provided output will be declared as well. However, the type of all the declarations will use only the first declaration type (just note that these are text-processing utilities, not full parsers!)

If the first line of text passed in the clipboard is nothing but an integer value, it will be interpreted as the maximum length of any resulting output line. This is so the results will resemble the rest of your code in terms of length of source lines. If the first line is not an integer, it will use the default of 112 characters.

Duplicate variable names will be automatically removed from the output. Just another convenience! 

Examples: Given the following input from the clipboard...

Global Const $iITblHdlIx=22, $iITblNameIx=1, $iITblDescIx=2,
$iIdpiXIx, $iIdpiYIx $iITblIxIx=1100, $iITblLeftIx
Local $iITblIxIx=5, ; Don't worry about the trailing comma!

$iITblWidthIx=6, $iITblHeightIx=7, $iITblLeftIx=8, $iITblTopIx=9
Static $iITblRightIx=       , $iITblBottomIx=1

$iITblCenterXIx

The first utility, ReSequence.exe, will return the following in the clipboard...

Global Const $iITblHdlIx=0, $iITblNameIx=1, $iITblDescIx=2, $iIdpiXIx=3, $iIdpiYIx=4, $iITblIxIx=5
Global Const $iITblLeftIx=6, $iITblWidthIx=7, $iITblHeightIx=8, $iITblTopIx=9, $iITblRightIx=10
Global Const $iITblBottomIx=11, $iITblCenterXIx=12

 

 The second utility is similar, but does not try to number/re-number anything. It simply identifies all the variable names in the clipboard and returns them, one per line, without any other text. I've found this to be useful when documenting function parameters and table-index definitions. It does not recognize the first line of text to be a line-length specification, since all variables will be listed one per line.

So with the same input as above, the second tool, VarList.exe, will return the following...

$iITblHdlIx
$iITblNameIx
$iITblDescIx
$iIdpiXIx
$iIdpiYIx
$iITblIxIx
$iITblLeftIx
$iITblWidthIx
$iITblHeightIx
$iITblTopIx
$iITblRightIx
$iITblBottomIx
$iITblCenterXIx

 

I've ended up using these tools more than I anticipated when I first decided to code them up. You may also find that to be true. Handy little things, these are. Of course, if any bugs or puzzles turn up, please leave me a message any way you wish, whether by posting here (as is usually done) or by PM or whatever. 

I hope you find these useful!

Due to upload limitations here on the forum, I've been forced to upload it to a third-party site with no expiration date. Here is the link:VarUtils Rel 1.0.zip

 

Edited by Mbee
Screwed up posting zip file
Link to comment
Share on other sites

Could you not use Enum for the const list? I use this method during GUI creation and create an array containing the control ids. If I add controls either at the start, end or middle the array element is adjusted.

Global Enum _
        $iITblHdlIx, _
        $iITblNameIx, _
        $iITblDescIx, _
        $iIdpiXIx, _
        $iIdpiYIx, _
        $iITblIxIx, _
        $iITblLeftIx, _
        $iITblWidthIx, _
        $iITblHeightIx, _
        $iITblTopIx, _
        $iITblRightIx, _
        $iITblBottomIx, _
        $iITblCenterXIx

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...