Close

November 10, 2016

More code optimisations and a new beta available (v2.0 preview)

As my first official post on this new official website for my add-in, it might be a lengthy one 🙂

Code optimisation(s):

There are several that I’ve discovered, including a variant of the ‘IF’ command that I didn’t know existed.

First

There’s the condensation of a line of code. I’ve done this before in previous “how can I shrink the code” runs, but due to some “copy & paste coding”, I’d got lazy and had forgotten that I should be doing this.

My Old Code:
CheckProtection
If blnProtected = True Then
 Exit Sub
End If
The New Code:
CheckProtection
If blnProtected = True Then Exit Sub

That’s three lines of code into one.

Second

This is the new IIF function that I never knew existed in VBA. It is very similar to the IF function that can be used in Excel formulae in that you store a result from a test, based on whether the answer is true or false. I do a *lot* of these kinds of tests in my code, mostly within the generation of the list box contents for the various Inspector-type tools.

My Old Code:
If .Rows.WrapAroundText = True Then
 strWrapAround = "Y"
Else
 strWrapAround = "N"
End If
The New Code:
strWrapAround = IIf(.Rows.WrapAroundText = True, "Y", "N")

That’s five lines of code into a single one. That’s going to help shave quite a few kilobytes off the size of the final release of v2.0 when I’ve gone through the code and fixed them all.

New beta:

There is a new beta available (v2.0 preview) which can be downloaded via the DropBox links on the Beta page. I completely forgot to update the GoogleDrive links, but I will fix that tonight. This will be the version which will have some, but not all of the code optimisations as mentioned above. All being well, there will be a noticeable difference in the size of the release version, compared to this beta.

Download, install and let me know via the Trello board if there are any changes needed.


Fatal error: Uncaught Error: [] operator not supported for strings in /home/mikestoo/public_html/wp-content/themes/layerswp-master/core/helpers/post.php:62 Stack trace: #0 /home/mikestoo/public_html/wp-content/themes/layerswp-master/partials/content-single.php(79): layers_post_meta(322) #1 /home/mikestoo/public_html/wp-includes/template.php(724): require('/home/mikestoo/...') #2 /home/mikestoo/public_html/wp-includes/template.php(671): load_template('/home/mikestoo/...', false) #3 /home/mikestoo/public_html/wp-includes/general-template.php(168): locate_template(Array, true, false) #4 /home/mikestoo/public_html/wp-content/themes/layerswp-master/single.php(20): get_template_part('partials/conten...', 'single') #5 /home/mikestoo/public_html/wp-includes/template-loader.php(78): include('/home/mikestoo/...') #6 /home/mikestoo/public_html/wp-blog-header.php(19): require_once('/home/mikestoo/...') #7 /home/mikestoo/public_html/index.php(17): require('/home/mikestoo/...') #8 {main} thrown in /home/mikestoo/public_html/wp-content/themes/layerswp-master/core/helpers/post.php on line 62