home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-024 < prev    next >
Text File  |  2010-09-21  |  71KB  |  1,892 lines

  1. Received-Date: Sat, 7 May 1994 13:07:34 +0200
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-024
  4. To: csmp-digest@ens.fr
  5. Date: Sat, 7 May 94 13:07:29 MET DST
  6. X-Mailer: ELM [version 2.3 PL11]
  7. Errors-To: listman@ens.fr
  8. Reply-To: pottier@clipper.ens.fr
  9. X-Sequence: 26
  10.  
  11. C.S.M.P. Digest             Sat, 07 May 94       Volume 3 : Issue 24
  12.  
  13. Today's Topics:
  14.  
  15.         Anyone have routine for random numbers?
  16.         Async CD-ROM Drivers?
  17.         Comparing 2 LongDateTime's
  18.         Copying graphics the fast way (in assembler)
  19.         Favorite C++ Book?
  20.         Native PPC Interrupt Control?
  21.         SetDialogDefaultItem in a modal dialog
  22.         Symantec has an FTP site!
  23.         pascal and c libraries
  24.  
  25.  
  26.  
  27. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  28. (pottier@clipper.ens.fr).
  29.  
  30. The digest is a collection of article threads from the internet newsgroup
  31. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  32. regularly and want an archive of the discussions.  If you don't know what a
  33. newsgroup is, you probably don't have access to it.  Ask your systems
  34. administrator(s) for details.  If you don't have access to news, you may
  35. still be able to post messages to the group by using a mail server like
  36. anon.penet.fi (mail help@anon.penet.fi for more information).
  37.  
  38. Each issue of the digest contains one or more sets of articles (called
  39. threads), with each set corresponding to a 'discussion' of a particular
  40. subject.  The articles are not edited; all articles included in this digest
  41. are in their original posted form (as received by our news server at
  42. nef.ens.fr).  Article threads are not added to the digest until the last
  43. article added to the thread is at least two weeks old (this is to ensure that
  44. the thread is dead before adding it to the digest).  Article threads that
  45. consist of only one message are generally not included in the digest.
  46.  
  47. The digest is officially distributed by two means, by email and ftp.
  48.  
  49. If you want to receive the digest by mail, send email to listserv@ens.fr
  50. with no subject and one of the following commands as body:
  51.     help                        Sends you a summary of commands
  52.     subscribe csmp-digest Your Name    Adds you to the mailing list
  53.     signoff csmp-digest            Removes you from the list
  54. Once you have subscribed, you will automatically receive each new
  55. issue as it is created.
  56.  
  57. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  58. Questions related to the ftp site should be directed to
  59. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  60. digest are available there.
  61.  
  62. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  63.  
  64.  
  65. -------------------------------------------------------
  66.  
  67. >From truo8166@silver.SJSU.EDU (Thai Binh Truong)
  68. Subject: Anyone have routine for random numbers?
  69. Date: 21 Apr 94 20:47:04 GMT
  70. Organization: San Jose State University - Math/CS Dept.
  71.  
  72. I'm looking for a routine that will generate
  73. normally distributed random numbers.  If anyone
  74. know of any other routines that comes close to
  75. it, please post. Thanks in advance.
  76.  
  77. -Thai
  78.  
  79.  
  80. +++++++++++++++++++++++++++
  81.  
  82. >From Jim Conner <jc30@cornell.edu>
  83. Date: 22 Apr 1994 16:00:20 GMT
  84. Organization: Cornell University
  85.  
  86. Subject: Anyone have routine for random numbers?
  87. From: Thai Binh Truong, truo8166@silver.SJSU.EDU
  88. Date: 21 Apr 94 20:47:04 GMT
  89. In article <truo8166.766961224@sjsumcs.sjsu.edu> Thai Binh Truong,
  90. truo8166@silver.SJSU.EDU writes:
  91. >I'm looking for a routine that will generate
  92. >normally distributed random numbers.  If anyone
  93. >know of any other routines that comes close to
  94. >it, please post. Thanks in advance.
  95. >
  96. >-Thai
  97. >
  98.  
  99. Try looking in Numerical Recipes in Pascal (or C or Fortran, take your
  100. pick).  Each book in this set has several routines for generating uniform
  101. deviates as well as other types of distributions.  The routine for
  102. normally distributed random numbers looks like this (in Pascal):
  103.  
  104. { Global stuff... }
  105. GasdevIset: integer;
  106. GasdevGset: real;
  107. begin
  108.     GasdevIset := 0;
  109.  
  110. { Returns a normally distributed deviate with zero mean and unit
  111. variance,     }
  112. { using UniDev as the source of uniform deviates.                        
  113.        }
  114.  
  115.  function gasdev: extended;
  116.   var
  117.    fac, r, v1, v2: extended;
  118.  
  119.  begin
  120.   if GasdevIset = 0 then
  121.    begin
  122.     repeat
  123.      v1 := 2.0 * UniDev - 1.0;
  124.      v2 := 2.0 * UniDev - 1.0;
  125.      r := sqr(v1) + sqr(v2);
  126.     until (r < 1.0) and (r > 0.0);
  127.     fac := sqrt(-2.0 * ln(r) / r);
  128.     GasdevGset := v1 * fac;
  129.     gasdev := v2 * fac;
  130.     GasdevIset := 1
  131.    end
  132.   else
  133.    begin
  134.     GasdevIset := 0;
  135.     gasdev := GasdevGset;
  136.    end
  137.  end;
  138.  
  139. See Numerical Recipes for more details.
  140.  
  141. Jim Conner
  142.  
  143. +++++++++++++++++++++++++++
  144.  
  145. >From AppleGG@lamg.com (Gordon Apple)
  146. Date: 22 Apr 1994 11:55:56 -0800
  147. Organization: (none)
  148.  
  149. I'm looking for a routine that will generate
  150. normally distributed random numbers.  If anyone
  151. know of any other routines that comes close to
  152. it, please post. Thanks in advance.
  153.  
  154.  
  155.       I don't have the exact algorithms handy, but here are a couple of
  156. suggestions (assuming you already have a good uniformly distributed random
  157. number generator):
  158.  
  159.      If you are just doing things like usual statistics, then the simplest
  160. way is to generate a series of uniformly distributed variables and average
  161. them.  Even small series like 16 or so will give you very good results.
  162.  
  163.      If you're working far out on the tail (5 or 10 standard deviations),
  164. such as is often the case when working statistical communications problems,
  165. you need something better.  One of the best methods we found for our
  166. simulations was to take a pair of uniformly distributed random variables and
  167. use them to generate a pair of Gaussion rvs.  To do this, you need to use an
  168. exponential to map one variable into a Rayleigh amplitude distribution.  Use
  169. the other to generate a random angle from 0 to 2 * Pi.  Use sin and cos to
  170. get the two (independent) Gaussians.  Works great.  I've used it for years.
  171.  
  172. G. Gordon Apple, PhD
  173. Advanced ommunications Engineering, Inc.
  174. Redondo Beach, CA
  175.  
  176. +++++++++++++++++++++++++++
  177.  
  178. >From afcjlloyd@aol.com (AFC JLloyd)
  179. Date: 22 Apr 1994 19:52:06 -0400
  180. Organization: America Online, Inc. (1-800-827-6364)
  181.  
  182. In article <505016286.7954988@lamgnet.lamg.com>, AppleGG@lamg.com (Gordon
  183. Apple) writes:
  184.  
  185. >>>
  186.      If you're working far out on the tail (5 or 10 standard deviations),
  187. such as is often the case when working statistical communications problems,
  188. you need something better.  One of the best methods we found for our
  189. simulations was to take a pair of uniformly distributed random variables and
  190. use them to generate a pair of Gaussion rvs.  To do this, you need to use an
  191. exponential to map one variable into a Rayleigh amplitude distribution.  Use
  192. the other to generate a random angle from 0 to 2 * Pi.  Use sin and cos to
  193. get the two (independent) Gaussians.  Works great.  I've used it for years.
  194. <<<
  195.  
  196. Code to implement this technique can be found in "Numerical Recipes in C".
  197. The code given manages to avoid calling sin() and cos(), but it does require
  198. a log() and a sqrt() (and a float divide).  Here's the basic code:
  199.  
  200. do {
  201.    v1 = 2.0*ran() - 1.0;
  202.    v2 = 2.0*ran() - 1.0;
  203.    r = v1*v1 + v2*v2;
  204. } while (r >= 1.0);
  205. fac = sqrt(-2.0*log(r)/r);
  206.  
  207. ran() is a function returning a uniform deviate in the range 0.0 .. 1.0.
  208. After computing the above, you can now get two independent normal deviates
  209. by returning v1*fac and v2*fac.  The deviates have zero mean and unit variance.
  210.  
  211. Jim Lloyd
  212. afcjlloyd@aol.com
  213.  
  214.  
  215. ---------------------------
  216.  
  217. >From siegel@netcom.com (Rich Siegel)
  218. Subject: Async CD-ROM Drivers?
  219. Date: Wed, 13 Apr 1994 21:46:18 GMT
  220. Organization: Bare Bones Software
  221.  
  222.  
  223. (This is a philosophical question. If you can't spell "philosophy",
  224. you're excused. :-])
  225.  
  226. A number of us, having nothing better to do, were idly wondering about
  227. the pros and cons of the new SCSI Manager. One of its benefits is the
  228. ability to disconnect and reconnect (provided the device supports it),
  229. which leads directly to the ability for a driver to support async I/O
  230. operations.
  231.  
  232. This obviously works well for high-speed SCSI devices and copying.
  233. You can also perform some SCSI operations such as a format
  234. asynchronously at the application level (drivers rarely, if ever, need
  235. to format a disk); the app can issue the format, disconnect, and then
  236. handle UA and reconnect.
  237.  
  238. However, my colleagues and I can't pin down and specific technical
  239. benefits, besides the pure sex appeal, for supporting async I/O in a
  240. CD-ROM driver.
  241.  
  242. Are we missing something? Can someone, or several someones, enumerate
  243. the specific benefits for supporting async SCSI operation for CD-ROM
  244. drives?
  245.  
  246. For the benefit of all, please post to this newsgroup.
  247.  
  248. R.
  249.  
  250. -- 
  251. Rich Siegel % siegel@netcom.com    % Principal, Bare Bones Software
  252. --> For information about BBEdit, finger bbedit@world.std.com <--
  253.  
  254. "...yeah, I inhaled, and then I drank the bong water. So what're
  255. you gonna do about it?" - Dennis Miller, on Bill Clinton
  256.  
  257. +++++++++++++++++++++++++++
  258.  
  259. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  260. Date: Thu, 14 Apr 1994 00:25:43 -0500
  261. Organization: University of Illinois at Urbana-Champaign
  262.  
  263. In article <siegelCo7wH7.Lu5@netcom.com>, siegel@netcom.com (Rich Siegel) wrote:
  264.  
  265. >(This is a philosophical question. If you can't spell "philosophy",
  266. >you're excused. :-])
  267.  
  268. I think I can spell it pretty well.
  269.  
  270. >This obviously works well for high-speed SCSI devices and copying.
  271.  
  272. Why does anyone care about async I/O on a high-speed device other than
  273. pure sex appeal? On a high-speed device, I/O should happen so quickly that
  274. calling it async should have no effect to your program.
  275.  
  276. >However, my colleagues and I can't pin down and specific technical
  277. >benefits, besides the pure sex appeal, for supporting async I/O in a
  278. >CD-ROM driver.
  279. >
  280. >Are we missing something? Can someone, or several someones, enumerate
  281. >the specific benefits for supporting async SCSI operation for CD-ROM
  282. >drives?
  283.  
  284. The best reason for any async I/O on any device is multitasking. It drives
  285. me absolutely bananas that FSRead is written synchronously, because to
  286. read 1 Meg at a time, people call:
  287.  
  288.         buffPtr = NewPtr(1000000);
  289.         count = 1000000;
  290.         FSRead(refNum, &count, buffPtr);
  291.  
  292. This is ESPECIALLY horrible on a slow device, and worst over the network
  293. (consider going over a 9600 bps ARA link). Why can't people do it right
  294. and say:
  295.  
  296.         paramBlock->ioParam.ioCompletion = nil;
  297.         paramBlock->ioParam.ioRefNum = refNum;
  298.         paramBlock->ioParam.ioBuffer = NewPtr(1000000);
  299.         paramBlock->ioParam.ioReqCount = 1000000;
  300.         PBReadAsync(paramBlock);
  301.         while(paramBlock->ioParam.ioResult > noErr)
  302.             HandleEvents();
  303.  
  304. So, the reason that a CD-ROM drive should have async I/O is exactly
  305. because the damn things are slow. In all honesty, I don't see that there
  306. is any other reason to have async I/O except to allow you to call your
  307. event loop during I/O operations. Everything else is secondary.
  308.  
  309. Personally, I wish that FSRead called _Read asynchronously and provided a
  310. filterProc which could continue to receive events while the damn read was
  311. going on.
  312.  
  313. I am driven almost to tears every time I try to get anything done while
  314. doing copies in the Finder (which, contrary to its documentation, can't do
  315. a background copy to save its life) from a slow device because my machine
  316. either comes to a complete screeching halt or behaves so poorly that I
  317. can't get anything done (like typing a news article).
  318.  
  319. CD-ROM's should have async I/O before any device which is faster.
  320.  
  321. pr
  322. -- 
  323. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  324. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  325. System manager - Cognitive Science Group, Beckman Institute, UIUC
  326. Internet: resnick@cogsci.uiuc.edu
  327.  
  328. +++++++++++++++++++++++++++
  329.  
  330. >From zobkiw@datawatch.com (joe zobkiw)
  331. Date: Thu, 14 Apr 1994 13:20:42 GMT
  332. Organization: Datawatch Corporation
  333.  
  334. In article <resnick-140494002543@ruger-6.slip.uiuc.edu>,
  335. resnick@cogsci.uiuc.edu (Pete Resnick) wrote:
  336.  
  337. > CD-ROM's should have async I/O before any device which is faster.
  338.  
  339. Don't forget floppy disks...believe it or not...some people still use them!
  340. :)
  341.  
  342. ___________________________________________________________
  343. _/_/_/_/   Joe Zobkiw                                   ,,,
  344.     _/     Senior Software Engineer                     - -
  345.   _/       Datawatch Corporation                         L
  346. _/_/_/_/   zobkiw@datawatch.com                          -
  347.  
  348. +++++++++++++++++++++++++++
  349.  
  350. >From rmcassid@uci.edu (Robert Cassidy)
  351. Date: Thu, 14 Apr 1994 10:23:20 -0700
  352. Organization: TLG Project
  353.  
  354. In article <siegelCo7wH7.Lu5@netcom.com>, siegel@netcom.com (Rich Siegel)
  355. wrote:
  356.  
  357. > (This is a philosophical question. If you can't spell "philosophy",
  358. > you're excused. :-])
  359. > A number of us, having nothing better to do, were idly wondering about
  360. > the pros and cons of the new SCSI Manager. One of its benefits is the
  361. > ability to disconnect and reconnect (provided the device supports it),
  362. > which leads directly to the ability for a driver to support async I/O
  363. > operations.
  364. > This obviously works well for high-speed SCSI devices and copying.
  365. > You can also perform some SCSI operations such as a format
  366. > asynchronously at the application level (drivers rarely, if ever, need
  367. > to format a disk); the app can issue the format, disconnect, and then
  368. > handle UA and reconnect.
  369. > However, my colleagues and I can't pin down and specific technical
  370. > benefits, besides the pure sex appeal, for supporting async I/O in a
  371. > CD-ROM driver.
  372. > Are we missing something? Can someone, or several someones, enumerate
  373. > the specific benefits for supporting async SCSI operation for CD-ROM
  374. > drives?
  375. > For the benefit of all, please post to this newsgroup.
  376.  
  377. Well, here's a prime example. I work in a place where we take ancient Greek
  378. writings (all of 'em) and encode them on CD-ROM. We sent our our first CD
  379. about 8 years ago - we were one of the first. The CD contains about 500MB
  380. of data, and only about 20MB of indices :-(  As the first CD's were going
  381. out a decision was made to create a machine dedicated to searching through
  382. our CD looking for particular instances of words. The machine was based on
  383. an 8MHz 68000 but at 8MHz it was just fast enough to search data at the
  384. same rate that it came in (asynchronously) from the CD-ROM drive
  385. (150K/sec). The whole process takes about 50 minutes.
  386.  
  387. Most users of our CD are Mac users (~50% worldwide). My Q800 with a 300CD
  388. can search the CD in exactly the same amount of time as the 68000 above
  389. because there is no asynchrounous. I've determined that if I rewrote the
  390. Mac search programs (And I just might) that I would have the following
  391. results:
  392.  
  393. For a full search (500MB)
  394.  
  395.                       running time          processing time
  396. PM6100 async         ~30min                                                                <5min
  397. PM6100 sync          ~35min                ~35min
  398.  
  399. The running time (when the program starts to when the program quits)
  400. doesn't change much - but the processing time (how much I can't give back
  401. to the system) drops drastically. So in 30 minutes (a lot of time in my
  402. opinion) the user can recover 25 of it for other things and probably won't
  403. even know the background task is running.
  404.  
  405. Just for measure. We have an HP1000 that most of our work is done on. It
  406. takes about 6 hours for a full search with no other users on the system. A
  407. PM8100 working asynchronously from HD could do it in under 5 min.
  408.  
  409. -- 
  410. Robert Cassidy
  411. TLG Project
  412. UC Irvine
  413.  
  414. Let's hope 'Information SuperTollroad' isn't the catchphrase of the next
  415. decade...
  416.  
  417. +++++++++++++++++++++++++++
  418.  
  419. >From rang@winternet.mpls.mn.us (Anton Rang)
  420. Date: 15 Apr 1994 00:13:30 GMT
  421. Organization: Minnesota Angsters
  422.  
  423. In article <zobkiw-140494082042@zobkiw.datawatch.com> zobkiw@datawatch.com (joe zobkiw) writes:
  424. >In article <resnick-140494002543@ruger-6.slip.uiuc.edu>,
  425. >resnick@cogsci.uiuc.edu (Pete Resnick) wrote:
  426. >> 
  427. >> CD-ROM's should have async I/O before any device which is faster.
  428. >> 
  429. >
  430. >Don't forget floppy disks...believe it or not...some people still use them!
  431. >:)
  432.  
  433.   But they've had asynchronous I/O since the very first Macs!
  434.  
  435.   (Believe it or not....)
  436. --
  437. Anton Rang (rang@winternet.mpls.mn.us)
  438.  
  439. +++++++++++++++++++++++++++
  440.  
  441. >From Steve Bryan <sbryan@maroon.tc.umn.edu>
  442. Date: Sun, 17 Apr 1994 16:47:49 GMT
  443. Organization: Sexton Software
  444.  
  445. In article <zobkiw-140494082042@zobkiw.datawatch.com> joe zobkiw,
  446. zobkiw@datawatch.com writes:
  447. >Don't forget floppy disks...believe it or not...some people still use
  448. them!
  449.  
  450. I was under the impression that the driver for the floppy drive was (and
  451. has been) asynchronous. The fact that it disables interrupts causing
  452. mouse movement to become eratic diminishes the possible benefit of being
  453. asynchronous.
  454. Steve Bryan                  InterNet: sbryan@maroon.tc.umn.edu
  455. Sexton Software            CompuServe: 76545,527
  456. Minneapolis, MN                   Fax: (612) 929-1799
  457.  
  458. +++++++++++++++++++++++++++
  459.  
  460. >From Brad Koehn <koehn@macc.wisc.edu>
  461. Date: 18 Apr 1994 02:32:37 GMT
  462. Organization: University of Wisconsin
  463.  
  464. In article <zobkiw-140494082042@zobkiw.datawatch.com> joe zobkiw,
  465. zobkiw@datawatch.com writes:
  466. >> 
  467. >> CD-ROM's should have async I/O before any device which is faster.
  468. >> 
  469. >
  470. >Don't forget floppy disks...believe it or not...some people still use
  471. them!
  472. >:)
  473.  
  474. Floppy I/O is asynchronous, check out a copy of Disk Charmer. It lets you
  475. format floppies in the background. It's pretty chunky on my Duo, but it
  476. works perfectly on a PPC.
  477.  
  478. _________________________________________________________________________
  479. Brad Koehn          Data Transformations, Inc.        koehn@macc.wisc.edu
  480.  
  481. +++++++++++++++++++++++++++
  482.  
  483. >From bell@apple.com (Mike Bell)
  484. Date: Wed, 20 Apr 1994 17:34:46 GMT
  485. Organization: Apple Computer, Inc.
  486.  
  487. In article <siegelCo7wH7.Lu5@netcom.com>, siegel@netcom.com (Rich Siegel) 
  488. writes:
  489. > Newsgroups: comp.sys.mac.programmer 
  490. > Path: gallant.apple.com!apple.com!taligent!ames!hookup!swrinde!ihnp4.
  491. > ucsd.edu!library.ucla.edu!news.ucdavis.edu!csus.edu!netcom.com!siegel 
  492. > From: siegel@netcom.com (Rich Siegel) 
  493. > Subject: Async CD-ROM Drivers? 
  494. > Message-ID: <siegelCo7wH7.Lu5@netcom.com> 
  495. > Organization: Bare Bones Software 
  496. > Date: Wed, 13 Apr 1994 21:46:18 GMT 
  497. > Lines: 33 
  498. > (This is a philosophical question. If you can't spell "philosophy", you'
  499. > re excused. :-]) 
  500. > A number of us, having nothing better to do, were idly wondering about 
  501. > the pros and cons of the new SCSI Manager. One of its benefits is the 
  502. > ability to disconnect and reconnect (provided the device supports it), 
  503. > which leads directly to the ability for a driver to support async I/O 
  504. > operations. 
  505. > This obviously works well for high-speed SCSI devices and copying. 
  506. > You can also perform some SCSI operations such as a format 
  507. > asynchronously at the application level (drivers rarely, if ever, need 
  508. > to format a disk); the app can issue the format, disconnect, and then 
  509. > handle UA and reconnect. 
  510. > However, my colleagues and I can't pin down and specific technical 
  511. > benefits, besides the pure sex appeal, for supporting async I/O in a 
  512. > CD-ROM driver. 
  513. > Are we missing something? Can someone, or several someones, enumerate 
  514. > the specific benefits for supporting async SCSI operation for CD-ROM 
  515. > drives? 
  516. > For the benefit of all, please post to this newsgroup. 
  517. > R. 
  518. > -- 
  519. > Rich Siegel % siegel@netcom.com    % Principal, Bare Bones Software 
  520. > --> For information about BBEdit, finger bbedit@world.std.com <-- 
  521. > "...yeah, I inhaled, and then I drank the bong water. So what're 
  522. > you gonna do about it?" - Dennis Miller, on Bill Clinton 
  523. >  
  524.  
  525.  
  526.  Having async I/O in a CD ROM driver is very useful. It allows you to do 
  527. something with the data that you just read while simultaneously reading 
  528. another chunk off of the SLOW CD ROM drive. So, if a program is smart enough 
  529. to use multiple async reads from disc, effective throughput is greatly 
  530. increased by the async driver.
  531.  
  532.     
  533.      -Mike
  534.  
  535.  
  536.  
  537.     
  538.  
  539.  
  540. ****************************************************************************
  541. Mike Bell                                                     email: bell@apple.com
  542. Rock and Roll Project
  543. 2 Infinite Loop    MS: 302-3SB
  544. Cupertino, CA  95014
  545.  
  546.  
  547.  
  548. +++++++++++++++++++++++++++
  549.  
  550. >From jens_alfke@powertalk.apple.com (Jens Alfke)
  551. Date: 21 Apr 94 01:03:58 GMT
  552. Organization: Apple Computer
  553.  
  554. Pete Resnick, resnick@cogsci.uiuc.edu writes:
  555. > Why does anyone care about async I/O on a high-speed device other than
  556. > pure sex appeal? On a high-speed device, I/O should happen so quickly that
  557. > calling it async should have no effect to your program.
  558.  
  559. By those standards I guess a RAM disk might qualify as "high speed" but not
  560. anything else! My hard disk has a 14ms access time, and think of how much the
  561. 25MHz 040 in my now-lowly Quadra 700 could get done during those 350,000
  562. clock cycles.
  563.  
  564. I was under the impression that the CD-ROM driver already did async I/O.
  565. Doesn't QuickTime decode and render one frame while it's reading the next one
  566. from the disk?
  567.  
  568. > I am driven almost to tears every time I try to get anything done while
  569. > doing copies in the Finder (which, contrary to its documentation, can't do
  570. > a background copy to save its life) from a slow device because my machine
  571. > either comes to a complete screeching halt or behaves so poorly that I
  572. > can't get anything done (like typing a news article).
  573.  
  574. You need the "ALLRight" utilities from MSA software. It has a background
  575. copying feature (which used to be a standalone utility called COPYright) that
  576. makes copies a breeze. Finder copies are forwarded to a small app that runs
  577. in the background. It does all its I/O asynchronously, with little CPU
  578. hogging even when copying to/from a floppy, a slow file server, or over ARA.
  579. It'll do multiple copies at a time, too.
  580. The other utilities in the package are not too original (a Helium clone, a
  581. very weak SuperBoomerang clone, a BeHierarchic clone, etc.) and have some
  582. serious bugs, but the copy utility is worth the price of the package.
  583.  
  584. --Jens Alfke
  585.   jens_alfke@powertalk              Rebel girl, rebel girl,
  586.             .apple.com              Rebel girl you are the queen of my world
  587.  
  588. +++++++++++++++++++++++++++
  589.  
  590. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  591. Date: Wed, 20 Apr 1994 21:47:49 -0500
  592. Organization: University of Illinois at Urbana-Champaign
  593.  
  594. In article <1994Apr21.010358.20490@gallant.apple.com>,
  595. jens_alfke@powertalk.apple.com (Jens Alfke) wrote:
  596.  
  597. >Pete Resnick, resnick@cogsci.uiuc.edu writes:
  598. >> Why does anyone care about async I/O on a high-speed device other than
  599. >> pure sex appeal? On a high-speed device, I/O should happen so quickly that
  600. >> calling it async should have no effect to your program.
  601. >
  602. >By those standards I guess a RAM disk might qualify as "high speed" but not
  603. >anything else! My hard disk has a 14ms access time, and think of how much the
  604. >25MHz 040 in my now-lowly Quadra 700 could get done during those 350,000
  605. >clock cycles.
  606.  
  607. I agree completely. I was just playing with what Rich Siegel said. Every
  608. external device should support asynchronous I/O because every external
  609. device is going to be really slow.
  610.  
  611. >> I am driven almost to tears every time I try to get anything done while
  612. >> doing copies in the Finder (which, contrary to its documentation, can't do
  613. >> a background copy to save its life) from a slow device because my machine
  614. >> either comes to a complete screeching halt or behaves so poorly that I
  615. >> can't get anything done (like typing a news article).
  616. >
  617. >You need the "ALLRight" utilities from MSA software. It has a background
  618. >copying feature (which used to be a standalone utility called COPYright) that
  619. >makes copies a breeze. Finder copies are forwarded to a small app that runs
  620. >in the background. It does all its I/O asynchronously, with little CPU
  621. >hogging even when copying to/from a floppy, a slow file server, or over ARA.
  622. >It'll do multiple copies at a time, too.
  623.  
  624. But why can't the Finder do this?? Why is it that I need yet another patch
  625. trapping, memory using (no matter how small) extra utility that does
  626. something that could be done infinitely more easily in the Finder, which
  627. should have done it in the first place? The code to write this into the
  628. Finder itself is trivial. This is just a case of sloppy programming that
  629. needs to be fixed, not extra functionality that a third-party program
  630. should be solving.
  631.  
  632. pr
  633. -- 
  634. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  635. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  636. System manager - Cognitive Science Group, Beckman Institute, UIUC
  637. Internet: resnick@cogsci.uiuc.edu
  638.  
  639. +++++++++++++++++++++++++++
  640.  
  641. >From rmcassid@uci.edu (Robert Cassidy)
  642. Date: Thu, 21 Apr 1994 12:19:25 -0800
  643. Organization: TLG Project
  644.  
  645. In article <resnick-200494214749@resnick.isdn.uiuc.edu>,
  646. resnick@cogsci.uiuc.edu (Pete Resnick) wrote:
  647.  
  648. [stuff deleted]
  649.  
  650. > >> I am driven almost to tears every time I try to get anything done while
  651. > >> doing copies in the Finder (which, contrary to its documentation, can't do
  652. > >> a background copy to save its life) from a slow device because my machine
  653. > >> either comes to a complete screeching halt or behaves so poorly that I
  654. > >> can't get anything done (like typing a news article).
  655. > >
  656. > >You need the "ALLRight" utilities from MSA software. It has a background
  657. > >copying feature (which used to be a standalone utility called COPYright) that
  658. > >makes copies a breeze. Finder copies are forwarded to a small app that runs
  659. > >in the background. It does all its I/O asynchronously, with little CPU
  660. > >hogging even when copying to/from a floppy, a slow file server, or over ARA.
  661. > >It'll do multiple copies at a time, too.
  662.  
  663. Well, not to be an ass or anything but COPYright and Copydoubler don't
  664. always (do they ever) do asynchronous I/O. Those programs work on my Color
  665. Classic and it doesn't support asynch I/O to SCSI. They do their magic just
  666. in stolen cycles  (it's much slower in the background than in the
  667. forground) and actually do their work synchronously (at least on non 040
  668. machines). I know it's picking nits but it is an async discussion...
  669.  
  670. > But why can't the Finder do this?? Why is it that I need yet another patch
  671. > trapping, memory using (no matter how small) extra utility that does
  672. > something that could be done infinitely more easily in the Finder, which
  673. > should have done it in the first place? The code to write this into the
  674. > Finder itself is trivial. This is just a case of sloppy programming that
  675. > needs to be fixed, not extra functionality that a third-party program
  676. > should be solving.
  677.  
  678. Apple has been avoiding this situation in its more recent software
  679. (Powertalk at least) in that Powertalk runs as an appe instead of some big
  680. hunk of the system. That way it takes cycles just like any app. I think the
  681. biggest thing the Mac needs at this time is a threaded OS - spin the
  682. copying off on a thread - formatting floppies - launching apps - etc. etc.
  683. Apple has done really well in some things and poorly in others, Powertalk
  684. is *wonderful* in this regard, PrintMonitor is good, but the finder stuff
  685. _rots_. Isn't Apple working on a rewrite of the Finder, though? I thought I
  686. heard rumors of that for 7.8 or something (I don't think it is planned for
  687. 7.5)
  688.  
  689. -- 
  690. Robert Cassidy
  691. TLG Project
  692. UC Irvine
  693.  
  694. Let's hope 'Information SuperTollroad' isn't the catchphrase of the next
  695. decade...
  696.  
  697. +++++++++++++++++++++++++++
  698.  
  699. >From rang@winternet.mpls.mn.us (Anton Rang)
  700. Date: 21 Apr 1994 05:54:04 GMT
  701. Organization: Minnesota Angsters
  702.  
  703. In article <9404200934.AA46914@Sort-of-a-900.Apple.com> bell@apple.com (Mike Bell) writes:
  704. > Having async I/O in a CD ROM driver is very useful. It allows you to do 
  705. >something with the data that you just read while simultaneously reading 
  706. >another chunk off of the SLOW CD ROM drive. So, if a program is smart enough 
  707. >to use multiple async reads from disc, effective throughput is greatly 
  708. >increased by the async driver.
  709.  
  710.   In particular, newer QuickTime versions (from 1.5 or 1.6, I forget
  711. which) take advantage of this to overlap i/o and decompression....
  712. --
  713. Anton Rang (rang@winternet.mpls.mn.us)
  714.  
  715. ---------------------------
  716.  
  717. >From srussell@reed.edu (Steven J. Russell)
  718. Subject: Comparing 2 LongDateTime's
  719. Date: 19 Apr 1994 21:08:02 GMT
  720. Organization: Reed College,  Portland, Oregon
  721.  
  722.  
  723. I have a routine that compares two LongDateTime variables and tells me
  724. if the first one is before the second one.  Unfortunately, it converts
  725. the LongDateTime types to LongDateRec types via LongSecs2Date and then
  726. compares the old date format values, branching out at the appropriate
  727. moment.
  728.  
  729. What I would like to do is skip the conversion to LongDateRec's and then
  730. compare the LongDateTime variables that are passed in.  Inside Mac: Text
  731. says that the LongDateTime is a 64-bit signed representation of the number
  732. of seconds since Jan 1, 1904.  So, I check the high-bit of both and compare
  733. the high-order and low-order longs.  Seems to work most of the time.  However,
  734. I get LongDateTime values that are negative using this scheme (high-order bit
  735. set) sometimes even though the date is, for instance, 18 April 1994!
  736.  
  737. Does anybody have code to compare LongDateTime's directly without conversion?
  738.  
  739. BTW, I am doing this for a speed optimization, sincemy program compares dates
  740. and times frequently.
  741.  
  742. Thanks,
  743. Steven Russell
  744. srussell@reed.edu
  745.  
  746. +++++++++++++++++++++++++++
  747.  
  748. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  749. Date: Wed, 20 Apr 1994 00:28:41 -0500
  750. Organization: University of Illinois at Urbana-Champaign
  751.  
  752. In article <2p1h7i$kk9@scratchy.reed.edu>, srussell@reed.edu (Steven J.
  753. Russell) wrote:
  754.  
  755. >What I would like to do is skip the conversion to LongDateRec's and then
  756. >compare the LongDateTime variables that are passed in.
  757.  
  758. This should be pretty easy. In Script.h is a typedef for LongDateCvt,
  759. which gives you the high and low long of each. Here's a routine that
  760. returns 1 if the first is greater, -1 if the first is less than, and 0 if
  761. the first is equal to the second:
  762.  
  763. short CompareLongDate(LongDateTime *time1, LongDateTime *time2)
  764. {
  765.     LongDateCvt temp1, temp2;
  766.     short returnVal;
  767.  
  768.     temp1.c = *time1;
  769.     temp2.c = *time2;
  770.     if(temp1.hl.lHigh > temp2.hl.lHigh) {
  771.         returnVal = 1;
  772.     } else if(temp1.hl.lHigh < temp2.hl.lHigh) {
  773.         returnVal =  -1;
  774.     } else {
  775.         if(temp1.hl.lLow > temp2.hl.lLow) {
  776.             returnVal = 1;
  777.         } else if(temp1.hl.lLow < temp2.hl.lLow) {
  778.             returnVal = -1;
  779.         } else {
  780.             returnVal = 0;
  781.         }
  782.         if(temp1.hl.lHigh < 0) {
  783.             returnVal = -returnVal;
  784.         }
  785.     }
  786.     return returnVal;
  787. }
  788.  
  789. Will that do it?
  790.  
  791. pr
  792. -- 
  793. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  794. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  795. System manager - Cognitive Science Group, Beckman Institute, UIUC
  796. Internet: resnick@cogsci.uiuc.edu
  797.  
  798. +++++++++++++++++++++++++++
  799.  
  800. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  801. Date: Thu, 21 Apr 1994 11:50:56 +0800
  802. Organization: NCRPDA, Curtin University
  803.  
  804. >What I would like to do is skip the conversion to LongDateRec's and then
  805. >compare the LongDateTime variables that are passed in.  Inside Mac: Text
  806. >says that the LongDateTime is a 64-bit signed representation of the number
  807. >of seconds since Jan 1, 1904.  So, I check the high-bit of both and compare
  808. >the high-order and low-order longs.  Seems to work most of the time.  However,
  809. >I get LongDateTime values that are negative using this scheme (high-order bit
  810. >set) sometimes even though the date is, for instance, 18 April 1994!
  811.  
  812. Well, LongDateTime is an 64-bit signed number.  But it's very unlikely
  813. that it fills more than 48 bits, right?  So why not take the bottom 24
  814. bits and the next 24 bits (and ignore the top 16 bits), and compare the
  815. top two first, and then the bottom two.  This only requires the date to be
  816. after 19040101, and before 2^48 seconds after that (8 million years I
  817. think :-).
  818.  
  819. type LongLongInt=record
  820.   hi:longInt;
  821.   lo:longInt;
  822. end;
  823.  
  824. var
  825.   c1,c2:LongDateTime;
  826.   l1,l2:LongLongInt;
  827. begin
  828.   l1:=LongLongInt(c1);
  829.   l1.hi:=BAND(BSL(l1.hi,8),$00FFFF00)+BAND(BSR(l1.lo,16),$000000FF);
  830.   l1.lo:=BAND(l1.lo,$00FFFFFF);
  831. ditto for l2
  832.   if l1.hi=l2.hi then
  833.     return l1.lo<l2.lo
  834.   else
  835.     return l1.hi<l2.hi
  836.   end-if
  837. end;
  838.  
  839. Something like that anyway,
  840.    Peter.
  841. _______________________________________________________________________
  842. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  843.  
  844. +++++++++++++++++++++++++++
  845.  
  846. >From sparent@mv.us.adobe.com (Sean Parent)
  847. Date: Thu, 21 Apr 1994 21:17:50 GMT
  848. Organization: Adobe Systems Incorporated
  849.  
  850. Since LongDateTime is declared as a comp why not just use ">" - should at
  851. least work in MPW C and Pascal.
  852.  
  853. Sean
  854. In article <peter.lewis-210494115056@rocky.curtin.edu.au>,
  855. peter.lewis@info.curtin.edu.au (Peter N Lewis) wrote:
  856. > >What I would like to do is skip the conversion to LongDateRec's and then
  857. > >compare the LongDateTime variables that are passed in.  Inside Mac: Text
  858. > >says that the LongDateTime is a 64-bit signed representation of the number
  859. > >of seconds since Jan 1, 1904.  So, I check the high-bit of both and compare
  860. > >the high-order and low-order longs.  Seems to work most of the time.  However,
  861. > >I get LongDateTime values that are negative using this scheme (high-order bit
  862. > >set) sometimes even though the date is, for instance, 18 April 1994!
  863. > Well, LongDateTime is an 64-bit signed number.  But it's very unlikely
  864. > that it fills more than 48 bits, right?  So why not take the bottom 24
  865. > bits and the next 24 bits (and ignore the top 16 bits), and compare the
  866. > top two first, and then the bottom two.  This only requires the date to be
  867. > after 19040101, and before 2^48 seconds after that (8 million years I
  868. > think :-).
  869. > type LongLongInt=record
  870. >   hi:longInt;
  871. >   lo:longInt;
  872. > end;
  873. > var
  874. >   c1,c2:LongDateTime;
  875. >   l1,l2:LongLongInt;
  876. > begin
  877. >   l1:=LongLongInt(c1);
  878. >   l1.hi:=BAND(BSL(l1.hi,8),$00FFFF00)+BAND(BSR(l1.lo,16),$000000FF);
  879. >   l1.lo:=BAND(l1.lo,$00FFFFFF);
  880. > ditto for l2
  881. >   if l1.hi=l2.hi then
  882. >     return l1.lo<l2.lo
  883. >   else
  884. >     return l1.hi<l2.hi
  885. >   end-if
  886. > end;
  887. > Something like that anyway,
  888. >    Peter.
  889. > _______________________________________________________________________
  890. > Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  891.  
  892. --
  893. Sean Parent
  894.  
  895. +++++++++++++++++++++++++++
  896.  
  897. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  898. Date: Sat, 23 Apr 1994 12:24:01 +0800
  899. Organization: NCRPDA, Curtin University
  900.  
  901. In article <sparent-210494141641@macb041.mv.us.adobe.com>,
  902. sparent@mv.us.adobe.com (Sean Parent) wrote:
  903.  
  904. >Since LongDateTime is declared as a comp why not just use ">" - should at
  905. >least work in MPW C and Pascal.
  906.  
  907. True - but it does it (at least in THINK Pascal) by calling zillions of
  908. _Pack4 (SANE) traps.  By the look of it, it converts the comp to an 80-bit
  909. floating point number and then compares it.  Not exactly efficient.  I
  910. just did a quick test on my LC3, and the SANE code for x<y required
  911. exactly ten times more time than the  code I posted.  Of course, on the
  912. PPC, things might well be different given the PPC executes floating point
  913. faster than integer anyway.
  914.    Peter.
  915. _______________________________________________________________________
  916. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  917.  
  918. ---------------------------
  919.  
  920. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  921. Subject: Copying graphics the fast way (in assembler)
  922. Date: Sat, 23 Apr 1994 18:38:29 GMT
  923. Organization: Demon Internet
  924.  
  925.  
  926. My (cheap) version of CopyBits, in assembler
  927. - ------------------------------------------
  928.  
  929.    After I mentioned in a previous note that I had written a custom
  930. copy routine, I got flooded with messages asking if I could post it for
  931. others to see or use. So, here it is!
  932.  
  933.    This code is taken directly from my new arcade game, to be released
  934. in the next couple of months. I know it may be possible to make the code
  935. faster, but it works fast enough for me. With this and similar routines
  936. in my game, I get an increase of up to 500% over CopyBits and CopyMask.
  937. This is mainly because I do far less checking than CopyBits does.
  938.  
  939.    Also note that (I assume unlike CopyBits) this code may actually draw
  940. to the screen when the electron beam is half way down the screen. So, the
  941. top half of your graphic may appear slightly after the bottom half. You
  942. need to read up on the Vertical Retrace manager and SlotVInstall if you
  943. want to "sync" your animation with the electron beam of the screen.
  944.  
  945.    The code copies a rectangle from an offscreen graphics world onto the
  946. screen. The following assumptions are made:
  947.  
  948. o   You're in 32-bit addressing mode
  949. o   The monitor is in 8-bit (256 colours/grays); 1 byte per pixel
  950. o   The cursor is hidden
  951. o   The source and destination rectangles are the same size
  952. o   The rectangles don't go off the screen or off the GWorld
  953. o   The rectangles are in coordinates which are local to the screen
  954.         (i.e. top left of screen is 0,0)
  955.  
  956.    There are four globals used:
  957.  
  958. o   gWorldPixMapBase is the pix map base address of the graphics world.
  959. You use GetGWorldPixMap to get the pix map, and then you use
  960. GetPixBaseAddr to get the base address.
  961.  
  962. o   gScreenPixMapBase is the pix map base address of the screen.
  963. You get the pix map from the GDHandle of the screen you're using. Then
  964. you use GetPixBaseAddr.
  965.  
  966.     If you're using the main monitor, you can get the GDHandle for that
  967. monitor by using GetMainDevice ().
  968.  
  969. o   gWorldRowByteCount is the rowBytes for the graphics world. You get
  970. it like this:
  971.  
  972. gWorldRowByteCount = (0x7FFF & (**tWorldPixMap).rowBytes);
  973.  
  974. o   gScreenRowByteCount is the rowBytes for the screen. You get it like
  975. this:
  976.  
  977. gScreenRowByteCount = (0x7FFF & (**tScreenPixMap).rowBytes);
  978.  
  979.  
  980.    I hope the code is useful to someone: you might try using the code,
  981. but it's much better if you read through and understand what's happening,
  982. and then use parts of it in your own game, animation app, or whatever.
  983.  
  984.    If you don't know how to read assembler, an excellent start is this
  985. book:
  986.  
  987. How to Write Macintosh Software
  988. by Scott Knaster
  989. Published by Addison Wesley
  990. ISBN 0-201-60805-7
  991.  
  992.    Have fun!
  993.  
  994.  
  995.  
  996.    Alex Metcalf
  997.    alex@metcalf.demon.co.uk
  998.  
  999.  
  1000. void RectCopy (Rect tSourceRect, Rect tDestRect)
  1001. {
  1002.         asm
  1003.         {
  1004.                 movem.l a0-a1/d0-d7, -(sp);
  1005.                 
  1006.                 move.l  gWorldPixMapBase, D0;
  1007.                 move.w  tSourceRect.top, D1;
  1008.                 ext.l   D1;
  1009.                 mulu.l  gWorldRowByteCount, D1;
  1010.                 add.l   D1, D0;
  1011.                 move.w  tSourceRect.left, D1;
  1012.                 ext.l   D1;
  1013.                 add.l   D1, D0;
  1014.                 move.l  D0, A0;     // A0 is the source
  1015.                 
  1016.                 move.l  gScreenPixMapBase, D0;
  1017.                 move.w  tDestRect.top, D1;
  1018.                 ext.l   D1;
  1019.                 mulu.l  gScreenRowByteCount, D1;
  1020.                 add.l   D1, D0;
  1021.                 move.w  tDestRect.left, D1;
  1022.                 ext.l   D1;
  1023.                 add.l   D1, D0;
  1024.                 move.l  D0, A1;     // A1 is the destination
  1025.                 
  1026.                 move.w  tSourceRect.right, D6;
  1027.                 move.w  tSourceRect.left, D0;
  1028.                 sub.w   D0, D6; 
  1029.                 ext.l   D6;         // D6 is the width of rect to copy
  1030.                 
  1031.                 move.l  gWorldRowByteCount, D2;
  1032.                 sub.l   D6, D2;     // D2 is the source row offset
  1033.                 
  1034.                 move.l  gScreenRowByteCount, D3;
  1035.                 sub.l   D6, D3;     // D3 is the destination row offset
  1036.                 
  1037.                 move.w  tSourceRect.bottom, D4;
  1038.                 move.w  tSourceRect.top, D0;
  1039.                 sub.w   D0, D4;
  1040.                 ext.l   D4;
  1041.                 subq.l  #1, D4;     // D6 is number of rows to copy
  1042.                 
  1043.                 moveq.l #4, D5;
  1044.                 
  1045.                 tst.l   D4;
  1046.                 ble.s   @6;
  1047.                 
  1048.                 move.l D6, D0;
  1049.                 divs.l D5, D0;
  1050.                 move.l D5, D7;
  1051.                 mulu.l D0, D7;
  1052.                 move.l D6, D1;
  1053.                 sub.l  D7, D1;
  1054.                 subq.l #1, D0;
  1055.                 subq.l #1, D1;
  1056.                 move.l D0, D6;
  1057.                 move.l D1, D7;
  1058.                 
  1059.                 @1;
  1060.                 tst.l D0;
  1061.                 blt.s @3;
  1062.                 
  1063.                 @2;
  1064.                 move.l (a0)+, (a1)+;
  1065.                 dbra d0,@2;
  1066.                 
  1067.                 @3;
  1068.                 tst.l D1;
  1069.                 blt.s @5;
  1070.                 
  1071.                 @4;
  1072.                 move.b (a0)+, (a1)+;
  1073.                 dbra d1,@4;
  1074.                 
  1075.                 @5;
  1076.                 adda.l D2, A0;
  1077.                 adda.l D3, A1;
  1078.                 move.l D6, D0;
  1079.                 move.l D7, D1;
  1080.                 dbra d4,@1;
  1081.                 
  1082.                 @6;
  1083.                 movem.l (sp)+, a0-a1/d0-d7;
  1084.         }
  1085. }
  1086.  
  1087.  
  1088. --
  1089. Alex Metcalf, Mac programmer in C, C++, HyperTalk, assembler
  1090.  
  1091. Internet, AOL, BIX: alex@metcalf.demon.co.uk            "Surely you
  1092. AppleLink:          alex@metcalf.demon.co.uk@internet#   can't be
  1093. CompuServe:         INTERNET:alex@metcalf.demon.co.uk    serious?"
  1094. Delphi:             alex@metcalf.demon.co.uk@inet#
  1095. FirstClass:         alex@metcalf.demon.co.uk,Internet   "I am serious...
  1096. Fax (UK):           (0570) 45636                         and don't call
  1097. Fax (US / Canada):  011 44 570 45636                     me Shirley."
  1098.  
  1099. ---------------------------
  1100.  
  1101. >From jake@dxal13.cern.ch (Bob Jacobsen)
  1102. Subject: Favorite C++ Book?
  1103. Date: Wed, 13 Apr 1994 21:50:36 GMT
  1104. Organization: CERN, the European Organization for Nuclear Research
  1105.  
  1106. What books do people recommend for C++ on the Mac?
  1107.  
  1108. Two suggestions have been:
  1109.  
  1110. 1) Learn C++ on the Macintosh, Dave Mark (1993).  Comes with Thin C++ and a
  1111. cheap (how much?) upgrade offer.
  1112.  
  1113. 2) Symantec C++ Programming for the Macintosh, Neil Rhodes and Julie
  1114. McKeehan
  1115.  
  1116. Neither of these is available at a local bookstore - if you had to order it
  1117. from the US and wait a month, which would you pick?
  1118.  
  1119. Bob Jacobsen, jake@afal01.cern.ch
  1120.  
  1121. +++++++++++++++++++++++++++
  1122.  
  1123. >From jaeger@kunikpok.icus.com (Jaeger)
  1124. Date: Thu, 14 Apr 94 11:36:11 CDT
  1125. Organization: Kunikpok Kennels and Komputers (Pet Project)
  1126.  
  1127. jake@dxal13.cern.ch (Bob Jacobsen) writes:
  1128.  
  1129. > What books do people recommend for C++ on the Mac?
  1130. > Two suggestions have been:
  1131. > 1) Learn C++ on the Macintosh, Dave Mark (1993).  Comes with Thin C++ and a
  1132. > cheap (how much?) upgrade offer.
  1133. > 2) Symantec C++ Programming for the Macintosh, Neil Rhodes and Julie
  1134. > McKeehan
  1135. > Neither of these is available at a local bookstore - if you had to order it
  1136. > from the US and wait a month, which would you pick?
  1137. > Bob Jacobsen, jake@afal01.cern.ch
  1138.  
  1139. Hi Bob,  
  1140. I can't tell you which one to get but I have the Rhodes and 
  1141. McKeehan book so I can tell you something about it.  The book is in three 
  1142. parts: The Symantec environment (120pp), Intro to C++ (200pp), Using TCL 
  1143. (180pp).  There are also several appendices, source listings and a disk 
  1144. with all the source from the book.  The authors say that the book is a 
  1145. practical approach not a comprehensive approach.  Believe them.  In my 
  1146. opinion the first section is a waste of space.  It repeats the 
  1147. information given in the Symantec manuals.  It is perhaps better than the 
  1148. material in the actual manuals :-/  but I think the space could have 
  1149. better been used to increase the size of sections two and three.  
  1150.  
  1151. The Intro to C++ section isn't that bad.  It gives you a lot of redundant 
  1152. information about how to use SC++ as does the first section.  It tells 
  1153. you how to use the class browser for instance (gee that's a toughie).  It 
  1154. has a long discussion of the global optimizer.  Apparently the authors 
  1155. wrote the book with a prerelease version of SC++6.0.  They go through 
  1156. excruciating detail (dissasembled code) to explain how the global 
  1157. optimizer works and of course they show all the places where it doesn't 
  1158. (didn't?) work.  IMHO most of this is useless.  The actual intro to C++' 
  1159. is useful and I learned some things from it.  It should have been longer 
  1160. and more complete.  For example the discussion of multiple inheritance is 
  1161. about 1.5 pages.  The discussion of segmentation of your project in the 
  1162. first section is about 2 pages.  Which do you think is more important?
  1163.  
  1164. The third section has six chapters with code examples in each.  I would 
  1165. say that these are informative.  There are some useful tips about using 
  1166. TCL and using C++ in these chapters.  However, this book doesn't cover 
  1167. some of the more advanced features of C++ like templates and friends (and 
  1168. probably others that I've never heard of).
  1169.  
  1170. I suppose that my problem was that I wanted an in-depth book about C++ 
  1171. that emphasized the Mac, and such a book doesn't exist.
  1172.  
  1173. There are a couple of annoying things about the book.  All the TCL 
  1174. documentation uses the terms 'instance variable' and 'method'.  The book 
  1175. uses the terms 'member variable' and 'member function' and never mentions 
  1176. that these are the same thing.  Also, the book uses an icon of a 5.25 
  1177. floppy next to many of the source code examples.  I wonder if the 
  1178. authors' 'Macs' use these :-/
  1179.  
  1180. Basically I don't think the book is worth US$40.  Also it's obsolete now 
  1181. that SC++7 and TCL 2.0 are out.  Look for the sequel.
  1182.  
  1183. Brian Stern  }:-{)}
  1184. Jaeger@fquest.com
  1185.  
  1186.  
  1187. +++++++++++++++++++++++++++
  1188.  
  1189. >From fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate)
  1190. Date: Fri, 15 Apr 1994 14:29:11 GMT
  1191. Organization: DCRT, NIH, Bethesda, MD
  1192.  
  1193. In addition to learning C++, I'm going to assume you want to learn how
  1194. to program in an object-oriented manner.  This is not trivial; it
  1195. involves learning a new way of approaching programming, and of thinking
  1196. about things.
  1197.  
  1198. I recommend the book "Developing Object-Oriented Software on the
  1199. Macintosh," by Goldstein and Alger.  It's part of the Macintosh
  1200. Inside-Out series from Addison-Wesley, though I don't have its
  1201. ISBN number handy.  I *do* know that it's Addison-Wesley #57065,
  1202. list price $24.95.
  1203.  
  1204. It's an excellent discussion of the theoretical foundations of why
  1205. object-oriented software development is good, why it's hard to learn,
  1206. and what you can do about it.  The book also presents a (IMHO good)
  1207. methodology and notation for developing OO software.
  1208.  
  1209. - -------------------------------------------------------------
  1210. Christopher Tate             |  "So he dropped the heart - 
  1211. MSD, Inc.                    |     the floor's clean."
  1212. fixer@faxcsl.dcrt.nih.gov    |                 - Sidney Harris
  1213.  
  1214. +++++++++++++++++++++++++++
  1215.  
  1216. >From John Brewer <jbrewer@wri.com>
  1217. Date: Sat, 16 Apr 1994 16:41:49 GMT
  1218. Organization: Wolfram Research, Inc.
  1219.  
  1220. In article <jake-130494225036@csacbl6.cern.ch> Bob Jacobsen,
  1221. jake@dxal13.cern.ch writes:
  1222. >What books do people recommend for C++ on the Mac?
  1223.  
  1224. I'd recommend some general C++ books to start out with.  Once you've
  1225. mastered the syntax and the key concepts of the language, then you can
  1226. branch out into platform-specific things like GUI frameworks.  Trying to
  1227. do everything at once will result in information overload.
  1228.  
  1229. If I were teaching a C++ class right now, I'd have the following books be
  1230. required reading:
  1231. Lippman, Stanley _The C++ Primer_ (If you don't know C) OR
  1232. Pohl, Ira(?) _C++ for C Programmers_ (If you do know C)
  1233. Budd, Timothy _An Introduction to Object Oriented Programming_
  1234.  
  1235. The following would be recommended supplemental reading:
  1236. Meyers, Scott _Effective C++_
  1237.  
  1238. You'll probably also want to pick up one or both of the following for
  1239. reference:
  1240. Stroustrup, Bjarne _The C++ Programming Language_
  1241. Ellis & Stroustrup _The Annotated C++ Reference Manual_
  1242.  
  1243. The reason I recommend either Lippman or Pohl is that, while Lippman is
  1244. probably the better book, it assumes you have no knowledge of C.  Since
  1245. Ihave over a decade of experience with C, I resent being told what a
  1246. "break" statement is again.  I also find that when I try to skip over
  1247. the stuff I already know, I invariably skip some new stuff by mistake. 
  1248. Pohl assumes you know C, and therefore only covers the differences.  I
  1249. appreciate this approach.
  1250.  
  1251. Budd is a general book on object-oriented programming.  It deals with
  1252. primarily with general concepts, not syntax, and has examples in C++,
  1253. Objective C, Object Pascal, and Smalltalk.  It introduces the concepts
  1254. of classes and inheritance, as well as responsibility-driven design and
  1255. CRC cards.
  1256.  
  1257. Meyers is the best _second_ book on C++ that I know of.  It contains a
  1258. lot of general tips for writing better code.  The introduction alone
  1259. explained copy constructors better than some entire books.
  1260.  
  1261. I don't recommend Stroustrup as an introduction to C++, as it is way too
  1262. terse, but you really need it and/or the ARM as a language reference.
  1263.  
  1264. Good luck!
  1265.  
  1266. John Brewer
  1267. Wolfram Research, Inc.
  1268. (but speaking for myself)
  1269.  
  1270. +++++++++++++++++++++++++++
  1271.  
  1272. >From nick@pitt.edu ( nick.c )
  1273. Date: 20 Apr 94 01:48:56 GMT
  1274. Organization: (none)
  1275.  
  1276. In Article <jake-130494225036@csacbl6.cern.ch>, jake@dxal13.cern.ch (Bob
  1277. Jacobsen) wrote:
  1278. >What books do people recommend for C++ on the Mac?
  1279. >
  1280. >Two suggestions have been:
  1281. >
  1282. >1) Learn C++ on the Macintosh, Dave Mark (1993).  Comes with Thin C++ and a
  1283. >cheap (how much?) upgrade offer.
  1284.  
  1285.    Dave's book is good (I have it), but is kind of a "vol 2" to his
  1286.     _Learn_C_on_the_Macintosh_, I think it would be hard to learn from
  1287.     unless you'd read "vol 1".  If you're already an ace at C - you'll
  1288.     probably get a lot out of it.
  1289.  
  1290.    I found an interesting book called _Symantec_C++_for_the_Macintosh:_
  1291.     the_Basics_, by John May and Judy Whittle.  It trys to explain
  1292.     C++ without refering to C, and is very specific to the Symantec
  1293.     environment.  Unlike the two books you mentioned, this one is 
  1294.     stand alone (kind of impressive when you think of what it's trying
  1295.     cover).  It's not as detailed as having a seperate book on
  1296.     C, on your environment, and on C++ - but it's very convenient to
  1297.     have most of that info in one cover, and have it all with respect
  1298.     to Symantec's environment.
  1299.  
  1300.                                         -- nick
  1301.  
  1302.  
  1303.  
  1304.    _/   _/  _/  _/_/_/   _/   _/  Sea Shells to C shells,  Waikiki to
  1305.   _/_/ _/  _/  _/   _/  _/_/_/     the Internet, a wave, is a wave...
  1306.  _/ _/_/  _/  _/       _/ _/
  1307. _/   _/  _/   _/_/_/  _/   _/  CompSrv: 71232,766 I-Net: Nick@pitt.edu
  1308.  
  1309.  
  1310. +++++++++++++++++++++++++++
  1311.  
  1312. >From wang_dj@dev.gdb.org (David J. Wang)
  1313. Date: Thu, 21 Apr 1994 00:24:07 GMT
  1314. Organization: Genome Database
  1315.  
  1316. nick.c (nick@pitt.edu) wrote:
  1317. >In Article <jake-130494225036@csacbl6.cern.ch>, jake@dxal13.cern.ch (Bob
  1318. >Jacobsen) wrote:
  1319. >>What books do people recommend for C++ on the Mac?
  1320. >>
  1321. >>Two suggestions have been:
  1322. >>
  1323. >>1) Learn C++ on the Macintosh, Dave Mark (1993).  Comes with Thin C++ and a
  1324. >>cheap (how much?) upgrade offer.
  1325.  
  1326. >   Dave's book is good (I have it), but is kind of a "vol 2" to his
  1327. >    _Learn_C_on_the_Macintosh_, I think it would be hard to learn from
  1328. >    unless you'd read "vol 1".  If you're already an ace at C - you'll
  1329. >    probably get a lot out of it.
  1330.  
  1331. I have a different opinion about this -- I Learn C on the Macintosh --
  1332. and found it to be inadequate in dealing with both C as well as the
  1333. Macintosh.  There is a minimal amount of information dealing with the
  1334. macintosh (I now have Macintosh C Programming Vol. and wouldn't know
  1335. what to do without iit -- although I wish I didn't have to pay $30 for
  1336. the source on disk), and a barely adequate amount of info. dealing
  1337. with C. I looked through Learn C++... today, and it appeared to be the same
  1338. situation. 
  1339.  
  1340. I hear from others around here that the Pohl book is very good
  1341. however, and I own C by Dissection (Pohl, Kelley).
  1342. --
  1343. *************************************************************************
  1344. David J. Wang                 #include <std_disclaimer>
  1345. wang_dj@gdb.org                 (410)614-0393
  1346. wang_dj@server.cs.jhu.edu         Biology@The Johns Hopkins University
  1347.                      Baltimore, Maryland 21210
  1348. ************************************************************************/
  1349.  
  1350. +++++++++++++++++++++++++++
  1351.  
  1352. >From bootstrap1@aol.com (Bootstrap1)
  1353. Date: 23 Apr 1994 22:56:02 -0400
  1354. Organization: America Online, Inc. (1-800-827-6364)
  1355.  
  1356. In Article <jake-130494225036@csacbl6.cern.ch>, jake@dxal13.cern.ch (Bob
  1357. Jacobsen) wrote:
  1358. > What books do people recommend for C++ on the Mac?
  1359.  
  1360. I bought Stroustrup's The C++ Programming Language a few years ago and really
  1361. didn't care for it.  I've looked for a really good book on the subject ever
  1362. since and last year came across Bruce Eckel's C++ Inside & Out.  For me, it hit
  1363. the nail on the head; it was easy to read, gave good examples, and, best of
  1364. all, gave insight on the workings of the language behind the scenes, something
  1365. a lot of C++ books neglect.
  1366.  
  1367. ---------------------------
  1368.  
  1369. >From jberry@teleport.com (James D. Berry)
  1370. Subject: Native PPC Interrupt Control?
  1371. Date: Thu, 14 Apr 1994 14:57:47 -0700
  1372. Organization: Consultant
  1373.  
  1374. Is there interface level support for disabling interrupts on the PowerMac?
  1375. I know that application code runs at User Level, but haven't tried hitting
  1376. the EE bit in the MSR (which I would presume would cause an exception that
  1377. might or might not get properly emulated). Is this the only level of
  1378. support? Or is there some hook into the nanokernel to set the interrupt
  1379. level?
  1380.  
  1381. This is required to enforce mutual exclusion (since we don't yet have good
  1382. kernel level support--I want V1/NuKernel!) and I don't want to enter the
  1383. emulator just to modify the interrupt level.
  1384.  
  1385. -- 
  1386. James Berry
  1387. jberry@teleport.com
  1388.  
  1389. +++++++++++++++++++++++++++
  1390.  
  1391. >From creiman@netcom.com (Charlie Reiman)
  1392. Date: Fri, 15 Apr 1994 07:07:27 GMT
  1393. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  1394.  
  1395. jberry@teleport.com (James D. Berry) writes:
  1396.  
  1397. >Is there interface level support for disabling interrupts on the PowerMac?
  1398. >I know that application code runs at User Level, but haven't tried hitting
  1399. >the EE bit in the MSR (which I would presume would cause an exception that
  1400. >might or might not get properly emulated). Is this the only level of
  1401. >support? Or is there some hook into the nanokernel to set the interrupt
  1402. >level?
  1403.  
  1404. >This is required to enforce mutual exclusion (since we don't yet have good
  1405. >kernel level support--I want V1/NuKernel!) and I don't want to enter the
  1406. >emulator just to modify the interrupt level.
  1407.  
  1408. I can't say for sure about disabling interrupts, but I have been
  1409. attacked by user mode limits on my PPC hacking. If all you need is
  1410. simple mutex stuff, get a 601 manual and look in the back for the code
  1411. examples covering mutuexes (mutexi? or is that a breakfast cereal...)
  1412. Or just look up information on load/store with reservation.
  1413. -- 
  1414. "You can't cancel the project! We already made the T-shirts!"
  1415. Charlie Reiman
  1416. creiman@netcom.com
  1417.  
  1418. +++++++++++++++++++++++++++
  1419.  
  1420. >From rang@winternet.mpls.mn.us (Anton Rang)
  1421. Date: 16 Apr 1994 00:02:23 GMT
  1422. Organization: Minnesota Angsters
  1423.  
  1424. In article <creimanCoAH4G.BJG@netcom.com> creiman@netcom.com (Charlie Reiman) writes:
  1425. >If all you need is simple mutex stuff, get a 601 manual and look in
  1426. >the back for the code examples covering mutuexes (mutexi? or is that
  1427. >a breakfast cereal...)  Or just look up information on load/store
  1428. >with reservation.
  1429.  
  1430.   That works great if you have two competing user-level threads.  If
  1431. you're trying to synchronize against interrupt-level routines (like an
  1432. I/O completion routine, driver, VBL task), you can't easily use a
  1433. mutex because there's no convenient way to ask the system to schedule
  1434. the running task for a later time.
  1435.  
  1436.   Of course, you can always implement your own process scheduler and
  1437. run everything through it (I did this once for a Nubus card driver
  1438. back when I was young and foolish).  But it's very difficult to make
  1439. sure that every case is properly handled, and it shouldn't be that
  1440. much work....
  1441. --
  1442. Anton Rang (rang@winternet.mpls.mn.us)
  1443.  
  1444. +++++++++++++++++++++++++++
  1445.  
  1446. >From rang@winternet.mpls.mn.us (Anton Rang)
  1447. Date: 15 Apr 1994 00:23:58 GMT
  1448. Organization: Minnesota Angsters
  1449.  
  1450. In article <jberry-140494145747@ppp-005.teleport.com> jberry@teleport.com (James D. Berry) writes:
  1451. >Is there interface level support for disabling interrupts on the PowerMac?
  1452.  
  1453.   There is absolutely no documented way to do this, and I'm very leery
  1454. of digging into the nanokernel to do it.  I've had several engineers
  1455. from Apple tell me that I shouldn't even think about it.  No word yet
  1456. on whether this will be added at some point, though I've heard that
  1457. the group working on porting the Appletalk protocol stack has
  1458. requested such a capability.
  1459.  
  1460.   I understand *why* they don't want people messing with interrupts
  1461. (especially with Geoport support and such), but at the same time, it's
  1462. a major bottleneck in the driver-level work I'm doing.
  1463.  
  1464. >This is required to enforce mutual exclusion (since we don't yet have good
  1465. >kernel level support--I want V1/NuKernel!) and I don't want to enter the
  1466. >emulator just to modify the interrupt level.
  1467.  
  1468.   And if you enter the emulator, it only modifies the emulator's
  1469. interrupt level.  You can still get low-level interrupts, though I
  1470. believe that currently all system-call-back interrupts (e.g. VBL
  1471. tasks, Time Manager, etc.) go through the emulator and thus obey the
  1472. restriction.
  1473.  
  1474.   I need mutual exclusion for a memory pool (darn Memory Manager won't
  1475. run at interrupt time :-), and an allocation/free pair which takes 4us
  1476. in PPC code takes nearly 100us if I switch into and out of emulation
  1477. for it.  Really sucks.
  1478.  
  1479.  Anyone from Apple listening to our pleas?  (Anyone with the $$$ to be
  1480. an Apple Partner who might have clout enough to let us call the
  1481. nanokernel for this until NuKernel is out?)
  1482. --
  1483. Anton Rang (rang@winternet.mpls.mn.us)
  1484. >From Eric Anderson <eric_anderson@quickmail.apple.com>
  1485. Subject: Native PPC Interrupt Control?
  1486. Date: Tue, 19 Apr 1994 03:06:46 GMT
  1487. Organization: Apple Computer
  1488.  
  1489. Re: Native PPC Interrupt Control?
  1490.  
  1491.  
  1492. Yes, folks here at Apple are listening to your pleas. In fact, if you
  1493. look at the native Thread Manager, you will note the lack of preemptive
  1494. threads - this is because the native interrupt runtime model is not
  1495. exported outside the kernel. Yes, we need to wait for the new kernel
  1496. before we get such native niceties as native interrupt handling (in some
  1497. form(s)) to provide better I/O and tasking services both inside Apple and
  1498. from our developer community.
  1499.  
  1500. Eric Anderson
  1501. Mac OS
  1502. Apple Computer, Inc.
  1503.  
  1504. +++++++++++++++++++++++++++
  1505.  
  1506. >From benh@fdn.org (Benjamin Herrenschmidt)
  1507. Date: Tue, 19 Apr 94 23:01:05 +0100
  1508. Organization: (none)
  1509.  
  1510. >
  1511. >In article <RANG.94Apr14192358@icicle.winternet.mpls.mn.us> (comp.sys.mac.programmer), rang@winternet.mpls.mn.us (Anton Rang) writes:
  1512. >
  1513. >In article <jberry-140494145747@ppp-005.teleport.com> jberry@teleport.com (James D. Berry) writes:
  1514. >>Is there interface level support for disabling interrupts on the PowerMac?
  1515. >
  1516. >  There is absolutely no documented way to do this, and I'm very leery
  1517. >of digging into the nanokernel to do it.  I've had several engineers
  1518. >from Apple tell me that I shouldn't even think about it.  No word yet
  1519. >on whether this will be added at some point, though I've heard that
  1520. >the group working on porting the Appletalk protocol stack has
  1521. >requested such a capability.
  1522. >
  1523. >  I understand *why* they don't want people messing with interrupts
  1524. >(especially with Geoport support and such), but at the same time, it's
  1525. >a major bottleneck in the driver-level work I'm doing.
  1526. >
  1527. >>This is required to enforce mutual exclusion (since we don't yet have good
  1528. >>kernel level support--I want V1/NuKernel!) and I don't want to enter the
  1529. >>emulator just to modify the interrupt level.
  1530. >
  1531. >  And if you enter the emulator, it only modifies the emulator's
  1532. >interrupt level.  You can still get low-level interrupts, though I
  1533. >believe that currently all system-call-back interrupts (e.g. VBL
  1534. >tasks, Time Manager, etc.) go through the emulator and thus obey the
  1535. >restriction.
  1536. >
  1537. >  I need mutual exclusion for a memory pool (darn Memory Manager won't
  1538. >run at interrupt time :-), and an allocation/free pair which takes 4us
  1539. >in PPC code takes nearly 100us if I switch into and out of emulation
  1540. >for it.  Really sucks.
  1541. >
  1542. > Anyone from Apple listening to our pleas?  (Anyone with the $$$ to be
  1543. >an Apple Partner who might have clout enough to let us call the
  1544. >nanokernel for this until NuKernel is out?)
  1545. >--
  1546. >Anton Rang (rang@winternet.mpls.mn.us)
  1547.  
  1548. I completely agree with you ! as a Nubus card driver designer and
  1549. a low level developper (i work on drivers, interrupts, network software
  1550. etc...), a way to mask interrupts is VERY important. It is the only
  1551. way to do some tasks at interrupt level. Another VERY important thing
  1552. is to be able to do atomic read-test-modify like the TAS instruction
  1553. of the 68K to do semaphores. They are REQUIRED to work with "resources"
  1554. shared between several processors. (main processor and a DSP for example).
  1555.  
  1556. It would be a VERY BAD thing from apple to remove the ability of having
  1557. uninterruptible pieces of code and atomic semaphores.
  1558.  
  1559. I hope Apple will soon release a technote with everything we MUST
  1560. know about these. (remeber that not all macintoshes support the TAS
  1561. instruction which is really a pain when you have to build an interface
  1562. between the mac and another processor, on a PDS card for example).
  1563.  
  1564. Hey, Apple ! do you listen to us ? will you do it ?
  1565.  
  1566. BenH.
  1567.  
  1568.  
  1569. +++++++++++++++++++++++++++
  1570.  
  1571. >From mrustad@aol.com (MRustad)
  1572. Date: 23 Apr 1994 01:05:05 -0400
  1573. Organization: America Online, Inc. (1-800-827-6364)
  1574.  
  1575. In article <01050105.tk4phy@tatooine.fdn.org>, benh@fdn.org (Benjamin
  1576. Herrenschmidt) writes:
  1577.  
  1578. >I hope Apple will soon release a technote with everything we MUST
  1579. >know about these. (remeber that not all macintoshes support the TAS
  1580. >instruction which is really a pain when you have to build an interface
  1581. >between the mac and another processor, on a PDS card for example).
  1582.  
  1583. Ben,
  1584.  
  1585. TAS is not all that important. I did the multiprocessor interlocking for A/ROSE
  1586. and could not use TAS at all anywhere (even for single processor
  1587. locks) due to nasty bus error conditions that could arise with the 68000
  1588. coprocessors. In previous positions I worked on CDC Cybers that had a bunch of
  1589. processors in the box and nothing remotely like a TAS. There are lots of neat
  1590. tricks that really work better than TAS anyway.
  1591.  
  1592. Of course, you can continue to use the emulator, which does TAS for you, if it
  1593. is that important to you (but my stuff will run faster than yours!).
  1594.  
  1595. -Mark Rustad, mdr@apple.com
  1596.  
  1597. ---------------------------
  1598.  
  1599. >From walkerm@acf2.nyu.edu (Michael A. Walker)
  1600. Subject: SetDialogDefaultItem in a modal dialog
  1601. Date: Wed, 20 Apr 1994 09:15:01 -0500
  1602. Organization: New York University
  1603.  
  1604. Hi. Please forgive this question if it's a FAQ.  I'm trying to use 
  1605. SetDialogDefaultItem for a modal dialog and I'm having some
  1606. problems (well, one problem--it's not working ;-).  Within my 
  1607. routine that displays the dialog, I call SetDialogDefaultItem
  1608. as I'm suppose to do.  The problem comes in when I call
  1609. ModalDialog using my own dialog filter which is used to control
  1610. a read-only scrolling text region.  Somehow, the call to 
  1611. SetDialogDefaultItem is reversed or ignored since I added the
  1612. dialog filter.  Here is a snippet of the code:
  1613.  
  1614. void ShowAbout(void)
  1615. {
  1616.     DialogPtr        dialog;
  1617.     Boolean        dialogDone = false;
  1618.     short        itemHit, itemType;
  1619.  
  1620. /* deleted stuff */
  1621.     
  1622.     dialog = GetNewDialog(kAboutResID, nil, kMoveToFront);
  1623.     
  1624.     SetDialogDefaultItem(dialog, ok);
  1625.     SetDialogTracksCursor(dialog, true);
  1626.         
  1627. /* deleted stuff */
  1628.  
  1629.     ShowWindow(dialog);
  1630.     SetPort(dialog);
  1631.     
  1632.     GetDItem(dialog, ok, &itemType, &okItemHandle, &itemRect);    
  1633.     
  1634.     /* you guessed it, more deleted stuff */
  1635.     
  1636.     while (! dialogDone) {
  1637.         ModalDialog(AboutDlgFilter, &itemHit);
  1638.         switch (itemHit) {
  1639.             case ok:
  1640.                 dialogDone = true;
  1641.                 break;
  1642.         }
  1643.     }
  1644.     
  1645.     DisposDialog(dialog);
  1646. }
  1647.  
  1648. Is there something else I have to do?
  1649.  
  1650. Thanks in advance.
  1651.  
  1652. -- 
  1653. Michael A. Walker
  1654. New York University
  1655. walkerm@acf2.nyu.edu
  1656. ==============================================------------------------8-;
  1657. main() {int x,y,k;char *b=" .:,;!/>)|&IH%*#@";double
  1658. cr,ci,zr,zi,temp,cx,cy;
  1659. for(y=30;puts(""),cy=y*0.1-1.5,y-->=0;){for(x=0;cx=x*0.04-2,zr=0,zi=0,x++<75;)
  1660. {for(cr=cx,ci=cy,k=0;temp=zr*zr-zi*zi+cr,zi=2*zr*zi+ci,zr=temp,k<112;k++)
  1661. if(zr*zr+zi*zi>10)break;printf("%c",b[k%16]);}}}      /*  try this on for
  1662. size!!  */
  1663.  
  1664. +++++++++++++++++++++++++++
  1665.  
  1666. >From Kevin.R.Boyce@gsfc.nasa.gov (Kevin R. Boyce)
  1667. Date: Wed, 20 Apr 1994 12:46:05 -0400
  1668. Organization: NASA/GSFC
  1669.  
  1670. In article <walkerm-200494091501@walker.infocenter.nyu.edu>,
  1671. walkerm@acf2.nyu.edu (Michael A. Walker) wrote:
  1672.  
  1673. > Hi. Please forgive this question if it's a FAQ.  I'm trying to use 
  1674. > SetDialogDefaultItem for a modal dialog and I'm having some
  1675. > problems (well, one problem--it's not working ;-).  Within my 
  1676. > routine that displays the dialog, I call SetDialogDefaultItem
  1677. > as I'm suppose to do.  The problem comes in when I call
  1678. > ModalDialog using my own dialog filter which is used to control
  1679. > a read-only scrolling text region.  Somehow, the call to 
  1680. > SetDialogDefaultItem is reversed or ignored since I added the
  1681. > dialog filter.
  1682.  
  1683. You didn't include your dialog filter, but I bet it doesn't call the
  1684. standard filter proc.  Here's one that doesn't handle any dialog events,
  1685. but correctly passes update events on to other windows (this is taken
  1686. almost verbatim from the "Pending Update Perils" technote):
  1687.  
  1688. pascal Boolean BasicDlogFilter( DialogPtr currentDialog,
  1689.  EventRecord *theEventIn, short *theDialogItem)
  1690. {
  1691.     OSErr                myErr;
  1692.     ModalFilterProcPtr    standardProc;
  1693.     Boolean                returnVal = false;
  1694.     WindowPtr            temp;
  1695.     
  1696.     if( (theEventIn->what == updateEvt) &&
  1697.      (theEventIn->message != (long)currentDialog) )
  1698.     {
  1699.         returnVal = DoUpdate(theEventIn);    /* go to my update routine */  
  1700.     }
  1701.     else
  1702.     { 
  1703.         GetPort(&temp);
  1704.         SetPort(currentDialog);
  1705.         myErr = GetStdFilterProc((ProcPtr)&standardProc);
  1706.         if(!myErr)
  1707.             returnVal = standardProc( currentDialog, theEventIn, theDialogItem );
  1708.         SetPort(temp);
  1709.     }
  1710.     return(returnVal);
  1711. }
  1712.  
  1713. (Apologies if the formatting is screwed up.  Boy I wish NewsWatcher handled
  1714. tabs correctly.  Time to take another look at the source...)
  1715.  
  1716.  
  1717. -- 
  1718. Kevin      Kevin.R.Boyce@x500.gsfc.nasa.gov
  1719. You can blow out a candle, but you can't blow out a fire.
  1720. Once the flame begin to catch, the wind will blow it higher.
  1721.            --Peter Gabriel, 1980  (_Biko_)
  1722.  
  1723. +++++++++++++++++++++++++++
  1724.  
  1725. >From Stephan Bublava <stephan@iguwnext.tuwien.ac.at>
  1726. Date: 21 Apr 1994 06:08:54 GMT
  1727. Organization: Vienna University of Technology
  1728.  
  1729. In article <walkerm-200494091501@walker.infocenter.nyu.edu> Michael A.
  1730. Walker, walkerm@acf2.nyu.edu writes:
  1731.  
  1732. >Hi. Please forgive this question if it's a FAQ.  I'm trying to use 
  1733. >SetDialogDefaultItem for a modal dialog and I'm having some
  1734. >problems (well, one problem--it's not working ;-). 
  1735.  
  1736. >[snip]
  1737.  
  1738. >Somehow, the call to SetDialogDefaultItem is reversed or ignored
  1739. >since I added the dialog filter.
  1740.  
  1741. You must call the default filter from your modal dialog filter.
  1742. How to to this is described in the TechNote that describes the
  1743. new Dialog Manager routines.
  1744.  
  1745. Stephan
  1746.  
  1747. --
  1748. Stephan Bublava
  1749. stephan@iguwnext.tuwien.ac.at
  1750.  
  1751. ---------------------------
  1752.  
  1753. >From baileyc@gmg.com (Christopher R. Bailey)
  1754. Subject: Symantec has an FTP site!
  1755. Date: 22 Apr 1994 15:34:28 GMT
  1756. Organization: DejaView Software, Inc.
  1757.  
  1758. Maybe most of you already know this, but I didn't and I've never seen anything
  1759. about it.  I was sick of waiting for the CPlusLib update from Symantec for
  1760. 7.0.  So I called them, and the guy told me to ftp to their site:
  1761.  
  1762.     devtools.symantec.com
  1763.  
  1764. Sure enough it was there, along with all the other updates.  Now, why couldn't
  1765. Symantec post on here telling us about that?  I realize they may not want
  1766. their ftp machine getting loaded up, but if they don't, then they should have
  1767. posted it to Sumex (as if we can get in there).  I wasted a phone call, as 
  1768. well as I've probably now started that totally lame limited 90 days of support
  1769. crap that they've started.  What a joke!  (Hmm, it seems Symantec bashing is
  1770. now a required part of every post on these groups :)
  1771.  
  1772. -- 
  1773. ________________________________________________________
  1774.   Christopher Bailey        Work: baileyc@dejaview.com 
  1775.   Software Engineer         Home: baileyc@beetle.com      
  1776.   DejaView Software Inc.    http://bigmac.gmg.com/
  1777.  
  1778. ---------------------------
  1779.  
  1780. >From Ben J Fry <bf2c+@andrew.cmu.edu>
  1781. Subject: pascal and c libraries
  1782. Date: Tue, 19 Apr 1994 21:31:59 -0400
  1783. Organization: Freshman, Design, Carnegie Mellon, Pittsburgh, PA
  1784.  
  1785. is there any way to write a function in think pascal and have it
  1786. available for use in a think c project? how would this be done, and how
  1787. would you do the opposite, compiling something in c and calling it from
  1788. pascal?
  1789.  
  1790. thanks in advance...
  1791.  
  1792. ben
  1793. bf2c+@andrew.cmu.edu
  1794.  
  1795. +++++++++++++++++++++++++++
  1796.  
  1797. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  1798. Date: 22 Apr 1994 09:24:52 GMT
  1799. Organization: (none)
  1800.  
  1801. Ben J Fry <bf2c+@andrew.cmu.edu> writes:
  1802.  
  1803. >is there any way to write a function in think pascal and have it
  1804. >available for use in a think c project? how would this be done, and how
  1805. >would you do the opposite, compiling something in c and calling it from
  1806. >pascal?
  1807.  
  1808. Both are quite possible. I've even had projects where I write a lib mostly
  1809. in Pascal, but calling a C-lib (for the inline assembler). Then I make a
  1810. library of it, so my C-using friend can use it. That means that the code
  1811. has three layers, C-Pascal-C!
  1812.  
  1813. Using C from Pascal is simple. The C functions must be declared "Pascal".
  1814. You build a library and write an interface file.
  1815.  
  1816. Using Pascal from C takes a bit more, mostly due to limitations in the
  1817. Think compilers, and very poor documentation. (May I say "bugs"?)
  1818.  
  1819. You build a library from the Pascal code and convert it with oConv.
  1820.  
  1821. BUT something is wrong with how either Think Pascal sets the function names
  1822. or how oConv converts them, so capitalization might get wrong. You can fix
  1823. that by checking the ".v" box, edit the .v file to he correct capitalization
  1824. in the cases where you get problems, and then oConv again, still with ".v"
  1825. checked.
  1826.  
  1827. BUT your Pascal library might rely on some of Think Pascal's built-in
  1828. functions, usually LMUL and LDIV. The fix I've been recommended, and that
  1829. I am using, is to include uRuntime.lib in the Pascal library. This works
  1830. just great with Think C 5. (Note that Symantec's support people seem to
  1831. know nothing about how to do this.)
  1832.  
  1833. BUT Think C version 6 has a bug in its linker! If you include uRuntime.lib,
  1834. you get a link error telling you that a function isn't defined - a function
  1835. that is in the ROM's since 1984! (MaxApplZone if I remember right.) This can
  1836. be fixed by opening the library and remove a segemnt that is named %_TOOLBOX
  1837. (or something like that).
  1838.  
  1839. BUT that is only possible using Think C 5! If you don't have Think C 5,
  1840. you'll have to ask someone who has it to do it. I guess we could convert
  1841. uRuntime.lib to a C library and remove it, and post...
  1842.  
  1843. BUT is that legal, or is it breaking some copyright that Symantec has?
  1844.  
  1845. If you have Think C 5, it isn't a big problem.
  1846.  
  1847. The whole problems should be simpler with CodeWarrior. Can anyone confirm
  1848. that?
  1849.  
  1850.  
  1851.  
  1852. --
  1853. - -
  1854. Ingemar Ragnemalm, PhD
  1855. Image processing, Mac shareware games
  1856. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  1857.  
  1858. ---------------------------
  1859.  
  1860. End of C.S.M.P. Digest
  1861. **********************
  1862.  
  1863.  
  1864.