From: owner-csmp@ee.mcgill.ca Subject: csmp digest Vol 4 No 044 C.S.M.P. Digest Wed, 12 Nov 97 Volume 4 : Issue 44 Today's Topics: Changing a menu title text? Closing PPP Connection Color table from PICTs Determining Screen size Dragging from background app? Resource XCMD's? Seeking Rich Text Format (RTF) reference Strange template problem (C++) Using the current Desktop pattern [Q] How do I measure time between two close events... bitfield question which Macsbug for and 8600-300, macOS8? The Comp.Sys.Mac.Programmer Digest is moderated by Mark Aiken (marka@ee.mcgill.ca). The digest is a collection of article threads from the internet newsgroups comp.sys.mac.programmer.help, csmp.tools, csmp.misc and csmp.games. It is designed for people who read news semi-regularly and want an archive of the discussions. If you don't know what a newsgroup is, you probably don't have access to it. Ask your systems administrator(s) for details. If you don't have access to news, you may still be able to post messages to the group by using a mail server like anon.penet.fi (mail help@anon.penet.fi for more information). Each issue of the digest contains one or more sets of articles (called threads), with each set corresponding to a 'discussion' of a particular subject. The articles are not edited; all articles included in this digest are in their original posted form (as received by our news server at ee.mcgill.ca). Article threads are not added to the digest until the last article added to the thread is at least two weeks old (this is to ensure that the thread is dead before adding it to the digest). Article threads that consist of only one message are generally not included in the digest. The digests can be obtained by email, ftp or through the World Wide Web. If you want to receive the digest by mail, send email to majordomo@ee.mcgill.ca with no subject and one of the following commands as body: help Sends you a summary of commands subscribe csmp Adds you to the mailing list unsubscribe csmp Removes you from the list Once you have subscribed, you will automatically receive each new issue as it is created. Back issues are available by ftp from Info-Mac mirror sites in the per/csmp subdirectory, e.g. ftp://sumex-aim.stanford.edu/info-mac/per/csmp/ The contents of all back issues can be searched by accessing the following URL, courtesy of Andrew Barry (ajbarry@ozemail.com.au): http://marvin.stattech.com.au/search.html They can also be searched through the following URLs, thanks to Tim Tuck (Tim.Tuck@sensei.com.au): http://wais.sensei.com.au/searchform.html wais://wais.sensei.com.au:210/csmp? ------------------------------------------------------- >From jasonp@blue.seas.upenn.edu (Jason S Pareti) Subject: Changing a menu title text? Date: 17 Oct 1997 21:31:49 GMT Organization: University of Pennsylvania Hi. Is it possible to change the title text of a menu (ie "File" -> "Cheese")? The SetMenuItemText() function won't seem to do it, even if you pass in a value of 0 as the menu item number. I don't want to remove and re-insert the menu, because that seems to screw up some of the menu-handling routines in PowerPlant. Is there any other way to do this? Thanks a lot. Cheers, Jason +++++++++++++++++++++++++++ >From gurgle@iname.com (Pete Gontier) Date: Sun, 19 Oct 1997 19:50:51 -0700 Organization: cellular In article <628lg5$tvo$1@netnews.upenn.edu>, jasonp@blue.seas.upenn.edu (Jason S Pareti) wrote: > Hi. Is it possible to change the title text of a menu (ie "File" -> > "Cheese")? The SetMenuItemText() function won't seem to do it, even if > you pass in a value of 0 as the menu item number. I don't want to remove > and re-insert the menu, because that seems to screw up some of the > menu-handling routines in PowerPlant. Is there any other way to do this? This is one of the deficiencies of the API. There isn't a good way. :-( -- Pete Gontier, Integer Poet +++++++++++++++++++++++++++ >From Online@MacTech.com ( nick.c MacTech ) Date: Thu, 23 Oct 1997 09:56:57 -0700 Organization: MacTech Magazine gurgle@iname.com (Pete Gontier) wrote: >In article <628lg5$tvo$1@netnews.upenn.edu>, >jasonp@blue.seas.upenn.edu (Jason S Pareti) wrote: > > > Hi. Is it possible to change the title text of a menu (ie "File" -> > > "Cheese")? The SetMenuItemText() function won't seem to do it, even if > > you pass in a value of 0 as the menu item number. I don't want to remove > > and re-insert the menu, because that seems to screw up some of the > > menu-handling routines in PowerPlant. Is there any other way to do this? > >This is one of the deficiencies of the API. There isn't a good way. :-( You could have two MBAR's, one with a the first non-Apple MENU being MENU 128 (with File as the title), and the second with it being MENU 129 (with Cheese as the title). Then load the first MBAR on startup, and the second MBAR when you want to switch the menu title. Admittedly, it's a hack but it should at least do what you want... ____Nicholas C. DeMello, Ph.D.___________________________________________ "MacTech Online"--MacTech Magazine, for Mac OS Programmers and Developers http://www.MacTech.com/ _/ _/ _/ _/_/_/ _/ _/ Chemistry: Nick@chem.UCLA.edu _/_/ _/ _/ _/ _/ _/_/_/ MacTech: Online@MacTech.com _/ _/_/ _/ _/ _/ _/ http://www.chem.ucla.edu/~nick/ _/ _/ _/_/_/ _/ _/ +++++++++++++++++++++++++++ >From trygve@bombaydigital.com (Trygve Isaacson) Date: Thu, 23 Oct 1997 11:28:21 -0700 Organization: Bombay Digital In article , gurgle@iname.com (Pete Gontier) wrote: >In article <628lg5$tvo$1@netnews.upenn.edu>, >jasonp@blue.seas.upenn.edu (Jason S Pareti) wrote: > > > Hi. Is it possible to change the title text of a menu (ie "File" -> > > "Cheese")? The SetMenuItemText() function won't seem to do it, even if > > you pass in a value of 0 as the menu item number. I don't want to remove > > and re-insert the menu, because that seems to screw up some of the > > menu-handling routines in PowerPlant. Is there any other way to do this? > >This is one of the deficiencies of the API. There isn't a good way. :-( Here's a way to do it manually, since there's no Menu Manager call to do it for you. It's been a while since I wrote this or even compiled it, so I make no promises, but it always worked fine for me. Try it out. Basically what I am doing is changing the title in the menu handle by altering it in place, and moving the menu item data up or down in memory to fit the new title string (the menu item data immediately follows the variable-length title whose length we may be changing). I forget why I put the "makeUnpurgeable" flag in there; menus should always be unpurgeable anyway. --Trygve void SetMenuTitle(MenuHandle theMenuHandle, StringPtr theMenuTitle, Boolean makeUnpurgeable) { Handle h; SInt32 origHandleSize; SInt32 newHandleSize; SInt32 extraDataSize; SInt32 origTitleLength; SInt32 newTitleLength = theMenuTitle[0]; if (makeUnpurgeable) HNoPurge((Handle) theMenuHandle); origHandleSize = GetHandleSize((Handle) theMenuHandle); origTitleLength = (**theMenuHandle).menuData[0]; extraDataSize = origHandleSize - sizeof(SInt16) // (**m).menuID - sizeof(SInt16) // (**m).menuWidth - sizeof(SInt16) // (**m).menuHeight - sizeof(Handle) // (**m).menuProc - sizeof(SInt32) // (**m).enableFlags - (origTitleLength + 1); // (**m).menuData's title // // We copy the post-title data aside because the new title can be either // longer or shorter than the old one. // h = NewHandle(extraDataSize); if (MemError() == noErr) { BlockMove(&(**theMenuHandle).menuData[origTitleLength+1], *h, extraDataSize); newHandleSize = origHandleSize - (origTitleLength - newTitleLength); SetHandleSize((Handle) theMenuHandle, newHandleSize); if (MemError() == noErr) { BlockMove(&theMenuTitle[0], &(**theMenuHandle).menuData[0], newTitleLength+1); BlockMove(*h, &(**theMenuHandle).menuData[newTitleLength+1], extraDataSize); } DisposeHandle(h); } } --------------------------- >From i'm@not.here (Jeff Clites) Subject: Closing PPP Connection Date: Thu, 23 Oct 1997 11:36:08 -0700 Organization: California Institute of Technology, Pasadena Is there a somewhat simple way to check whether a PPP connection is open, and to close it if there is? Is the answer different depending on the PPP software being used (OT/PPP, FreePPP, MacPPP, etc.)? Should I be looking in the dreaded, not-available-on-the-web IM: Comm. Toolbox? (I don't see anything relevant in Subwoofer or IC. There are a lot of things which automagically cause a connection to intiate if necessary, but I can't locate a way to close it.) - ------------------------------------------------------------------------ Jeff Clites Pasadena, California My account name is jac and the rest of my address has igor and caltech and edu, separated by dots. Don't spam me or anybody else (please). +++++++++++++++++++++++++++ >From fb@enteract.com (Frederick) Date: Sat, 25 Oct 1997 18:28:45 -0500 Organization: EnterAct L.L.C. Turbo-Elite News Server In article , i'm@not.here (Jeff Clites) wrote: >Is there a somewhat simple way to check whether a PPP connection is open, >and to close it if there is? Is the answer different depending on the PPP >software being used (OT/PPP, FreePPP, MacPPP, etc.)? Should I be looking >in the dreaded, not-available-on-the-web IM: Comm. Toolbox? OT/PPP is fully scriptable via AppleScript. 1.0 was available on the web for free. The latest version (1.2?) is included with MacOS 8. -- Frederick Bruckman URL:http://www.enteract.com/~fb +++++++++++++++++++++++++++ >From friefeld@deltanet.com (Rob Friefeld) Date: Sun, 26 Oct 1997 21:19:46 -0800 Organization: Hackware In article , i'm@not.here (Jeff Clites) wrote: >Is there a somewhat simple way to check whether a PPP connection is open, >and to close it if there is? Is the answer different depending on the PPP >software being used (OT/PPP, FreePPP, MacPPP, etc.)? These 3 do require different methods. Richard Buckle has made a set of interfaces available. -- - - Rob Friefeld Long Beach, CA friefeld@deltanet.com --------------------------- >From masong7@aol.com (MasonG7) Subject: Color table from PICTs Date: 5 Oct 1997 15:49:19 GMT Organization: AOL http://www.aol.com Does anybody know how you get a color table/palette from a PICT? Or is there a description of the PICT format somewhere (apple's Inside Mac server isn't working, and I'd rather not download 7 megs of text and wade through it all to find the 1 or 2 pages I need anyways)? MasonG7@aol.nospam.com Mason Gup remove nospam to send e-mail (like it's really going to make a differnce in the amount of spam I get) +++++++++++++++++++++++++++ >From entity@interlog.com (Entity) Date: 6 Oct 1997 12:09:17 -0400 Organization: Hybrid Designs In article <19971005154901.LAA05832@ladder01.news.aol.com>, MasonG7 wrote: >Does anybody know how you get a color table/palette from a PICT? Or is there a > description of the PICT format somewhere (apple's Inside Mac server isn't > working, and I'd rather not download 7 megs of text and wade through it all to > find the 1 or 2 pages I need anyways)? In both Photoshop 3 & 4 (and probably in earlier versions too!) you can convert an image to "indexed color" so that it uses a 256 color palette and then if you go to the palette editor, it lets you save off the CLUT. It just stores each R,G,B entry as 8bits per gun in the data fork. So you get 3*256 bytes of information. -- _____________________________________________________________________________ Hybrid Designs entity@interlog.com +++++++++++++++++++++++++++ >From Steve Israelson Date: Tue, 07 Oct 1997 19:17:52 -0700 Organization: Rogers WAVE > >Does anybody know how you get a color table/palette from a PICT? Or is there a > > description of the PICT format somewhere (apple's Inside Mac server isn't > > working, and I'd rather not download 7 megs of text and wade through it all to > > find the 1 or 2 pages I need anyways)? You could use the PicUtilities package. I forget the exact calls, but they are documented in InsideMac. Steve Israelson +++++++++++++++++++++++++++ >From desalvo@apple.com (Chris De Salvo) Date: Wed, 08 Oct 1997 12:12:15 -0700 Organization: Apple Computer, Inc. In article <19971005154901.LAA05832@ladder01.news.aol.com>, masong7@aol.com (MasonG7) wrote: >Does anybody know how you get a color table/palette from a PICT? Or is there a > description of the PICT format somewhere (apple's Inside Mac server isn't > working, and I'd rather not download 7 megs of text and wade through it all to > find the 1 or 2 pages I need anyways)? Well, parsing a PICT file is no simple task. _I_ certainly wouldn't want to have to write the code. You have two good options if you want to do this. 1) GetPictInfo(). This function is defined in PictUtil.h. You pass it a PicHandle, the address of a PictInfo structure, and some other parameters that tell you how many colors to extract and which extraction method to use. You get back the colors that are in the Pict either in a PaletteHandle or a CTabHandle or both depending on how you set up the calls. The downside of this call is that the color table you back isn't necessarily (and almost always is not) in the same order as it was when the Pict was created. This routine just samples colors and does not look at any embedded color tables. 2) The RIGHT way to do this if you want back the exact CLUT from an 8-bit PICT would be to temporarily replace all of the QuickDraw bottleneck routines with SetStdProcs() (defined in QuickDraw.h). Of particular interest is the bitsProc routine. You'll want to write your own version of this routine that looks at the PixMapHandle that is passed in to it. You can then go and extract the CTabHandle from that PixMap and get the exact color map for the Pict. This, of course, assumes a Pict that has been flattened and is just a bit image. Now, one tricky thing to pay attention to is that the bitsProc takes a BitMapPtr and not a PixMap so you need to look at the rowBytes field of the BitMapPtr. If the top two bits are 00 then it really is a BitMap. If the top two bits are 10 then it is a PixMap. If the top two bits are 11 then it is a CGrafPort. Now, just call DrawPicture() with the Pict you're interested in and your bitsProc routine will get called and you can snag the CLUT from the Pict data. Just make sure that you restore the original bottleneck routines when you're done!!! Now, before everyone passes out at the thought of writing this you'll be comforted to know that there is sample code for this already available at: Have fun kids. L8R Chris -- To get random signatures put text files into a folder called „Random Signatures¾ into your Preferences folder. +++++++++++++++++++++++++++ >From Martin J Murrett Date: Tue, 21 Oct 1997 21:19:15 -0400 Organization: MacPants Software In article <343AED4F.3259@rogers.wave.ca>, pfhorte@rogers.wave.ca wrote: >> >Does anybody know how you get a color table/palette from a PICT? Or is there a >> > description of the PICT format somewhere (apple's Inside Mac server isn't >> > working, and I'd rather not download 7 megs of text and wade through it all to >> > find the 1 or 2 pages I need anyways)? > > >You could use the PicUtilities package. I forget the exact calls, but >they are documented in InsideMac. > >Steve Israelson try this; if the picture uses fewer than 256 colors, it returns a color table in ctab, otherwise, it returns nil. i wrote it just now, because i'm too lazy to go into cw, but it should compile: #include #include CTabHandle GetColors( PicHandle pic ) { OSErr err; Boolean direct; PictInfo info; UInt32 colors; UInt16 depth; CTabHandle ctab; PicHandle pic; err = GetPictInfo( pic, &info, returnColorTable, 256, medianMethod, 0 ); if( err != noErr ) { printf( "a GetPictInfo error occurred. i am going to quit now. (error\ number %d.)\n", err ); getchar(); ExitToShell(); } depth = info.depth; if( colors < 256 ) { DisposeCTable( info.theColorTable ); err = GetPictInfo( pic, &info, returnColorTable, colors, medianMethod, 0 ); if( err != noErr ) { printf( "a GetPictInfo error occurred. i am going to quit now. \ (error number %d.)\n", err ); getchar(); ExitToShell(); } } if( depth > 8 ) { direct = true; ctab = nil; } else { direct = false; ctab = info.theColorTable; } return( ctab ); } manuel noriega was named Maximum Leader. Nice. Mac. -- To get random signatures put text files into a folder called „Random Signatures¾ into your Preferences folder. --------------------------- >From pwestbro@best.com (Paul Westbrook) Subject: Determining Screen size Date: Tue, 21 Oct 1997 23:45:12 -0700 Organization: (none) Hello, How can I determine the size of an attached monitor from a program that I am writing? Thanks, Paul Westbrook -- PAUL WESTBROOK | For PGP public key pwestbro@best.com | http://www.Four11.com/ - ---------------------------------------------------------------- Who REALLY puts the filling in the twinkies, anyway? - ---------------------------------------------------------------- +++++++++++++++++++++++++++ >From carl.gustafson@no.spam.welcome (Carl Gustafson) Date: Wed, 22 Oct 1997 07:39:15 -0400 Organization: Imaging and Computer Vision Center, Drexel University In article , pwestbro@best.com (Paul Westbrook) wrote: > Hello, > How can I determine the size of an attached monitor from a program that > I am writing? Get the head of the GDevice list using GetDeviceList(), then walk the chain using GetNextDevice(). Get sizes by looking at the gdRect member of the GDevice record. Get the size of the main device (the one using the menu bar) by checking screenBits.bounds. -- Carl Gustafson carl.gustafson at ece.drexel.edu Computer Vision Center for Vertebrate Brain Mapping Drexel University, Philadelphia, Penna -- Obligatory anti-microsoft screed: Microsoft buys into Apple! The future of Windows is safe! Now they will have a superior system to copy for the next 13 years as well. Macintosh. +++++++++++++++++++++++++++ >From DavidO@dascorp.com (David Phillip Oster) Date: Wed, 22 Oct 1997 12:01:55 -0700 Organization: Digital Arts & Sciences Corp. In article , pwestbro@best.com (Paul Westbrook) wrote: >Hello, > How can I determine the size of an attached monitor from a program that >I am writing? I'm writing this on a machine with 2 monitors, and I've written for a network of macs, where each mac had 3 monitors. In addition, now that there is Display Manager, the number of pixels on each monitor can change while your program is running. (The Monitors control panel, and an item on the control strip at the bottom of the screen let you change the number of pixels per monitor.) Read the Display Manager chapter of Inside Macintosh, available on apple's web site http://www.devworld.apple.com for more information. You can use LMGetGrayRgn() to return a region, in global coordinates, of the current desktop. You can use GDHandle gd; for(gd = GetDeviceList(); nil != gd ; gd = GetNextDevice(gd)){ } to cycle through all the graphic devices on your system. Don't forget to use TestAttribute() to see if the graphic device is an active screen device. You can use display manager callbacks to be informed when the Display Manager changes the size of a monitor, but if it is done from the control strip, you can't expect your window list to be valid. You can get my CDisplay code from the metrowerks powerplant contributed class archive to see how I handled the details. -- -- Warning: posted from an unlocked cubicle: no guarantee its really me. "I am Buffie of Borg. Resistance is so totally bogus. You will be, like, assimilated..." (and we give you these bitchin' piercings) --------------------------- >From smfr@santafe.edu (Simon Fraser) Subject: Dragging from background app? Date: Fri, 24 Oct 1997 12:42:06 +0000 Organization: BT Internet In implementing drag and drop in a small app, I came across a problem that I can't solve. I want to be able to drag from my app, while it is in the background, without it being activated. Notepad and the Scrapbook do this, but no other drag-aware app that I've found does it. The problem is that the Finder brings my app to the front as soon as you click in its window; the app does not even get a chance to call WaitMouseMoved before being activated. I've checked out the Finder flags, to no avail. Anyone know how this is done? Simon -- Simon Fraser smfr@santafe.edu http://www.santafe.edu/~smfr/ +++++++++++++++++++++++++++ >From stk@berlin.snafu.de (Stefan Haller) Date: Fri, 24 Oct 1997 18:39:16 +0200 Organization: none Simon Fraser wrote: > I want to be able to drag from my app, while it is in the background, > without it being activated. Notepad and the Scrapbook do this, but > no other drag-aware app that I've found does it. Notepad, Scrapbook and the Finder itself use an undocumented feature of the Drag Manager to accomplish this. This feature isn't available to us ordinary mortals (which is a shame). I don't know if anyone has reverse-engineered this. -- Stefan Haller Berlin, Germany http://www.inx.de/~stk/ +++++++++++++++++++++++++++ >From johns@sonic.net (John Selhorst) Date: Sun, 26 Oct 1997 07:35:41 -0800 Organization: Sonic,Santa Rosa CA,http://www.sonic.net In article , smfr@santafe.edu (Simon Fraser) wrote: >In implementing drag and drop in a small app, I came across a problem >that I can't solve. > >I want to be able to drag from my app, while it is in the background, >without it being activated. Notepad and the Scrapbook do this, but >no other drag-aware app that I've found does it. > >The problem is that the Finder brings my app to the front as soon >as you click in its window; the app does not even get a chance to >call WaitMouseMoved before being activated. I've checked out >the Finder flags, to no avail. > >Anyone know how this is done? Apple cheats. Apple system software is the only stuff that can do that. Johnny +++++++++++++++++++++++++++ >From d88-bli@bitbucket.nada.kth.se (Bo Lindbergh) Date: 27 Oct 1997 16:16:50 GMT Organization: Royal Institute of Technology, Stockholm, Sweden In article <1cyn4az.100upchq1o32iN@n099h057.berlin.snafu.de> stk@berlin.snafu.de (Stefan Haller) writes: > Simon Fraser wrote: > > > I want to be able to drag from my app, while it is in the background, > > without it being activated. Notepad and the Scrapbook do this, but > > no other drag-aware app that I've found does it. > > Notepad, Scrapbook and the Finder itself use an undocumented feature of > the Drag Manager to accomplish this. Actually, it's part of the core OS. (It was in 7.1 anyway.) > I don't know if anyone has reverse-engineered this. At least one person has. :-) /Bo Lindbergh (see X-From header) --------------------------- >From maury@softarc.com (Maury Markowitz) Subject: Resource XCMD's? Date: Fri, 24 Oct 1997 15:22:29 -0500 Organization: SoftArc Inc. Does anyone know of a good XCMD set for massaging resources in files? I need to do string replaces in things like DITL's and WIND resources. AppleScriptable tools would be OK too, but I'm having trouble finding anything that does this. Maury +++++++++++++++++++++++++++ >From i'm@not.here (Jeff Clites) Date: Sat, 25 Oct 1997 18:49:16 -0700 Organization: California Institute of Technology, Pasadena In article , maury@softarc.com (Maury Markowitz) wrote: > Does anyone know of a good XCMD set for massaging resources in files? I >need to do string replaces in things like DITL's and WIND resources. >AppleScriptable tools would be OK too, but I'm having trouble finding >anything that does this. Probably the easiest thing would be to deRez them, and work with the resulting text files. - ------------------------------------------------------------------------ Jeff Clites Pasadena, California My account name is jac and the rest of my address has igor and caltech and edu, separated by dots. Don't spam me or anybody else (please). +++++++++++++++++++++++++++ >From rinaldi1@euro.apple.com (Frederic RINALDI) Date: 29 Oct 1997 10:01:30 GMT Organization: Apple In article , maury@softarc.com (Maury Markowitz) wrote: > Does anyone know of a good XCMD set for massaging resources in files? Use FullResList, KillRes, CopyRes, ResText, TextRes from the rinaldi Collection available on: ftp.supelec.fr/pub/machines/macintosh/Rinaldi_Collection or ftpdev.info.apple.com/Developer_Services/Tool_Chest/Development_Platforms/HyperCard_Related/Rinaldi_Collection_/ or ftp.amug.org/pub/amug/bbs-in-a-box/files/hyper/rinaldi-collection. Frederic --------------------------- >From Russell Reece Subject: Seeking Rich Text Format (RTF) reference Date: Thu, 16 Oct 1997 09:48:09 -0800 Organization: TRW I have been trying to find a source document on how RTF is defined. I need to interface with Microsoft Word, and this seemed the simplest approach. Does anyone have a reference? +++++++++++++++++++++++++++ >From slasley@space.umd.edu (Scott E. Lasley) Date: Fri, 17 Oct 1997 20:01:32 -0400 Organization: UMD Space Physics Group In article <34465357.3E91@trw.com>, Russell Reece writes: > I have been trying to find a source document on how RTF is defined. > I need to interface with Microsoft Word, and this seemed the > simplest approach. Does anyone have a reference? you might try http://www.primate.wisc.edu/software/RTF/ it has documentation and source code for working with RTF files. hope this helps, SPAM dipped in liquid | Scott E. Lasley slasley@space.umd.edu nitrogen, thrown from on high. | http://umtof.umd.edu/pm/ Pink splinters scatter. | http://pemtropics.mit.edu/~jcho/spam/ +++++++++++++++++++++++++++ >From s.stapleton@NOBLOODYSPAM.easynet.co.uk (Simon Stapleton) Date: Thu, 23 Oct 1997 10:46:25 +0000 Organization: [posted via] Easynet UK In article <9710172001.AA32620@css-a2-69.umd.edu>, slasley@space.umd.edu (Scott E. Lasley) wrote: > In article <34465357.3E91@trw.com>, Russell Reece > writes: > > I have been trying to find a source document on how RTF is defined. > > I need to interface with Microsoft Word, and this seemed the > > simplest approach. Does anyone have a reference? > > you might try > > http://www.primate.wisc.edu/software/RTF/ > > it has documentation and source code for working with RTF files. > > hope this helps, Built an RTF-HTML convertor for a friend using this stuff. We had some problems with the format of RTF thrown out by word, however - it doesn't seem to match the specification supported by the RTF tools. On the other hand, I may have been doing something stupid. We ended up using the RTF tools but preconverting the files from Word's version of RTF to RTF using another package. It's pretty good code, though. +++++++++++++++++++++++++++ >From dent@highway1.com.au (Andy Dent) Date: Sun, 26 Oct 1997 15:37:44 +0800 Organization: A.D. Software In article <9710172001.AA32620@css-a2-69.umd.edu>, slasley@space.umd.edu (Scott E. Lasley) wrote: >In article <34465357.3E91@trw.com>, Russell Reece >writes: >> I have been trying to find a source document on how RTF is defined. >> I need to interface with Microsoft Word, and this seemed the >> simplest approach. RTF can be very very painful - if you get stuck we may be able to offer some advice. The only way to validate it is to use Word, and that can be very touchy if you get the syntax wrong. We've been through the mill a couple of times. Our OOFILE report writer has RTF export and we've developed an intranet-based document construction system that allows the user to combine chunks of RTF. -- Andy Dent, Software Designer, A.D. Software, Western Australia OOFILE - Database, reports, GUI for c++ on Mac, Unix & Windows http://www.highway1.com.au/adsoftware/ --------------------------- >From sarpskar@pgh.nauticom.net (Balaji Sarpeshkar ) Subject: Strange template problem (C++) Date: Wed, 22 Oct 1997 17:30:08 -0400 Organization: (none) I've been having a really bizarre problem with templates and derivation. I wrote a parameterized Array class, like the following: template class Array { // class definition here }; Then, I needed to write a class to utilize my Array while providing statistical values for an array of shorts (mean, median, etc.). To do this, I derived another template class from Array, like so: template class StatArray: public Array { // class definition here }; Anyway, that worked fine. The problem, however, comes when I have to make the program work with rational numbers, using a class I've already written. (This is for an AP Programming course, if you're wondering). To facilitate this (or so I thought), I tried to derive a non-template class from StatArray, like this: class RatArray: public StatArray Rational is the name of my rational number class, obviously. The problem is this: the StatArray class has a function called CalcFreqs(), which I use to calculate the frequency of each number in the array. This function is called from the StatArray constructor, which is passed a parameter from the RatArray constructor. I declared it as virtual in the StatArray class, and overrode(?) it in RatArray. However, every time I try to run the program, the StatArray version of the function is called, not the overridden one. Is there an experienced C++ programmer in the house who can help me? I'd appreciate any help you could give, as I need to finish this program to get credit for it :) - - Balaji Sarpeshkar sarpskar@pgh.nauticom.net - - Balaji's Mac Gaming Pages http://www.nauticom.net/www/sarpskar/index.html +++++++++++++++++++++++++++ >From i'm@not.here (Jeff Clites) Date: Thu, 23 Oct 1997 03:45:51 -0700 Organization: California Institute of Technology, Pasadena In article , sarpskar@pgh.nauticom.net (Balaji Sarpeshkar ) wrote: [...] >class RatArray: public StatArray > >Rational is the name of my rational number class, obviously. The problem >is this: the StatArray class has a function called CalcFreqs(), which I >use to calculate the frequency of each number in the array. This function >is called from the StatArray constructor, which is passed a parameter from >the RatArray constructor. I declared it as virtual in the StatArray class, >and overrode(?) it in RatArray. However, every time I try to run the >program, the StatArray version of the function is called, not the >overridden one. I think the problem may stem from the fact that when the StatArray constructor is call at construction time, the RatArray "part" if the object does not exist yet, and so the functions called from the base-class constructor are not overridden. This might be wrong, but it's what my intuition is telling me. - ------------------------------------------------------------------------ Jeff Clites Pasadena, California My account name is jac and the rest of my address has igor and caltech and edu, separated by dots. Don't spam me or anybody else (please). +++++++++++++++++++++++++++ >From demars@netcom.com (Dennis C. De Mars) Date: Thu, 23 Oct 1997 10:44:31 -0700 Organization: Hughes Aircraft Company In article , sarpskar@pgh.nauticom.net (Balaji Sarpeshkar ) wrote: : I've been having a really bizarre problem with templates and derivation. I : wrote a parameterized Array class, like the following: : : template : class Array : { : // class definition here : }; : : Then, I needed to write a class to utilize my Array while providing : statistical values for an array of shorts (mean, median, etc.). To do : this, I derived another template class from Array, like so: : : template : class StatArray: public Array : { : // class definition here : }; : : Anyway, that worked fine. The problem, however, comes when I have to make : the program work with rational numbers, using a class I've already : written. (This is for an AP Programming course, if you're wondering). To : facilitate this (or so I thought), I tried to derive a non-template class : from StatArray, like this: : : class RatArray: public StatArray : : Rational is the name of my rational number class, obviously. The problem : is this: the StatArray class has a function called CalcFreqs(), which I : use to calculate the frequency of each number in the array. This function : is called from the StatArray constructor, which is passed a parameter from : the RatArray constructor. I declared it as virtual in the StatArray class, : and overrode(?) it in RatArray. However, every time I try to run the : program, the StatArray version of the function is called, not the : overridden one. Is there an experienced C++ programmer in the house who : can help me? I'd appreciate any help you could give, as I need to finish : this program to get credit for it :) : The problem is that your virutal function override does not take effect until the constructor is finished running. That is, any virtual StatArray function called from the RatArray constructor will call the StatArray version, not the RatArray version. That's a standard C++ rule. The rationale is that any RatArray method (including those overriding virtual functions) should be able to assume that they are dealing with a fully constructed RatArray object, a condition that is clearly not true until the RatArray constructor is finished executing. Therefore, the RatArray virtual function table is not actually installed until the constructor exits. - Dennis D. --------------------------- >From c-p-o-s-t-o-n@rev.net (Curtis Poston) Subject: Using the current Desktop pattern Date: Sun, 26 Oct 1997 15:35:59 -0500 Organization: Roanoke Electronic Village Is there any way to figure out which desktop pattern is currently being used and use that inside of one of my applications? -- Curtis Poston |Remove the dashes between mail name c-p-o-s-t-o-n@rev.net |before replying. +++++++++++++++++++++++++++ >From Bill McElmury Date: Mon, 27 Oct 1997 09:04:43 -0600 Organization: JMC Inc Curtis Poston wrote: > > Is there any way to figure out which desktop pattern is currently being > used and use that inside of one of my applications? > > -- > Curtis Poston |Remove the dashes between mail name > c-p-o-s-t-o-n@rev.net |before replying. Sure is, Curtis: - ----------------------------------- Pattern deskPatternValue; PixPatHandle deskPixPattern; if (sysConfig.hasColorQD) { deskPixPattern = LMGetDeskCPat (); FillCRgn ( aRegion, deskPixPattern ); } else { LMGetDeskPattern (&deskPatternValue); FillRgn ( aRegion, &deskPatternValue ); } - ----------------------------------- Bill McElmury JMC Inc +++++++++++++++++++++++++++ >From Bill McElmury Date: Mon, 27 Oct 1997 09:08:37 -0600 Organization: JMC Inc Curtis Poston wrote: > > Is there any way to figure out which desktop pattern is currently being > used and use that inside of one of my applications? > Curtis, I forgot to tell you that the sysConfig.hasColorQDflag was set from a call to Gestalt. Later. Bill --------------------------- >From cwatson@cam.org (Sean McBride) Subject: [Q] How do I measure time between two close events... Date: Fri, 24 Oct 1997 23:21:39 -0400 Organization: Communications Accessibles Montreal, Quebec Canada I'm trying to determine the performance of some features of my program, and I have a few ways to do it, so I want to try both algorithms and see which is faster. Problem is that it takes at most 1 second to do, so calling GetTime () before and after yields a difference of 0 (or at best 1)... It's not very useful to know that 0 seconds ellapsed between events. What's a more precise way to get the time between two events? Thanks for any help! _________________________________________________________________________ H H | | | | | | Sean McBride | Life is like a pubic hair | H-C-C-O-H | cwatson@cam.org | on a toilet seat: | | | | Montreal, Canada | eventually, you get pissed off | H H | | | - ----------------------------------------------------------------------- +++++++++++++++++++++++++++ >From bradley@apple.com (Bob Bradley) Date: Fri, 24 Oct 1997 23:42:03 -0800 Organization: Uh huh huh...It says Organ In article , cwatson@cam.org (Sean McBride) wrote: > I'm trying to determine the performance of some features of my program, > and I have a few ways to do it, so I want to try both algorithms and see > which is faster. > > Problem is that it takes at most 1 second to do, so calling GetTime () > before and after yields a difference of 0 (or at best 1)... It's not very > useful to know that 0 seconds ellapsed between events. > > What's a more precise way to get the time between two events? Depending on the resolution you need, there are a number of ways to measure intervals smaller than a second. For course measurements, you can LMGetTicks to get 1/60 second resolution. You can use the Microseconds routine to get almost microsecond resolution (it has quite a bit of overhead). If you are on a PCI Mac, you can use UpTime() to get the amount of time the processor has been up in processor dependent units (AbsoluteTime) and can convert that to Nanoseconds using the AbsoluteToNanoseconds routine in DriverServicesLib. Using UpTime() is the most accurate method you can use to measure time. If you are just testing an algorithm, you may also be able to call your routine(s) multiple times in a loop and divide the total time taken by the number of times the algorithm was executed. +++++++++++++++++++++++++++ >From i'm@not.here (Jeff Clites) Date: Sat, 25 Oct 1997 19:50:11 -0700 Organization: California Institute of Technology, Pasadena In article , cwatson@cam.org (Sean McBride) wrote: >I'm trying to determine the performance of some features of my program, >and I have a few ways to do it, so I want to try both algorithms and see >which is faster. In addition to the other suggestions that someone posted, if you have CodeWarrior you can use the Profiler--that's what it's for. Take a look at the docs on CD, and run with it. - ------------------------------------------------------------------------ Jeff Clites Pasadena, California My account name is jac and the rest of my address has igor and caltech and edu, separated by dots. Don't spam me or anybody else (please). --------------------------- >From Stephen Kay <70714.1356@CompuServe.COM> Subject: bitfield question Date: Tue, 21 Oct 1997 21:04:57 -0400 Organization: TechniSound I am trying to used bitfields to designate a struct like this: typedef struct{ unsigned bit1: 1; unsigned bit2: 1; unsigned bit3: 1; unsigned bit4: 1; unsigned bit5: 1; unsigned bit6: 1; unsigned bit7: 1; unsigned bit8: 1; } BitStruct; The problem is this this struct seems to be 4 Bytes long, not 1 as I had hoped. Is this a limitiation of the bitfield declaration? Thanks, -- Stephen Kay - composer, producer, programmer +++++++++++++++++++++++++++ >From kaz@latte.cafe.net (Kaz) Date: 23 Oct 1997 04:58:04 -0700 Organization: Canada Internet Direct, Inc. In article <62n7jr$2iu$1@baygull.rtd.com>, Don Yuniskis wrote: >In article <344E1909.48E3@jmcinc.com>, Bill McElmury wrote: >Ask yourself if you *really* need to use bitfields or if some other >mechanism could suffice. If you really want to pack 8 bits into the >smallest possible storage unit, use bit masks instead. (even there you >can get screwed...) Providing a portable mechanism for compactly storing small integers is the one capability for which bitfields are excellent, so I would not advise dumping them for bit masks. It's a cleaner to write terminal[10]->echo = 0; than terminal[10]->flags &= ~T_ECHO; and it's probably not less efficient (unless the copmiler is truly poor). Only if you depend on the bitfield declarations to correspond to a particular storage layout do you run into portability problems. But for machine specific coding, even that capability of bitfields can be handy. In the original declaration that started this thread, you could replace the bit fields by an unsigned char. But dollars to doughnuts says that the structure will still be four bytes long, so you will only introduce inconvenience that buys you no saving in storage or efficiency. -- +++++++++++++++++++++++++++ >From dgy@rtd.com (Don Yuniskis) Date: 23 Oct 1997 21:09:52 GMT Organization: none In article <62ne4c$7vf$1@latte.cafe.net>, Kaz wrote: >In article <62n7jr$2iu$1@baygull.rtd.com>, Don Yuniskis wrote: >>In article <344E1909.48E3@jmcinc.com>, Bill McElmury wrote: > >>Ask yourself if you *really* need to use bitfields or if some other >>mechanism could suffice. If you really want to pack 8 bits into the >>smallest possible storage unit, use bit masks instead. (even there you >>can get screwed...) > >Providing a portable mechanism for compactly storing small integers is the one >capability for which bitfields are excellent, so I would not advise dumping >them for bit masks. It's a cleaner to write [snip] I was under the impression that the original poster was looking for a mechanism to "store eight bits in a byte". I.e. the emphasis being on *space* efficiency. While "bits" *could* be regarded as a degenerate form of "small integers", the use of bitfields make no guarantees in this regard. I've had far less portability problems packing bits with *masks* than I have with bitfields (i.e. the first time your "packed" array of such structures grows by a factor of four or more in a port, you quickly learn why bitfields aren't the answer! :>) --don +++++++++++++++++++++++++++ >From fred@genesis.demon.co.uk (Lawrence Kirby) Date: Fri, 24 Oct 97 12:27:16 GMT Organization: none In article <62osp3$pj3@sun001.spd.dsccc.com> jmccarty@sun1307.spd.dsccc.com "Mike McCarty" writes: >This is an illegal struct. Bitfields are not allowed to be unsigned >long or unsigned char or unsigned short. They are only allowed to be a >qualified or unqualified int. The permitted qualifiers are "const" and >"volatile". The standard supports int, signed int and unsigned int. Note that int and signed int are different when it comes to bit-fields, it is implementation-defined whether a plain int bit-field is signed or unsigned. -- - --------------------------------------- Lawrence Kirby | fred@genesis.demon.co.uk Wilts, England | 70734.126@compuserve.com - --------------------------------------- +++++++++++++++++++++++++++ >From Bill McElmury Date: Fri, 24 Oct 1997 10:41:13 -0600 Organization: JMC Inc Mike McCarty wrote: > > This is an illegal struct. Bitfields are not allowed to be unsigned > long or unsigned char or unsigned short. They are only allowed to be a > qualified or unqualified int. The permitted qualifiers are "const" and > "volatile". > > If you use these techniques, then be aware that you are no longer using > C. I'm not saying "Don't do this!" I'm saying, treat it exactly the way > you would treat making direct BIOS calls in an MSDOS environment using > int86() or similar constructs. It isn't C, and you shouldn't pretend it > is. Bury it in some access routine and don't let it out of its room. > > Mike > -- Okay, okay. I'm sorry. In the future I will try to avoid using unsigned short bit fields. I needed it way back when I converted from Think C to CodeWarrior to keep the structure the same size. And yes, I did need to keep the structure the same size. Anyway, thanks to everyone pointing out my not-quite-kosher use of the unsigned short bit fields. I honestly didn't know... Bill McElmury +++++++++++++++++++++++++++ >From jmccarty@sun1307.spd.dsccc.com (Mike McCarty) Date: 24 Oct 1997 01:14:11 GMT Organization: DSC Communications Corporation In article <344E1909.48E3@jmcinc.com>, Bill McElmury wrote: )Stephen Kay wrote: )> )> I am trying to used bitfields to designate a struct like this: )> )> typedef struct{ )> unsigned bit1: 1; )> unsigned bit2: 1; )> unsigned bit3: 1; )> unsigned bit4: 1; )> unsigned bit5: 1; )> unsigned bit6: 1; )> unsigned bit7: 1; )> unsigned bit8: 1; )> } BitStruct; )> )> The problem is this this struct seems to be 4 Bytes long, not 1 as I )> had hoped. Is this a limitiation of the bitfield declaration? ) )I had a similar problem before. It turned out that I needed to type )_unsigned short_ to get my bitfield to 2 bytes. If you just type )_unsigned_ the (my) compiler (CodeWarrior) assumed unsigned long (4 )bytes). ) )So if I were you I would try changing unsigned to unsigned char and see )what happens! ) )Bill McElmury )JMC Inc This is an illegal struct. Bitfields are not allowed to be unsigned long or unsigned char or unsigned short. They are only allowed to be a qualified or unqualified int. The permitted qualifiers are "const" and "volatile". If you use these techniques, then be aware that you are no longer using C. I'm not saying "Don't do this!" I'm saying, treat it exactly the way you would treat making direct BIOS calls in an MSDOS environment using int86() or similar constructs. It isn't C, and you shouldn't pretend it is. Bury it in some access routine and don't let it out of its room. Mike -- - -- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);} This message made from 100% recycled bits. I don't speak for DSC. <- They make me say that. +++++++++++++++++++++++++++ >From Stephen Kay <70714.1356@CompuServe.COM> Date: Sat, 25 Oct 1997 12:05:35 -0400 Organization: TechniSound kaz@latte.cafe.net: >In the original declaration that started this thread, you could >replace the bit fields by an unsigned char. But dollars to >doughnuts says that the structure will still be four bytes long, >so you will only introduce inconvenience that buys you no saving >in storage or efficiency. -- Actually, I posted the original question. Thanks to all who responded. As it turned out, if I declared the bitfields as unsigned short, the struct was 2 Bytes longs. If I declared the bitfields as unsigned char, it was still 2 Bytes long (due to struct alignment). Acually, in the interim, I went to using a single Byte with bit masks and bagging the bitfield thing. But thanks for the information - at least I know how it works now for the future. -- Stephen Kay - composer, producer, programmer +++++++++++++++++++++++++++ >From Brent Nelson Date: Wed, 22 Oct 1997 03:03:54 -0500 Orga +++++++++++++++++++++++++++ >From alain@cs.uchicago.edu (A. Roy) Date: Mon, 27 Oct 1997 15:39:56 GMT Organization: The Anti-Weather Forecasters Coalition In article <62ne4c$7vf$1@latte.cafe.net>, kaz@latte.cafe.net (Kaz) wrote: > them for bit masks. It's a cleaner to write > > terminal[10]->echo = 0; > > than > > terminal[10]->flags &= ~T_ECHO; flags stored as bits can be pretty clean if you do it right. In my C code, I write something like this: enum { _monster_is_in_use_bit, _monster_is_invisible_bit, NUMBER_OF_MONSTER_FLAGS, // we should assert that this is <= 32 somewhere. _monster_is_in_use = FLAG(_monster_is_in_use_bit), _monster_is_invisible = FLAG(_monster_is_invisible_bit) }; void assert_game_constants(void) { assert(NUMBER_OF_MONSTER_FLAGS <= 32); .... } Then I have three macros (inline functions if you prefer) that can be used like: SET_FLAG(monster->flags,_monster_is_in_use); CLEAR_FLAG(monster->flags,_monster_is_in_use); TEST_FLAG(monster->flags,_monster_is_in_use); Writing FLAG, SET_FLAG, CLEAR_FLAG, and TEST_FLAG and generalizing to integers larger than 1 bit is an exercise left to the reader. (Email me if you need help.) I find this code pretty clear, and I feel confident that it is more portable than bitfields, particularly when I store these flags to disk (which I often do). -alain --------------------------- >From mieczko1@acsu.buffalo.edu (Mark C Mieczkowski) Subject: which Macsbug for and 8600-300, macOS8? Date: 17 Oct 1997 05:38:18 GMT Organization: UB Does anyone know where the macsbug is for a PM8600/300 running system 8? I tried 6.5.4a3c1, which I believe is the latest version. TIA, Mark +++++++++++++++++++++++++++ >From gotow@stclairsw.com (Jon Gotow) Date: Fri, 17 Oct 1997 17:31:54 -0500 Organization: St. Clair Software In article <626tka$mev$1@prometheus.acsu.buffalo.edu>, mieczko1@acsu.buffalo.edu (Mark C Mieczkowski) wrote: > Does anyone know where the macsbug is for a PM8600/300 running system 8? > I tried 6.5.4a3c1, which I believe is the latest version. 6.5.4a3c1 is working fine on my 8600/300. What happens on yours? - Jon -- _____________________________________________________________________ Jon Gotow gotow@stclairsw.com St. Clair Software http://www.stclairsw.com/ Fax (330)549-3495 ftp://ftp.stclairsw.com/ +++++++++++++++++++++++++++ >From earl@netcom.com (Earl Vickers) Date: Sun, 19 Oct 1997 11:43:15 -0800 Organization: The Sound Guy In article <626tka$mev$1@prometheus.acsu.buffalo.edu>, mieczko1@acsu.buffalo.edu (Mark C Mieczkowski) wrote: > Does anyone know where the macsbug is for a PM8600/300 running system 8? > I tried 6.5.4a3c1, which I believe is the latest version. 6.5.4a3c1 should work fine with an 8600/300 and System 8. (It's at http://gemma.apple.com/MacOS8/) Apparently you can't rename MacsBug (for example, to "MacsBug 6.5.4a3c1") or it will crash on startup. +++++++++++++++++++++++++++ >From Online@MacTech.com ( nick.c MacTech ) Date: Thu, 23 Oct 1997 10:03:30 -0700 Organization: MacTech Magazine earl@netcom.com (Earl Vickers) wrote: >In article <626tka$mev$1@prometheus.acsu.buffalo.edu>, >mieczko1@acsu.buffalo.edu (Mark C Mieczkowski) wrote: > >> Does anyone know where the macsbug is for a PM8600/300 running system 8? >> I tried 6.5.4a3c1, which I believe is the latest version. > >6.5.4a3c1 should work fine with an 8600/300 and System 8. >(It's at http://gemma.apple.com/MacOS8/) > >Apparently you can't rename MacsBug (for example, to "MacsBug 6.5.4a3c1") >or it will crash on startup. I think that's always been the case with MacsBug. You used to have keep a preferences file in the system folder also, but that doesn't appear to be necessary anymore. BTW, Apple has put up a page with links to various developer tools and references for making the transition to Mac OS 8 (including the latest version of MacsBug 6.5.4--only versions 6.5.4 or later will work properly in Mac OS 8). That page is at: ____Nicholas C. DeMello, Ph.D.___________________________________________ "MacTech Online"--MacTech Magazine, for Mac OS Programmers and Developers http://www.MacTech.com/ _/ _/ _/ _/_/_/ _/ _/ Chemistry: Nick@chem.UCLA.edu _/_/ _/ _/ _/ _/ _/_/_/ MacTech: Online@MacTech.com _/ _/_/ _/ _/ _/ _/ http://www.chem.ucla.edu/~nick/ _/ _/ _/_/_/ _/ _/ +++++++++++++++++++++++++++ >From earl@netcom.com (Earl Vickers) Date: Thu, 23 Oct 1997 09:22:14 -0800 Organization: The Sound Guy > > Does anyone know where the macsbug is for a PM8600/300 running system 8? > > I tried 6.5.4a3c1, which I believe is the latest version. > > 6.5.4a3c1 should work fine with an 8600/300 and System 8. > (It's at http://gemma.apple.com/MacOS8/) > > Apparently you can't rename MacsBug (for example, to "MacsBug 6.5.4a3c1") > or it will crash on startup. Umm, what I meant to say is that it won't be loaded if you rename it. (A previous version of MacsBug crashes on startup with System 8.) Sorry for the disinformation. --------------------------- End of C.S.M.P. Digest **********************