Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Caption option with "=" character 1

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,814
JP
Hi all,
I suspec this is a simple problem, but a bit of pecking hasn't solved it... I just migrated an application from VFP 7 to VFP 8, and I got a surprise by a strange behaviour. I have several labels on a screen which have a value of "=" as their caption. Now, in VFP 8, it complains, "Syntax error". The caption seems to have been converted to look like this: ="="
nothing I do seems to fix the problem. How can I get my = sign to be a label?

(The idea here is, I have [Field1] + [Field2] = [Value])
It's important that I show these "=" signs.


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Hi Scott

This is a problem and VFP 8 is tight in error checking. SInce this is not available at compilation time, the error pops up.

I suggest, you shift that code from caption to the labels init event .
This.Caption = field1 + field2

That will solve the issue.

:)



____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Ramani,
Still a problem. I changed the caption on the form to be "none". This shows "none" in the label. Then, I put:

This.Caption = "="

because I need the caption to have the value of the = sign, I still get the "Syntax Error" Message. I'm trying to illustrate that a string of fields equals a value, so I show each field as a text box, then I put a lable with the value '+', to tie them together, and then a label with '=' and the the total of the fields in another text box. (It's hard to illustrate here, since I can't show what the screen looks like). Any ideas???


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Hi SCott,

I misunderstood your problem.

Try this in the Caption Property place..

=[=]

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Ramani,
Sorry mate, this didn't work either. In fact, even trying to leave the caption property gave me Syntax error. I tried several combinations, and even putting it into the Init event as you suggested before, but I'm still getting Syntax Error. Is there nothing that will simply tell fox, "The next character is to be taken as a character, not a value"? (Any other clever ideas?)


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
The Maniac

In the init put:

This.caption = "="

Or in the Caption put :
="="

Both seem to work for me in VFP8.0


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Gents,
I've tried both of these. I'm still getting the syntax error. I don't know what is going on. If I enter ="=" in the caption property, even as soon as I try to leave the field, I get the message "Syntax Error". When I run the form (with the ! button), I get the message 7 times (one for each instance of the = sign I have on my screen). If I click OK, then the form runs fine. When I exit, I get 7 more Syntax Errors. Maybe I'll just turn this into a graphic...


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Scott, is there any chance that you need to reload VFP8 ?

John
 
Hi scott

I am surprised. It is working for me. Let me walk you thru.. there is some misunderstanding..

1. Go to property window for the Label selected in the form.

2. Click on the Fx button
3. In the resulting window .. type [ = ] .i.e.
square brackets start... [
one space .. then = then one space (just to balance
square bracket end ].
4. Save as usual. It works for me.

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Ramani,
Wow... that is weird. Your suggestion worked! Seems a strange behavior, I would have rather liked if they had MS had just made this rather simple conversion. But at least now, I've got it working! Thanks!


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Mike --

I do not understand the construct you refer to:

Or in the Caption put :
="="


Are you refering to the caption property in property window for the label? If so, what is the meaning of the leading equal sign followed by quoted text? Another in the (almost infinite) list of cool things to know, but can only find out if somebody tells you?
 
jamrnelson

Have you tried it?

If you put '=' in the Caption property of a form, you get just that '=' (with the quotation marks), but if you put

='=' in the caption property of a form you just get the = sign, no quotations and no first equal sign.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
My question was not stated clearly.

What's the leading equal sign for? Why would I use it? What's the purpose? What other uses are there? Is it documented anywhere? (If so, and presuming there's some good reason for me to know about it, I might hope to learn other obscurities of value in the same vicinity.)
 
HI Jam

As I posted in Above thread..

With the caption property or for that matter any property,
If you ,,,
Click on the Fx button ... in the property window.. you are taken to another window to fill up the property value with probable help to choose as well.

When you complete that and back in property window, you can see a "=" sign without the quote as the first character and then whatever you typed in the next window.

This is to mean, that when the Init of that control takes place, the CAPTION property gets EVALUATED because of the leading = sign, to the contenets right of that = sign.

Example
cStrng = "myTest"

same way
CAPTION = "myTest"
CAPTION = "="

In Scott's case, he needed an = sign as the caption of a label to display probably an equation in the form. However he was finding problem, since he could neither ="=" as the caption nor = as caption. That was solved, by adding an extra space in front of the = sign and in order to evaluate the extra space as a string, the double quote was suggested by me.

Hope things are clear to you and you can use similar structure when you need it.

:)


____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
I can't test since I don't have 8 yet, but I'd suspect that you could use chr() too. It's often a good way to avoid specific characters in code. e.g. "=chr(61)"

Brian
 
Brian

I can't test since I don't have 8 yet, but I'd suspect that you could use chr() too. It's often a good way to avoid specific characters in code. e.g. "=chr(61)"


=chr(61) (no quotes) in the caption property of the form will do it in all versions of VFP from 5.0 to 8.0.

jamrnelson

Why would I use it? What's the purpose?

Sorry, I don't have the answer to that, including a reference that would include all the quirks of VFP, other than it works.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Oh, I see -- what's happening is that if the first character in the caption is an equal sign, the rest is executed within INIT.

My little testing indicates that I can put just about any expression I want (VFP 8) in there, including references to variables and UDFs.

Furthermore, I can do that for any property, not only the caption ... for some, I could enter directly using the property screen, for others, such as FontBold, I needed to use the Fx pop-up (I always wondered what that was for).

Not sure of when I'll need this, but I'm sure that day will come.

Thanks all,
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top