Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!apple.com!rmh From: rmh@apple.com (Rick Holzgrafe) Newsgroups: comp.sys.mac.hypercard Subject: Re: Using group Message-ID: <11030@goofy.Apple.COM> Date: 30 Oct 90 22:01:30 GMT References: <90302.144024Q8N@psuvm.psu.edu> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 48 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."