Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!ix.netcom.com!netcom.com!andya
From: andya@netcom.com (oh Golly)
Subject: adding help books to VW2
Message-ID: <andyaD3G2A0.1nt@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
Date: Fri, 3 Feb 1995 21:56:24 GMT
Lines: 79


here is a sort of answer to my own question.  maybe this much will help 
someone who hasn't gotten this far. please post or mail improvements 
and/or extension.

here some code we put in the workspace. It seems to work ok, but we have 
to do it in the order of page, then chapter, then book for it to work.

BTW, this is not the actual code, I had to retype it. bummer.

"Initialize"
| pageProxyCollection chapterProxyCollection bookProxy fileIndex |
Object errorSignal
  handle: [:ex ]
  do: [(Filename named: '/users/aiello/myhelp.hlp') delete].
(HelpChapter whichClassIncludesSelector: #displayString) ~~ HelpChapter
  ifFalse: [Dialog warn: 'Need to remove override to displayString to 
return nil for special chapter title handling by proxy.'].
HelpProxy initialize.
pageProxyCollection := OrderedCollection new.
chapterProxyCollection := OrderedCollection new.

"Create Page Proxies"
pageProxyCollection add: (HelpProxy with: (HelpPage title: 'Page 1' 
asText allBold contents: 'The first page.' examples: nil seeAlso: nil)).
...repeat subbing 'Page #' and  'The # page.'...

"Create Chapter Proxy"
chapterProxyCollection add: (HelpProxy with: (HelpChapter title: 
'Chapter: this better work' contents: pageProxyCollection)).

"Create Book Proxy"
bookProxy := (HelpProxy with: (HelpBook title: 'Stupid Book' fileID: 
'/users/aiello/myhelp.hlp' pageNumbers: #() contents: 
chapterProxyCollection)).

"Attempt to Store the Book to an external file"
HelpProxy defaultStorer initializeFiles.
fileIndex := HelpProxy defaultStorer addFile: (bookProxy value) fileID.
bookProxy fileIndex: fileIndex.
HelpProxy defaultStorer startFileFor: bookProxy.
pageProxyCollection do: [:pageProxy | pageProxy save ].
chapterProxyCollection do: [:chapterProxy | chapterProxy save ].
bookProxy value
   updateChapterNumbers;
   updatePageNumbers.
bookProxy save.

HelpProxy defaultStorer close.

"loading a proxy from myhelp.hlp"
| bookProxy fileIndex |
(HelpChapter whichClassIncludesSelector: #displayString ) == HelpChapter
  ifFalse: [^Dialog warn: 'need to override displayString to return nil 
for special chapter title handling by proxy.'].
HelpProxy := HelpProxy initialize.
fileIndex := HelpProxy defaultStorer addFile: '/users/aiello/myhelp.hlp'.
bookProxy := HelpProxy defaultStorer firstInFile: fileIndex.
MyHelpLibrary := HelpLibrary new.
MyHelpLibrary add: bookProxy before: nil.

HelpBrowser openOn: MyHelpLibrary

hope this helps.

*--------------------------------------------------*
* These are my opinions only...                    *
* not my employers or any other sane person        *
* andya@netcom.com              Andy Aiello        *
* andy.aiello@sprint.sprint.com Sprint, Dallas, TX *
*--------------------------------------------------*



-- 
*--------------------------------------------------*
* These are my opinions only...                    *
* not my employers or any other sane person        *
* andya@netcom.com              Andy Aiello        *
* andy.aiello@sprint.sprint.com Sprint, Dallas, TX *
*--------------------------------------------------*
