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!

Syntax Error - When Label Caption is "="

Status
Not open for further replies.

brucegs13

Programmer
May 13, 2002
4
CA
I am getting a non fatal Syntax Error when I try to update a label with a field which starts with an '=' sign.

THISFORM.lblSomeLabel.Caption=ALLTRIM(SomeCharacterField)

where the value of SomeCharacterField is '='

Other than validating ALL my fields for this value (and who knows what other characters will generate this error) does anyone have any idea why this is happening?

Thanks in Advance

Bruce Sharland
 
Hi Bruce

Set the caption as [ = ]
i.e. Square bracket starts + One space + =sign + One space + Square Bracket end

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
My understanding is that you can set the value for any property to a character string beginning with '=', and that string will then be evaluated as part of the INIT event for the object. Most common usage is for captions, within the Property sheet:
='first line'+chr[13]+'second line'

so, as frequently happens, a perceived bug is only a feature.

Jim Nelson
 
Thanks for your timely replies ... however ...

The '[ = ]' suggestion would work if the label is always an equal sign.

THISFORM.lblSomeLabel.Caption=ALLTRIM(SomeCharacterField)

The value of SomeCharacterField is input by the user and it could be any string but when they input an equal sign it crashes.

Thanks again ..

Bruce Sharland
 
Bruce,
You'll just have to check the first character - if it's an equal ("="), you'll have to add a space in front of the requested caption. (It appears to be a known "problem", and this is probably the only acceptable workaround.)

Rick
 
Thanks for all the input ...

FYI I wrote a procedure that strips '=' characters from any character field in a record passed to it ...

lnFieldCount=1
DO WHILE .t.
IF LEN(FIELD(lnFieldCount))=0 && End of Fields
EXIT
ENDIF
lcFieldName=FIELD(lnFieldCount)
IF TYPE("&lcFieldName")="C"
IF SUBSTR(&lcFieldName,1,1)="="
REPLACE &lcFieldName WITH SUBSTR(&lcFieldName,2)
ENDIF
ENDIF
lnFieldCount=lnFieldCount+1
ENDDO

Bruce Sharland
 
Brucegs13,

You can also use StrTran(cField,'=','')
this way, if the = sign is not in the beginning, rather anywhere in the field, it will be replaced with ''



Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
Try this:

SomeCharacterField = '='
THISFORM.lblSomeLabel.Caption=ALLTRI('&SomeCharacterField')

Where is the problem ?!?!?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top