June 26, 2008

WinTask - Undocumented Workarounds

As with any tool, there are a few undocumented problems and limitations in WinTask.


Here are some that I know about.  I'll add more as I learn of them.
(last updated: December 30, 2009)

#ScriptAfterTimeout$
#ScriptAfterTimeout$ does not allow you to use a .rob file name containing a space. It works correctly if the .rob doesn't contain any spaces in the file name.

So this will not work:
#ScriptAfterTimeout$="After Timeout"
#ExecTimeout = 20

Pause 30 secs
MsgBox("Ok")
WinTask Tech Support says that the " needs to be doubled:
The " needs to be doubled, so try:
#ScriptAfterTimeout$=chr$(34)+"After Timeout"+chr$(34)
and it will work.
BEGINDIALOG ... ENDDIALOG
In version 3.5a, it doesn't appear that the CAPTION statement works correctly in dialogs.

For example, the titlebar of this dialog won't show any caption, even though it should show "My Caption is Here":

    BEGINDIALOG Dialog 465, 387, 350, 220
    CAPTION "My Caption is Here"
    DEFPUSHBUTTON "&OK", btnOK, 137, 157, 75, 23
    ENDDIALOG

    CallDialog Dialog

The workaround is to remember to use the optional Title$ argument in every CallDialog statement:

    CallDialog Dialog,"My Caption is Here"

Note: This has been fixed in subsequent versions.
Capture$
The <mode> argument in the Capture$() function cannot be a variable.  It must be a constant.

So something like this will not work
var = 0
Capture$("window name",1,var)
It will get the following syntax error:
A number is expected
As a workaround, you could create a function like this and use it in place of Capture$:
Function MyCapture$(window_name$, instance, mode)
Local a$
  Select Case mode
    Case 0
        a$=Capture$(window_name$, instance, 0)
    Case 1
        a$=Capture$(window_name$, instance, 1)
    Case 3
        a$=Capture$(window_name$, instance, 3)
    Case 5
        a$=Capture$(window_name$, instance, 5)
    Case 7
        a$=Capture$(window_name$, instance, 7)
    Case 9
        a$=Capture$(window_name$, instance, 9)
    Case Else
        a$=Capture$(window_name$, instance, 0)
  EndSelect
MyCapture$=a$
EndFunction
MsgFrame
MsgFrame() cannot display an ampersand (&) as part of the text.

So, MsgFrame("A&B",1) will just display "AB"

WinTask Tech Support says to use two & characters instead of one
In the Windows control which is used for MsgFrame/MsgFrameTitle, the & is a special character (keyboard shortcut underlined). So to force the display of this character, you need to double the &
MsgFrame("A&&B",1)
MsgFrameTitle
MsgFrameTitle() cannot display an ampersand (&) as part of the text.

So, MsgFrameTitle("The Title","A&B",1) will just display "AB"

WinTask Tech Support says to use two & characters instead of one
In the Windows control which is used for MsgFrame/MsgFrameTitle, the & is a special character (keyboard shortcut underlined). So to force the display of this character, you need to double the &
MsgFrameTitle("The Title","A&&B",1)

June 22, 2008

Book: High Performance Web Sites: Essential Knowledge for Front-End Engineers




In High Performance Web Sites: Essential Knowledge for Front-End Engineers Steve Souders explains that at least 80 percent of the time it takes to display a web page happens after the HTML document has been downloaded, and describes the importance of the techniques in this book.

From the author:
"After two quick introductory chapters, I jump into the main part of this book: the 14 performance rules. Each rule is described, one per chapter, in priority order. Not every rule applies to every site, and not every site should apply a rule the same way, but each is worth considering. The final chapter of this book shows how to analyze web pages from a performance perspective, including some case studies."

HTTP Overview provides a short description of HTTP, highlighting the parts that are relevant to performance.

Rule 1: Make Fewer HTTP Requests, describes why extra HTTP requests have the biggest impact on performance, and discusses ways to reduce these HTTP requests including image maps, CSS sprites, inline images using data: URLs, and combining scripts and stylesheets.

Rule 2: Use a Content Delivery Network, highlights the advantages of using a content delivery network.

Rule 3: Add an Expires Header, digs into how a simple HTTP header dramatically improves your web pages by using the browser's cache.

Rule 4: Gzip Components, explains how compression works and how to enable it for your web servers, and discusses some of the compatibility issues that exist today.

Rule 5: Put Stylesheets at the Top, reveals how stylesheets affect the rendering of your page.

Rule 6: Put Scripts at the Bottom, shows how scripts affect rendering and downloading in the browser.

Rule 7: Avoid CSS Expressions, discusses the use of CSS expressions and the importance of quantifying their impact.

Rule 8: Make JavaScript and CSS External, talks about the tradeoffs of inlining your JavaScript and CSS versus putting them in external files.

Rule 9: Reduce DNS Lookups, highlights the often-overlooked impact of resolving domain names.

Rule 10: Minify JavaScript, quantifies the benefits of removing whitespace from your JavaScript.

Rule 11: Avoid Redirects, warns against using redirects, and provides alternatives that you can use instead.

Rule 12: Remove Duplicate Scripts, reveals what happens if a script is included twice in a page.

Rule 13: Configure ETags, describes how ETags work and why the default implementation is bad for anyone with more than one web server.

Rule 14: Make Ajax Cacheable, emphasizes the importance of keeping these performance rules in mind when using Ajax.

Deconstructing 10 Top Sites, gives examples of how to identify performance improvements in real-world web sites.
The book is a quick read containing some good hints and tips.  Many are fairly easily investigated and implemented in most companies.

Seemingly out of place, however, is Rule 2: Use a Content Delivery Network.  While it's certainly a good way to improve performance, it's not something every company can afford.

Overall, an interesting book.

June 10, 2008

WinTask - Getting the Path to Your Script

Command$(0) returns the full path and file name of your script.

So this:
Left$(Command$(0),InstrRev(Command$(0),""))
will extract the path to your script from Command$(0).

See for yourself:
msgbox(Left$(Command$(0),InstrRev(Command$(0),"")))

WinTask - Initializing a String Array

You can initialize each element in a string array with the same value in one line as follows:
Array$() = "value"
And of course you can initialize a string array to all nulls this way:
Array$() = ""
To assign different values to each array element, you could use something like:
SplitIntoArray("v0,v1,v2,v3,v4,v5,v6,v7,v8,v9",Array$(),",")