On May 19, 2008, at 3:34 PM, John Grimsley wrote: > Brian and Robert, > > Thanks very much. I already have all files in .rtf format I > believe. My one goal has been to ship all the content of my game > inside the app itself -- no external help files, etc. Can I > put .rtf files into Resources? Yes, all the rtf files can be stored in the Resource folder ( within the Contents folder in the bundle ). See the fn TxtViewLoadText Robert posted and the call to fn CFBundleCopyResourceURL( fn CFBundleGetMainBundle(). This gets a url to a file. This code could be used for your rtf files too. BTW: if your question was: can I put rtf files into resource files ( and not the Resources folder - your question was not specific ), the answer is don't even think about it ( yes, it is technically possible ). Use the method Robert has provided. Note: Either rtf files or html files ( if using Apple help ) can be safely stored inside the bundle enabling you to ship all the content inside the app. > > Brian, your suggestion is a good one -- make the help files > available on the web site. Someone in France recently said the main > help file was too big to copy-paste and print. OOPs. I sent him > the .rtf. > > > Thanks again, > > John G > > > > > Robert Purves wrote: >> >> John Grimsley wrote: >> >>> In nostalgic 1900's programming, I have 6 large help files as Text >>> resources. They are handled as below: >>> >>> ========= >>> Window -_helpWnd, "Help Information", (0,0)- >>> (565,System(_scrnHeight)-50), _docZoom >>> resPTR = _helpInfoRes+LANG // 0 = English ; 10 = French >>> (for Alain) >>> Edit Field 131, %resPTR, (6,6)- >>> (Window(_Width)-20,Window(_Height)-6), _copyOnlyNoFramed >>> scroll button -860,,,,,, _scrollVert >>> setselect 0, 0 >>> ========= >>> In modern 2000's programming, where do I start? "%resPTR"? >> >> The correct way is to convert your help files into html, and make a >> Help Book. Unfortunately we don't seem to have a demo in FBtoC >> Examples. Perhaps some beneficent programmer will remedy the >> deficiency by providing a Really Simple Help Book demo. >> >> Alternatively, you could convert your files to .rtf (in TextEdit), >> and display them in a scrolling text view. See: >> FBtoC_1.0.x > Examples > Text > Scrolling text view(10.4) >> The example "Scrolling text view" is somewhat cluttered and >> requires OS X 10.4, so I made a simpler example (below) that works >> in 10.3 to 10.5. >> >> Robert P. >> >> >> '----------------------- >> /* >> How to load and display an .rtf file from resources (FB and FBtoC) >> Requires main.nib and dummy.rtf from FBtoC_1.0.x > Examples > Text >> > Scrolling text view(10.4) >> >> rp 20080520 >> */ >> include "Tlbx IBCarbonRuntime.incl" >> include "Tlbx MacTextEditor.incl" >> >> // CFBundle.h >> toolbox fn CFBundleGetMainBundle = CFBundleRef >> toolbox fn CFBundleCopyResourceURL( CFBundleRef bundle, CFStringRef >> resourceName, CFStringRef resourceType, CFStringRef subDirName ) = >> CFURLRef >> >> #if def _FBtoC >> include resources "dummy.rtf" // the source of the rtf text >> #endif >> >> >> local mode >> local fn TxtViewLoadText( txtView as HIViewRef ) >> '~'1 >> dim as CFURLRef url >> dim as TXNObject @ txnObj >> dim as OSStatus err >> >> err = _fnfErr >> url = fn CFBundleCopyResourceURL( fn CFBundleGetMainBundle(), fn >> CFSTR( "dummy.rtf" ), 0, 0 ) >> long if ( url ) >> txnObj = fn HITextViewGetTXNObject( txtView ) >> err = fn TXNSetDataFromCFURLRef( txnObj, url, _kTXNStartOffset, >> _kTXNEndOffset ) >> CFRelease( url ) >> end if >> end fn = err >> >> >> local mode >> local fn TxtViewSetMargins( txtView as HIViewRef, left as SInt16, >> top as SInt16, right as SInt16, bottom as SInt16 ) >> '~'1 >> dim as TXNMargins @ margins >> dim as TXNControlData @ cData >> dim as TXNControlTag @ tag >> >> margins.topMargin = top >> margins.leftMargin = left >> margins.bottomMargin = bottom >> margins.rightMargin = right >> cData.marginsPtr = @margins >> tag = _kTXNMarginsTag >> end fn = fn TXNSetTXNObjectControls( fn >> HITextViewGetTXNObject( txtView ), _false, 1, @tag, @cData ) >> >> >> local fn BuildUI as HIViewRef >> '~'1 >> dim as IBNibRef @ nib >> dim as WindowRef @ w >> dim as HIViewRef scrollView, txtView, @ contentView >> >> txtView = 0 >> long if ( fn CreateNibReference( fn CFSTR( "main" ), @nib ) == >> _noErr ) >> //call SetMenuBarFromNib( nib, fn CFSTR( "MenuBar" ) ) >> call CreateWindowFromNib( nib, fn CFSTR( "Window" ), @w ) >> >> call HIViewFindByID( fn HIViewGetRoot( w ), >> kHIViewWindowContentID.signature, kHIViewWindowContentID.id, >> @contentView ) >> scrollView = fn HIViewGetFirstSubview( contentView ) >> txtView = fn HIViewGetLastSubview( scrollView ) >> >> fn TxtViewSetMargins( txtView, 8, 0, 0, 0 ) >> fn TxtViewLoadText( txtView ) >> ShowWindow( w ) >> DisposeNibReference( nib ) >> end if >> end fn = txtView >> >> >> // main program >> fn BuildUI >> do >> HandleEvents >> until gFBQuit >> '-------------------- >> >> -- >> To unsubscribe, send ANY message to: futurebasic-unsubscribe@... >> > > -- > To unsubscribe, send ANY message to: futurebasic-unsubscribe@... > Brian S.