Q8N@psuvm.psu.edu (Scott D. Camp) (10/30/90)
I have what is probably a very simple problem that has me stumped. I am trying to create an index of a bg fld into another bg fld. (If this sounds like something you have seen in TidBITS, it should. I took the idea from TidBITS.) When I copy the contents of the field I am indexing, I would like the contents to have a textStyle of group so I can later use clickText to go to the appropriate card. However, I have not been able to think of a way to do this. I have tried setting the textStyle of the field to be indexed to group, but the put command does not retain the style of the field from which information is being copied. I have tried setting the textStyle of the index field itself to group, hoping that returns would separate different chunks, but this does not appear to work as the entire content of the field is grouped. Anyone have any ideas? Thanks in advance for considering the request of an admitted HC novice. BTW, here is the basic repeat loop I am using. Note that the bg fld index is obviously locked and has the property ShareText set to true. repeat with x = 1 to the number of cards go to card x if x = 1 then put bg fld "index name" & return into bg fld "index" else put bg fld "index name" & return after bg fld "index" end repeat I have also considered putting the contents of "index name" into a local variable and then setting textStyle to group, but from the discussion in The Book, I assume that textStyle does not work with local variables. Is my understanding correct? Again, thanks. Scott D. Camp Q8N@PSUVM.PSU.EDU The Pennsylvania State University 305 Oswald Tower University Park, PA 16802 814-863-0121
taylorj@yvax.byu.edu (10/30/90)
In <90302.144024Q8N@psuvm.psu.edu>, Scott D. Camp <Q8N@psuvm.psu.edu> writes about having problems grouping the text of an index. You need to set the style of a chunk, not the style of the field. E.g., "set the textStyle of line 3 of cd field 1 to group" or "set the textStyle of word 4 to 8 of field 3 to group." Jim Taylor Microcomputer Support for Curriculum | Brigham Young University | Bitnet: taylorj@byuvax.bitnet 101 HRCB, Provo, UT 84602 | Internet: taylorj@yvax.byu.edu
rmh@apple.com (Rick Holzgrafe) (10/31/90)
I won't quote, but Q8N@psuvm.psu.edu (Scott D. Camp) wants to copy text from various fields into a destination field, preserving the source fields' text styles and also adding the 'group' style to portions of the copied text. He complains that put bg fld "index name" & return into bg fld "index" does not copy the text style, only the text; and that there is no (obvious) way to add a style, only to replace styles. All this is correct, and here are the work-arounds I found. (Anyone got any better ones?) To copy styles as well as text, you must use "doMenu Copy" and "doMenu Paste", along with "select" to specify what to copy and where to paste. This requires a userLevel of at least 4 ("Authoring") so (if your stack is for general use) be prepared to get and save the current userLevel, set it to 4, do your work, then restore the old userLevel. This method is unsatisfactory because it is slow, and because it cannot be used on a locked stack (cut and paste operations are forbidden on locked stacks) but it works otherwise. To add a style to text, without destroying its existing styles, you must do it one character at a time (probably in a loop, but I'll skip the loop and show just the code for dealing with one character): put the textStyle of char foo of bg fld fum into itsStyle if itsStyle does not contain "group" then put "group" into item ((the number of items in itsStyle) + 1) of itsStyle set the textStyle of char foo of bg fld fum to itsStyle end if The reason is that the response to "the textStyle of" a string is sometimes (maybe always) "mixed"; only asking about one char at a time guarantees a useful answer. Note that uninterrupted runs of chars styled "group" always count as a single group, even if the group styling was added piecemeal. (And forgive the off-the-cuff HyperTalk, it may be incorrect but I hope the point is clear.) Again, this is unsatisfactory because it is slow; but it works. Hope this helps. ========================================================================== Rick Holzgrafe | {sun,voder,nsc,mtxinu,dual}!apple!rmh Software Engineer | AppleLink HOLZGRAFE1 rmh@apple.com Apple Computer, Inc. | "All opinions expressed are mine, and do 20525 Mariani Ave. MS: 3-PK | not necessarily represent those of my Cupertino, CA 95014 | employer, Apple Computer Inc."