realbasic-nug
[Top] [All Lists]

Re: Window Refreshing

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Window Refreshing
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Thu, 31 Mar 2005 09:17:23 -0600
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20050330231139 dot 4517480CCEC at lists dot realsoftware dot com> <5cc2c9dff6da4cdcdb80e1f21a365206 at farhner dot com>
At 3:36 PM -0800 3/30/05, Ben Farhner wrote:

   field.SelStart = LenB(field.SelText)
field.SelText = EndOfLine + EndOfLine + bip.text + ": " + EndOfLine + d.data

What's the difference between Len and LenB?

The difference is explained in the language reference (briefly, the latter returns bytes, the former returns characters). It's safe to use LenB here because the goal is simply to put the cursor at the end of the text, and LenB(s) >= Len(s) for all values of s.

 Does it matter which one I use?

Not in this case, except that LenB is faster.

 Also, why is the other way wrong?

Because it (1) converts the entire contents of the EditField to a string, (2) constructs a new string by combining it with the new text, (3) deletes the entire contents of the EditField, and (4) stuffs the new string in its place. That is not only way slower than it needs to be, but it also messes up the scroll position, any styles, and so on.

This might be part of the problem, but that doesn't explain why the other two editfields need refreshing.

No, it doesn't.

Best,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout           REAL Software, Inc.                |
|    joe at realsoftware dot com       http://www.realsoftware.com        |
`------------------------------------------------------------------'
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>