Designed to Help You Run Your Business More Efficiently.     
Home  |  About AIMS  |  Contact Us  

  • Clients

  • FAQs

  • Programs

  • Tips

  • Fees

Script Formatter Hint

Version 119 of the AIMS Script Formatter adds a new feature that is a sort of combination Hint/Update. The update is only useful if you want to take advantage of the Hint.

Here's the Hint part:

If you write lengthy xdialog boxes, it can be difficult to tell where the xdialog begins and ends. One method is to put the xdialog into its own function and call the function. This works well if you're thinking ahead but I sometimes find myself starting with a small xdialog and adding to it, then adding to it some more until it eventually gets quite large. Usually this will also involve a rather extensive %code% section to validate results before closing the xdialog. This is OK until I come back a few weeks or months later to edit something else and have to skip past the xdialog box but have to do some searching in order to find the end of it.

A5 does provide another solution to this problem - changing the colors for the xdialog script sections. Changing the background is especially important. To change the colors, go to View / Settings / System / System Colors / Editors / Code. Then change the settings for the three Dialog settings - Dialog Format, Dialog Command, and Dialog String Background. These may not be your favorite colors but here's what I'm using right now:
     Dialog Format = #100,100,0
     Dialog Command = #188,0,0
     Dialog String Background = #255,255,160
These aren't exactly my favorite colors either - they were only chosen to make the xdialog section stand out and be readable. (see example below.)

Here's the Update part:

So, what does all this have to do with the script formatter? Well, the Dialog Colors only affect that portion of a script that is between the %dlg% tags so we want to be able to use the %dlg% tags around the 'code' section as well as the 'display/text' portion. Even though the default is to use %code% tags to delimit the code section of an xdialog, there is nothing in A5 to keep you from using %dlg% tags instead. Using %code% is just a convenient way to 'separate' that section from the 'dlg' section. The problem is that normally anything between %xxx% tags should never be reformatted so the AIMS Script Formatter was designed so it would not reformat anything between %xxx% tags unless it happened to be %code% tags. Since we now want to use %dlg% tags to delimit the 'code' section and still be able to reformat the code section, there needs to be a way to identify a 'code' section even when using the %dlg% tags. To do this, the formatter now looks for 'code on the first line after the <<%dlg% tag.

All that lengthy explanation boils down to this:

If you want to use the %dlg% tags to delimit the 'code' section of an xdialog in order to get the special background color and still allow the script formatter to format the dialog code, add a 'code comment line immediately after the <<%dlg% tag as in the second part of this example:

dlg_text = <<%dlg%
{ysize=.3}{units=F}{font=font_face,8,n}{sp};
{line=1,0};
<*15OK> <15Cancel>
%dlg%


dlg_text = stritran( dlg_text, "font_face", "Arial" )

dlg_result = ui_dlg_box( "Title", dlg_text, <<%dlg%
'code
[put your xdialog 'validation/action' code here]
%dlg%
)


Note:
The default is to build an xdialog in one continuous command. This puts the 'display/text' portion of the xdialog right next to the 'code' secton and having the same background on both makes it harder to tell where the 'display/text' portion ends and the 'code' section begins. However, many developers who write (or modify) their own xdialogs are now putting the 'display' section and/or 'code' section of the dialog definition outside the ui_dlg_box() command itself because this gives the developer the ability to manipulate the dialog string to handle various options - see example above. In this case, the two sections are already separated and it's more important to identify the start and end of the overall xdialog box. By delimiting both sections with %dlg%, both sections will now have an "xdialog background" and it will be easy to see the overall limits of the xdialog.



AIMS DataCom, Inc. - Custom Database Applications
This site created and maintained by Cal Locklin, CALocklin@chartermi.net, using 1st Page 2000.   Last update:  11-Oct-05
This site may be freely linked to but not duplicated in any fashion without prior written consent.