Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MaxLength and EditBoxes Probable Bug?
Message
From
11/04/2003 14:04:52
 
 
To
10/04/2003 14:29:14
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00776258
Message ID:
00776696
Views:
18
I see what you are talking about, and I think Sergey is on the right track. There may be a bug in here somewhere, but I also see the same behavior in VFP7 SP1.

There are a couple of things going on here.

First, once you copy text into the clipboard in VFP, it removes all line feeds.

Try this:
_cliptext = 'test'+CHR(13)+CHR(10)
?LEN(_cliptext)
The length will be 5 rather than 6, and the 5th character is a CR (i.e. chr(13)). Same thing happens if you copy text manually with ctrl+c.

So, when you paste into a textbox, the text does not contain any linefeeds. There is an editbox property, AddLineFeeds, which dictates whether a linefeed is added for each carriage return entered into the editbox. Apparently, the MaxLength setting is enforced before the linefeeds are added. This would be the bug. You should be able to work around this by setting editbox.AddLineFeeds = .F., that works for me.

Here is code to demonstrate this behavior.
clear 
text to _cliptext noshow 
TEST
TEST
TEST


endtext
_cliptext = Replicate(_cliptext, 249)
LOCAL aobj[1], xx as form
DELETE FILE testxx.sc?
CREATE FORM testxx NOWAIT
=ASELOBJ(aobj,1)
xx = aobj[1]
xx.autocenter = .t.
xx.addobject('edt1','editbox')
xx.edt1.move(10,10,300,175)
xx.edt1.maxlength = 4000
xx.edt1.addlinefeeds = .T.
xx.addobject('txt1','textbox')
xx.txt1.move(10,200)
text to lctext noshow 
activate screen 
?"This.value",Len(this.value),Occurs(Chr(13),this.value),Occurs(Chr(10),this.value),asc(Substr(this.value,5,1)),asc(Substr(this.value,6,1))
?"_cliptext  ",Len(_cliptext), Occurs(Chr(13),_cliptext),Occurs(Chr(10),_cliptext),asc(Substr(_cliptext,5,1)),asc(Substr(_cliptext,6,1))
endtext
xx.edt1.writemethod('lostfocus',lcText)
KEYBOARD 'Y' CLEAR
RELEASE WINDOW 'Form Designer'
keyboard '{ctrl+v}{tab}'
DO FORM testxx
return
You will see the length of _cliptext is less than 4000, but the length of the editbox value is over 4000. The _cliptext has no linefeeds, but the value property does.

I think it is a bug that the linefeeds are not counted as they are added, and this has been passed up the line on your behalf.

>Anyone seen this behavior?
>
>In vfp 8 I take an edit box and set the maxlength=4000
>then I take some text with a cariage return in it like.
>
>"TEST
>TEST
>TEST
>"
>
>Then I proceed to paste it into the editbox until it wont allow me anymore. At this point I just hold any key down until the editbox stops me.
>
>If I tab out and check the length then it will be over 4000. (varies but from 4050-4150)
>
>In vfp7 this does not happen but if the vary last character is a carriage return then it will go to 4001.
>
>I'm gonna try to do something in the interactive change but it sucks these properties dont work..
>
>Perhaps the enter chariage return line feed is counted as one when it should be two? CHR(10)+CHR(13)
>
>BR
>Tim
Jim Saunders
Microsoft
This posting is provided “AS IS”, with no warranties, and confers no rights.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform