Ask Dr. DePhobia - Questions and Answers about Clarion

by Jim DeFabia

Published 1997-07-01    Printer-friendly version

Question:

In some places in the Clarion development environment, preceding the entered text with an exclamation point indicates that it is a variable instead of literal text. I noticed that the same functionality is in the prompts for the standard templates. I tried typing in an exclamation point in one of my templates, but it didn't detect the difference. Have I missed something?

Answer:

Yes, you have missed something.

In the development environment, this functionality is internal to the development environment. In the standard templates, template code is mimicking this functionality. Your templates need code to detect an exclamation point and handle those cases. You don't just get it for free, you need to add a bit of code to provide the functionality.

Let's consider a template that does a property assignment to a control's PROP:Text property. In some cases, you want to assign a literal string. In other cases, you want to assign the value in a variable or the result of an expression. The literal string needs to be enclosed in quotes, the variable or expression does not. We could have designed the environment to require you to include the quotes everywhere they are needed, but that is not the TopSpeed way. If you always have to do it, you should never have to do it. The tool does it for you.

To handle both cases in your templates, enclose the statement your template will write inside a #IF structure. For example:

#DECLARE(%ValueConstructed)
#PROMPT('Control',CONTROL),%ControltoAlter
#PROMPT('Value to Assign',@s80),%ValuetoAssign
#IF(SUB(%MySymbol,1,1)='!')
  #SET(%ValueConstructed,SUB(%ValuetoAssign,2,LEN(%ValuetoAssign)-1))
%ControltoAlter{PROP:Text} = %ValueConstructed
  #ELSE
%ControltoAlter{PROP:Text} = '%ValuetoAssign
#ENDIF

In this code snippet, the template code is #DECLAREing a symbol to hold the constructed value of the expression.

Next, it prompts you at design time to provide a Control and the value to assign to that control's PROP:Text.

Finally, it instructs the Application Generator to examine the first character of the symbol, %ValuetoAssign and determine if it is an exclamation point. If it is, the template sets the rest of the value of the symbol into the %ValueConstructed symbol and writes that value into the generated source. If the first character is not an exclamation point, it surrounds the value of the original symbol in quotation marks writes that value into the generated source.

Question:

I have some legacy applications that I want to continue using, but need to write new applications that will share the data. This would be an easy task, but I used some field labels in the legacy data files that are now reserved words (e.g., NEW). I really don't want to write a series of data conversion programs and remake the legacy applications. They are working fine and I would prefer to leave them as they are. Is there anything I can do?

Answer:

Yes, there is a simple answer. In the data dictionary for the new application, provide a legal label for the fields, and use the NAME attribute to point it to the label in the data file.

For example, if you had a field (or file) called NEW (a word made reserved in version 2.0). You would define the file as follows:

MYFILE            FILE,DRIVER('TOPSPEED'),CREATE,PRE(MYF)
RECORD              RECORD
NEWField              STRING(20),NAME('NEW')
                    END
                  END

In the Dictionary Editor, you would provide the legal label of "NEWField' and in the External Name field on the Attributes tab of the Field Properties, as shown below:

Figure 1. Using an External Name keeps field label legal
Using an External Name keeps field label legal

Question:

I have a data file containing names addresses and phone numbers of my clients. I want to print a report that I can insert into an address book that has tabbed dividers for each letter of the alphabet. I have the page size set up correctly, and the report formatted correctly, but I have one small problem. I cannot figure out how to create a page break on each letter of the alphabet. What can I do?

Answer:

When I wanted a report like that I thought it was OVER my head, but then I discovered that OVER was exactly what I needed.

You see, you can declare a field OVER another field. This does not add a field to the file, it merely references a portion of the field it overlays. For example a STRING(1) OVER a STRING(25) references the first character of the longer STRING. In your example, you would create a STRING(1) OVER the field containing last names. To use it in a report, you would create a KEY (or INDEX) using that field as the first component. In my application, I made a key as follows:

InitialKey KEY(+MEM:LastNameInitial,+MEM:LastName,+MEM:FirstName,+MEM:MiddleName),DUP,OPT,NOCASE

I used that key in the Report and made a Group Break on the MEM:LastNameInitial field. I added the PAGEAFTER attribute to the Group Footer. Voilà, a phone book report ready to insert into my divided notebook. Now if I could only get the program to punch the holes for me...

Question:

I want to change the color of the text on a button but have not been able to do it. Can you help me?

Answer:

Well you could buy all your users colored glasses, but that would increase your cost of goods, so we'll use Clarion to make the change.

Clarion lets the operating system draw regular buttons (i.e., those without the icons), and Windows does not directly support font colors on a button. Since Clarion draws buttons which have graphics (i.e., the ICON attribute), the additional functionality of font color support is available when you let the Clarion Runtime Library draw the buttons.

If you want to have color support and not display an icon, you can use a transparent icon that will give you colorization without showing a picture. In fact, EQUATE (ICON:NONE) is provided which places an invisible Icon on a button. Keep in mind that using ICON:NONE is not the same as omitting the ICON attribute.

Here is an example using that EQUATE and red text.

BUTTON('Red'),AT(5,20,39,35),FONT(,,0FFH,),USE(?Button1),ICON(ICON:NONE)

Printer-friendly version

 
 

Search

 

Advanced Search
Topical Index

Related Articles

Subscribe to
ClarionMag

One year: $189

(includes all back issues since '99)

Renewals from $139

Two years: $289

Renewals from $239

More Info

Subscribe Now!

ClarionMag Blog

RSS Feeds

Updates via Email

Enter your Email


Powered by FeedBlitz

Quick Links