KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Placing a "<" in "static text" on a form
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: September 17, 1999

A question that often puzzles people is how to I create a static text expression that looks something like this:

Employees < 20 years old

The problem occurrs because 4D uses the < and > symbols in static text to represent variables. Try this, create a variable named mytext and assign it some value:

mytext := "This is my text"

Place the following static text on a form:

Hello there!

When you view the form you will see "Hello there! This is my text" (Assuming you made the text object large enough.)

You can use this 4D feature in all sorts of places to replace variable static text on a form. It's really handy to have around. On the other hand when you want to place our original text above it doesn't work. Instead you get nothing displaying. This is because 4D is trying to replace what is behind the "<" symbol with the contents of the variable 20 years old. Of course there isn't a variable named 20 years old, so 4D gives up and instead ignores all the text.

Your next thought might be to put on the form and assign my text as follows:

mytext := "Employees < 20 years old"

This unfortumately ends in the same result. I recently saw someone elses solution to the problem.

mytext := "Employees "+Char(220)+" 20 years old"

Unfortunately this person must only use the Macintosh. It does work, but not on Windows. If you work cross platform stay away from any ascii code above 127. They are different from Mac to Windows and even from country to country on Windows. (In fact there is even one country that has three completely different sets of high ascii codes.)

The only solution I have found is to place a Non-Enterable variable on the form instead of static text. If you carefully choose the foreground and background colors and make it plain in appearance you won't be able to tell the difference between real static text and the non-enterable variable.

In the On load form event or somewhere else before the form is shown load the variable with:

mytext := "Employees < 20 years old"

The text will display properly and only you will know the difference. You and thousands of other 4D developers that also know how you accomplished your feat. Shhh! Nobody tell! (End users of course.)