[futurebasic] Roomy Edit Fields

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2008 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Mon, 10 Mar 2008 10:09:28 -0400
Eugen asked:

> How can I put more then 32 767 characters of text in an Edit Field ?


Eugen:

Page 236 of the FB Reference Manual says:

    Note:
    An edit field cannot contain more than 32,767 characters of text.


and Page 229 adds this:

    In the case of edit fields, the information is truncated at 32,767
    characters which is the maximum number of characters allowed
    in an edit field.


I have found that a HITextView embedded in a HIScrollView is an  
excellent substitute for an Edit Field. In theory the amount of text  
it can hold is limited only by system memory.

HIView controls are most easily created in Interface Builder with nibs.

FBtoC contains a scrolling HITextView example by Robert Purves that  
loads a small RTF file included in the bundle. His example can be  
found here:

    FBtoC -> Examples -> Text -> Scrolling text view(10.4)

If you commemt out that example's fn TxtViewLoadText function and  
substitute the following, you can see how a scrolling HITextView  
handles really long text files. In this example I load all 234,936  
words in Webster's Second International into the view.

Note: It takes several seconds to load the entire 234,936-word  
dictionary when the compiled app is launched.

Ken


begin enum
_kCFURLPOSIXPathStyle   = 0
_kCFURLHFSPathStyle     = 1
_kCFURLWindowsPathStyle = 2
end enum

#if ndef _DEFINEDINCARBON
#define CFURLPathStyle as long
#endif

toolbox fn CFURLCreateWithFileSystemPath ( CFAllocatorRef allocator,  
CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory )  
= CFURLRef

local fn TxtViewLoadText( txtView as HIViewRef )
'~'1
dim as CFURLRef      url
dim as TXNObject   @ txnObj
dim as OSStatus      err

err = _fnfErr
url = fn CFURLCreateWithFileSystemPath( 0, fn CFSTR("/usr/share/dict/ 
web2"), _kCFURLPOSIXPathStyle, 0 )
long if ( url )
txnObj = fn HITextViewGetTXNObject( txtView )
err = fn TXNReadFromCFURL( txnObj, _kTXNStartOffset, _kTXNEndOffset,  
0, url, #0 )
CFRelease( url )
end if

end fn = err