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 apply this 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 - and the plain String Background. These may not be your favorite colors but here's what I'm using right now:
     Dialog Format = #100,100,0  (purple?)
     Dialog Command = #188,0,0  (red)
     Dialog String Background = #255,255,160  (yellow)
     String Background = #242,242,242  (light gray)
Those colors might sound rather odd but the were 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 do something so the %code% section will also have a special background color. Alpha sets the colors between %code% markers to the same as regular code. This is great when editing that section but then it's harder to find the end of that %code% section when scrolling past it to find something after the xdialog. So the AIMS Script Formatter has a button to change all %code% sections in the current script to %code_section% sections so those sections will use the String Background between those markers. NOTE: Changing it from %code% to %code_section% has no affect on how it runs - only on how it looks in the editor.

Additional info:
1. Alpha says they have reached the current limit on how many background colors can be used so they can't provide a different background for the %code% section.
2. Alpha's formatter won't format the code between the %code% sections anyway so changing the %code_section% won't change that. However, the AIMS Script Formatter will format the code between either the %code% or %code_section% markers.

All that lengthy explanation boils down to this:

If you want to edit a script and know that (A) the %code% section of your xdialog(s) is OK and (B) you want to be able to skip past any long %code% sections, just start the AIMS Script Formatter and click the Convert %code% button.

EXAMPLE CODE WITH MY COLORS:

'This shows how my xdialog code looks.
'This is just an example. Obviously it's overly simple because it doesn't make
'sense to change the font face this way when it's only used in one place.

dlg_text = <<%dlg%
{ysize=.3}{units=F}{font=font_face,8,n}{sp};
Put some xdialog stuff here.;
{sp};
{justify=center}<*15OK> <15Cancel>
%dlg%


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

dlg_result = ui_dlg_box( "Title", dlg_text, <<%code_section%
[put your xdialog 'validation/action' code here]
IF something = .T.
   Do something
END IF
%code_section%
)


Note:
Unlike my example, the default is to build an xdialog in one continuous command inside the ui_dlg_box() function. This puts the 'display/text' portion of the xdialog right next to the 'code' secton and having the same (default) 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. Changing %code% to %code_section% accomplishes that when you want to make it 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.