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

  1. Received-Date: Tue, 12 Jul 1994 14:08:59 +0200
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-044
  4. To: csmp-digest@ens.fr
  5. Date: Tue, 12 Jul 1994 14:08:55 +0200 (MET DST)
  6. X-Mailer: ELM [version 2.4 PL23]
  7. Mime-Version: 1.0
  8. Content-Type: text/plain; charset=ISO-8859-1
  9. Content-Transfer-Encoding: 8bit
  10. Errors-To: listman@ens.fr
  11. Reply-To: pottier@clipper.ens.fr
  12. X-Sequence: 47
  13.  
  14. C.S.M.P. Digest             Tue, 12 Jul 94       Volume 3 : Issue 44
  15.  
  16. Today's Topics:
  17.  
  18.         "Power Mac Programming Starter Kit", by Tom Thompson
  19.         AppleTalk Prefered vs. Alternate Interface?
  20.         CodeWarrior inline problem
  21.         Mac Pathname Syntax
  22.         MacTCP Berkeley socket wrapper?
  23.         MacsBug-How Do I...
  24.         Receiving Events in AppleScript
  25.         [Q] ReleaseResource, PICTs and handles
  26.         computer strategy
  27.  
  28.  
  29.  
  30. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  31. (pottier@clipper.ens.fr).
  32.  
  33. The digest is a collection of article threads from the internet newsgroup
  34. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  35. regularly and want an archive of the discussions.  If you don't know what a
  36. newsgroup is, you probably don't have access to it.  Ask your systems
  37. administrator(s) for details.  If you don't have access to news, you may
  38. still be able to post messages to the group by using a mail server like
  39. anon.penet.fi (mail help@anon.penet.fi for more information).
  40.  
  41. Each issue of the digest contains one or more sets of articles (called
  42. threads), with each set corresponding to a 'discussion' of a particular
  43. subject.  The articles are not edited; all articles included in this digest
  44. are in their original posted form (as received by our news server at
  45. nef.ens.fr).  Article threads are not added to the digest until the last
  46. article added to the thread is at least two weeks old (this is to ensure that
  47. the thread is dead before adding it to the digest).  Article threads that
  48. consist of only one message are generally not included in the digest.
  49.  
  50. The digest is officially distributed by two means, by email and ftp.
  51.  
  52. If you want to receive the digest by mail, send email to listserv@ens.fr
  53. with no subject and one of the following commands as body:
  54.     help                        Sends you a summary of commands
  55.     subscribe csmp-digest Your Name    Adds you to the mailing list
  56.     signoff csmp-digest            Removes you from the list
  57. Once you have subscribed, you will automatically receive each new
  58. issue as it is created.
  59.  
  60. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  61. Questions related to the ftp site should be directed to
  62. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  63. digest are available there.
  64.  
  65. Also, the digests are available to WAIS users.  To search back issues
  66. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  67. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  68.  
  69.  
  70. -------------------------------------------------------
  71.  
  72. >From nagle@netcom.com (John Nagle)
  73. Subject: "Power Mac Programming Starter Kit", by Tom Thompson
  74. Date: Tue, 28 Jun 1994 00:14:57 GMT
  75. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  76.  
  77.     Just bought "Power Macintosh Programming Starter Kit", by Tom
  78. Thompson (ISBN 1-56830-091-3).  This is a cute little book, but
  79. it's not quite what the title indicates.  You get a 418-page book,
  80. and a CD-ROM with a very limited version of the MetroWerks compilers.
  81. (You can't do anything but work with the sample code on the CD-ROM.)
  82.  
  83.     This book has attitude.  It's not one of those "The Mac is easy"
  84. books; it's a macho programming book by an old-time low-level Mac hacker.
  85. The first real sample application isn't something like a draw program; 
  86. it's a program to eject the currently mounted CD while file sharing is active.  
  87. The second sample application is an INIT which changes the screen depth when 
  88. some funny character combination is hit. There's
  89. trap patching, mixed 68K/PPC code, accessing of low-memory globals, 
  90. and 68K code that manipulates the stack pointer.  All the resources are
  91. written in Rez, by hand.  There's even some inline assembly 68K assembly
  92. code written in hex.  No PPC machine code, though.
  93.  
  94.      The approach taken is strictly C.  No new-fangled object-oriented
  95. programming here.  None of that exotic class library stuff.  You do things
  96. by calling the Toolbox, like Bill Atkinson intended.
  97.  
  98.      But if you want a readable explaination of how to do fat trap patches,
  99. this is the book for you.  
  100.  
  101.                     John Nagle
  102.  
  103. ---------------------------
  104.  
  105. >From npearl@magnus.acs.ohio-state.edu (Nathan Y Pearlstein)
  106. Subject: AppleTalk Prefered vs. Alternate Interface?
  107. Date: 27 Jun 1994 17:57:01 GMT
  108. Organization: The Ohio State University
  109.  
  110. Hi, According to THINK Reference there are 2 ways of using AppleTalk,
  111. the prefered or the alternate interface.  If I use the alternate
  112. interface I don't have to write a socket listener, but if I use the
  113. prefered method I do.  What would be the drawbacks of using the
  114. alternate interface?  Please don't send guesses.
  115. Thanks
  116.  
  117. -- 
  118. DarkNater - pearlstein.1@osu.edu
  119.  
  120. +++++++++++++++++++++++++++
  121.  
  122. >From npearl@magnus.acs.ohio-state.edu (Nathan Y Pearlstein)
  123. Date: 27 Jun 1994 18:03:42 GMT
  124. Organization: The Ohio State University
  125.  
  126. In article <2un3td$83d@charm.magnus.acs.ohio-state.edu>,
  127. Nathan Y Pearlstein <npearl@magnus.acs.ohio-state.edu> wrote:
  128. >Hi, According to THINK Reference there are 2 ways of using AppleTalk,
  129. >the prefered or the alternate interface.  If I use the alternate
  130. >interface I don't have to write a socket listener, but if I use the
  131. >prefered method I do.  What would be the drawbacks of using the
  132. >alternate interface?  Please don't send guesses.
  133. >Thanks
  134.  
  135. Silly me, I should also mention that I have to use DDP.
  136.  
  137.  
  138. -- 
  139. DarkNater - pearlstein.1@osu.edu
  140.  
  141. +++++++++++++++++++++++++++
  142.  
  143. >From jumplong@aol.com (Jump Long)
  144. Date: 28 Jun 1994 03:28:05 -0400
  145. Organization: America Online, Inc. (1-800-827-6364)
  146.  
  147. In article <2un3td$83d@charm.magnus.acs.ohio-state.edu>,
  148. npearl@magnus.acs.ohio-state.edu (Nathan Y Pearlstein) writes:
  149.  
  150. >Hi, According to THINK Reference there are 2 ways of
  151. >using AppleTalk, the prefered or the alternate interface.
  152. >If I use the alternate interface I don't have to write
  153. >a socket listener, but if I use the prefered method I do.
  154. >What would be the drawbacks of using the alternate
  155. >interface?  Please don't send guesses.
  156.  
  157. Drawbacks...
  158. 1) Apple has dropped all support of the alternate interface.
  159. 2) It has bugs that'll never be fixed.
  160. 3) I have already written a socket listener that does everything the
  161. one supplied with the alternate interface does, plus mine buffers
  162. packets. It is in the Tech Note "AppleTalk, the Rest of the Story"
  163. and in the sample "Network Watch (DMZ)"
  164. 4) The alternate interface uses network events which aren't supported
  165. any longer.
  166.  
  167. Is that enough?
  168.  
  169. - Jim Luther
  170.  
  171.  
  172. ---------------------------
  173.  
  174. >From philip@cs.wits.ac.za (Philip Machanick)
  175. Subject: CodeWarrior inline problem
  176. Date: 26 Jun 1994 16:58:49 GMT
  177. Organization: Computer Science Dept, U of Witwatersrand
  178.  
  179. Even though a member function is declared incline in the class, if I have a
  180. call 
  181. to it before its code actually appears, the compiler complains "illegal
  182. inline function" when it sees the code with inline in front of it.
  183.  
  184. Moving the code to before the call makes the compiler happy.
  185.  
  186. In my opinion this is a bug since other C++ compilers can deal with this
  187. with no problem.
  188.  
  189. The workaround of moving the inline function to before it's called is no
  190. big problem (I can't imagine anyone wanting mutually recursive inlines -
  191. what would they expand to?). But it's irritating because it means I can't
  192. keep my source file in the order I want it.
  193. -- 
  194. Philip Machanick                   philip@cs.wits.ac.za
  195. Department of Computer Science, University of the Witwatersrand
  196. 2050 Wits, South Africa
  197. phone 27(11)716-3309  fax 27(11)339-7965
  198.  
  199. +++++++++++++++++++++++++++
  200.  
  201. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  202. Date: Sun, 26 Jun 1994 13:53:10 -0400
  203. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  204.  
  205. Excerpts from netnews.comp.sys.mac.programmer: 26-Jun-94 CodeWarrior
  206. inline problem Philip Machanick@cs.wits (828)
  207.  
  208. > Even though a member function is declared inline in the class, if I have a
  209. > call 
  210. > to it before its code actually appears, the compiler complains "illegal
  211. > inline function" when it sees the code with inline in front of it.
  212.  
  213. > Moving the code to before the call makes the compiler happy.
  214.  
  215. > In my opinion this is a bug since other C++ compilers can deal with this
  216. > with no problem.
  217.  
  218. It's very likely that the other C++ compilers are dealing with it by
  219. ignoring the "inline" -- that is, they generate a normal member function
  220. which is called with the usual calling mechanism. This is easier than
  221. going through the rest of the compilation to find the inline definition,
  222. and then going back to compile the function that calls the inline
  223. function.
  224.  
  225. I'm not certain that they're doing it this way, but you might want to
  226. create a test case and examine the assembly code to see. It's something
  227. to consider; it's possible for a C++ programmer to get silently horked
  228. by this, where the compiler isn't giving him the inlining optimizations
  229. that he wants.
  230.  
  231. If CodeWarrior isn't willing to do that, it's a problem (what you're
  232. doing is legal C++, I believe) but it does point out the silent problem
  233. you would have with some other compilers.
  234.  
  235. --Z
  236.  
  237. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  238.  
  239. +++++++++++++++++++++++++++
  240.  
  241. >From johnmce@world.std.com (John McEnerney)
  242. Date: Sun, 26 Jun 1994 23:36:29 GMT
  243. Organization: The World Public Access UNIX, Brookline, MA
  244.  
  245. philip@cs.wits.ac.za (Philip Machanick) writes:
  246.  
  247. >Even though a member function is declared incline in the class, if I have a
  248. >call to it before its code actually appears, the compiler complains "illegal
  249. >inline function" when it sees the code with inline in front of it.
  250. >Moving the code to before the call makes the compiler happy.
  251.  
  252. >In my opinion this is a bug since other C++ compilers can deal with this
  253. >with no problem.
  254.  
  255. This is a hazy area. See ARM p. 104 for some examples. It is an error to 
  256. define a member function as 'inline' after it has already been called. It 
  257. is not clear from the notes whether it is legal if the function was 
  258. declared 'inline' (but not defined) in the class. I'd say it is probably 
  259. legal, and we are being too strict; I'll pass it on to the C++ front-end 
  260. architect.
  261.  
  262. -- John McEnerney, Metrowerks PowerPC Product Architect
  263.  
  264. +++++++++++++++++++++++++++
  265.  
  266. >From philip@cs.wits.ac.za (Philip Machanick)
  267. Date: 27 Jun 1994 13:32:23 GMT
  268. Organization: Computer Science Dept, U of Witwatersrand
  269.  
  270. In article <Cs12wu.Cyn@world.std.com>, johnmce@world.std.com (John
  271. McEnerney) wrote:
  272.  
  273. > philip@cs.wits.ac.za (Philip Machanick) writes:
  274. > >Even though a member function is declared incline in the class, if I have a
  275. > >call to it before its code actually appears, the compiler complains "illegal
  276. > >inline function" when it sees the code with inline in front of it.
  277. > >Moving the code to before the call makes the compiler happy.
  278. > >In my opinion this is a bug since other C++ compilers can deal with this
  279. > >with no problem.
  280. > This is a hazy area. See ARM p. 104 for some examples. It is an error to 
  281. > define a member function as 'inline' after it has already been called. It 
  282. > is not clear from the notes whether it is legal if the function was 
  283. > declared 'inline' (but not defined) in the class. I'd say it is probably 
  284. > legal, and we are being too strict; I'll pass it on to the C++ front-end 
  285. > architect.
  286.  
  287. You're right - it is hazy. However I don't think an error should be
  288. reported. In commentary on p 102, see the list of reasons an ordinary call
  289. may be generated for an inline function:
  290.   - An inline function was invoked in a program before it was defined
  291.  
  292. In a case like this the compiler has the option of either backpatching the
  293. inline in if a call is seen before the function definition, or generating
  294. code for a non-inline version of the function. My version of cfront on UNIX
  295. does the latter, and switches to using inlining after it's seen the
  296. definition of the inline function.
  297.  
  298. The key here is that the "inline" can be ignored (p 99). This is what a
  299. compiler should do if it sees "inline" then can't honour it - for whatever
  300. reason.
  301. -- 
  302. Philip Machanick                   philip@cs.wits.ac.za
  303. Department of Computer Science, University of the Witwatersrand
  304. 2050 Wits, South Africa
  305. phone 27(11)716-3309  fax 27(11)339-7965
  306.  
  307. ---------------------------
  308.  
  309. >From russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill)
  310. Subject: Mac Pathname Syntax
  311. Date: 24 Jun 1994 14:14:27 GMT
  312. Organization: JPL
  313.  
  314. I've written a portable program which uses IOstreams and no toolbox calls. 
  315. What
  316. syntax is allowable for Mac pathnames?  I have discovered that the
  317. following work:
  318.  
  319.     filename                        (same folder)
  320.     :folder1:folder2...:filename    (starting at same folder)
  321.     :::folder1...:filename          (up 3 folders)
  322.     disc:folder1...:filename        (absolute path)
  323.  
  324. and I've discovered that there can't be any spaces in the pathname.  Are
  325. there any other syntaxes or restrictions.  In particular, is there a way to
  326. refer to the desktop?
  327.  
  328. +++++++++++++++++++++++++++
  329.  
  330. >From rmah@panix.com (Robert S. Mah)
  331. Date: Fri, 24 Jun 1994 11:02:39 -0500
  332. Organization: One Step Beyond
  333.  
  334. russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill) wrote:
  335.  
  336. > I've written a portable program which uses IOstreams and no toolbox
  337. > calls.  What syntax is allowable for Mac pathnames?  I have discovered
  338. > that the following work:
  339. >     filename                        (same folder)
  340. >     :folder1:folder2...:filename    (starting at same folder)
  341. >     :::folder1...:filename          (up 3 folders)
  342. >     disc:folder1...:filename        (absolute path)
  343. > and I've discovered that there can't be any spaces in the pathname. 
  344. > Are there any other syntaxes or restrictions.  In particular, is
  345. > there a way to refer to the desktop?
  346.  
  347. No spaces?  Spaces never bothered my pathnames before -- what compiler
  348. and/or ANSI library are you using?
  349.  
  350. Anyway, to refer to the desktop, use something like...
  351.  
  352.   "disk:Desktop Folder:file"
  353.  
  354. The desktop displays the union of all Desktop Folder's on all mounted
  355. volumes.  The trash folder is similar in nature.
  356.  
  357. Cheers,
  358. Rob
  359. ___________________________________________________________________________
  360. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  361.  
  362. +++++++++++++++++++++++++++
  363.  
  364. >From oster@netcom.com (David Phillip Oster)
  365. Date: Fri, 24 Jun 1994 21:01:47 GMT
  366. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  367.  
  368. In article <russell.m.brill-240694070926@mac8.jpl.nasa.gov> russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill) writes:
  369.  
  370. If your program does not allow spaces in pathnames, your program is wrong.
  371.  
  372. If your program does not allow the user to name all his hard disks and
  373. floppies "untitled" and still allow the user to specify which file on which
  374. hard disk she meant, then your program is wrong. (This is what the standard
  375. file dialog, and also Macintosh Drag & Drop are for.)
  376.  
  377. The desktop is represented by an invisible folder with a name something like
  378. "Desktop", in the English Language version of System 7 and later.
  379.  
  380. In systems earlier than 7, it was a bit in the FinderFlags portion of the
  381. directory entry.  In languages other than English, it may not be called
  382. "Desktop", you need to call FindFolder() to get the dirID, which is a long,
  383. and the volRef, which is a short for the desktop folder.
  384.  
  385.  
  386.  
  387. +++++++++++++++++++++++++++
  388.  
  389. >From Rick_Holzgrafe@taligent.com (Rick Holzgrafe)
  390. Date: Fri, 24 Jun 1994 20:33:33 GMT
  391. Organization: Semicolon Software
  392.  
  393. In article <russell.m.brill-240694070926@mac8.jpl.nasa.gov>,
  394. russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill) wrote:
  395.  
  396. > I've written a portable program which uses IOstreams and no toolbox calls. 
  397. > What
  398. > syntax is allowable for Mac pathnames?  I have discovered that the
  399. > following work:
  400. >     filename                        (same folder)
  401. >     :folder1:folder2...:filename    (starting at same folder)
  402. >     :::folder1...:filename          (up 3 folders)
  403. >     disc:folder1...:filename        (absolute path)
  404. > and I've discovered that there can't be any spaces in the pathname.  Are
  405. > there any other syntaxes or restrictions.  In particular, is there a way to
  406. > refer to the desktop?
  407.  
  408. Spaces should not be a problem. In general any character is allowable
  409. except for colons, which are used only as separators. The Mac itself uses
  410. Pascal strings and probably wouldn't be bothered even by a null byte, but
  411. if you are working in C or C++ you may not be able to cope with null bytes
  412. because they'll be interpreted as end-of-string markers.
  413.  
  414. -- Rick Holzgrafe, a member of the Taligentsia
  415.    Rick_Holzgrafe@taligent.com
  416.    rmh@taligent.com
  417.  
  418. +++++++++++++++++++++++++++
  419.  
  420. >From nagle@netcom.com (John Nagle)
  421. Date: Sat, 25 Jun 1994 17:44:48 GMT
  422. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  423.  
  424. Rick_Holzgrafe@taligent.com (Rick Holzgrafe) writes:
  425. >Spaces should not be a problem. In general any character is allowable
  426. >except for colons, which are used only as separators. The Mac itself uses
  427. >Pascal strings and probably wouldn't be bothered even by a null byte, but
  428. >if you are working in C or C++ you may not be able to cope with null bytes
  429. >because they'll be interpreted as end-of-string markers.
  430.  
  431.      But be aware that under A/UX, the "/" is used as a separator, following
  432. UNIX conventions, and this can reach your program.  And under MPW,
  433. "/" is used to indicate regular expression expansion.  
  434.  
  435.                     John Nagle
  436.  
  437. +++++++++++++++++++++++++++
  438.  
  439. >From jumplong@aol.com (Jump Long)
  440. Date: 25 Jun 1994 17:15:02 -0400
  441. Organization: America Online, Inc. (1-800-827-6364)
  442.  
  443. In article <russell.m.brill-240694070926@mac8.jpl.nasa.gov>,
  444. russell.m.brill@ccmail.jpl.nasa.gov (Russ Brill) writes:
  445.  
  446. >What syntax is allowable for Mac pathnames?
  447.  
  448. In Inside Macintosh: Files pages 2-23 through 2-32, you'll find a
  449. section "Identifying Files, Directories, and Volumes" that includes
  450. the naming rules for pathnames.  The only omission I know of in this
  451. section of Inside Macintosh: Files is that consecutive colon (:)
  452. separator characters ascend a level in the catalog tree (for example,
  453. the pathname 'HD:System Folder:Extensions::' refers to the System
  454. Folder).  Using partial pathnames is discouraged because if a user
  455. moves things around, they break.  Using full pathnames is discouraged
  456. for the same reason as partial pathnames and for another good reason
  457. - the Macintosh allows multiple volumes to be mounted with the same
  458. volume name. If you have multiple volumes mounted with the same
  459. volume name and use a full pathname, the file system uses the first
  460. volume with a matching name that it finds by searching the VCB queue
  461. and that might not be the volume you wanted.
  462.  
  463. - Jim Luther
  464.  
  465.  
  466. +++++++++++++++++++++++++++
  467.  
  468. >From misc173@csc.canterbury.ac.nz
  469. Date: 28 Jun 94 14:24:13 +1200
  470. Organization: University of Canterbury, Christchurch, New Zealand
  471.  
  472. > for the same reason as partial pathnames and for another good reason
  473. > - the Macintosh allows multiple volumes to be mounted with the same
  474. > volume name. If you have multiple volumes mounted with the same
  475. > volume name and use a full pathname, the file system uses the first
  476. > volume with a matching name that it finds by searching the VCB queue
  477. > and that might not be the volume you wanted.
  478.     I'm writing a program somewhat like Xtree gold  on the IBM, where you
  479. get a tree view of the files, without having to worry about windows. At the
  480. moment it works by using full path names. I'm using the list manager and
  481. simply steeping back up the tree to work out the path. What alternatives are
  482. there to full path names, I know a bit about directory numbers and volume
  483. numbers, cant you just specify a volume number and a partial ( no volume name )
  484. or full path.
  485.     I really dont want to have to rewrite the list manager to include file
  486. numbers.
  487.  
  488. Thanks,
  489. Jon. 
  490.  
  491. +++++++++++++++++++++++++++
  492.  
  493. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  494. Date: Tue, 28 Jun 1994 21:25:19 GMT
  495. Organization: Apple Computer
  496.  
  497. misc173@csc.canterbury.ac.nz writes:
  498. >     I'm writing a program somewhat like Xtree gold  on the IBM, where you
  499. > get a tree view of the files, without having to worry about windows.
  500.  
  501. Hmm, is this really any better than the list view in the Finder, in which you
  502. can open subfolders in an outline?
  503.  
  504. > At the
  505. > moment it works by using full path names. I'm using the list manager and
  506. > simply steeping back up the tree to work out the path. What alternatives are
  507. > there to full path names, I know a bit about directory numbers and volume
  508. > numbers
  509.  
  510. The preferred way to deal with files is by volume refNum, directory ID and
  511. filename. The volume refNum is not persistent across volume mounts but the
  512. other two are. There is a structure called an FSSpec that encapsulates this
  513. info. Most of the file manager functions that deal with files have versions
  514. that take FSSpecs.
  515.   You probably really want to get the "MoreFiles" sample code, which has all
  516. kinds of routines for dealing with files and directories, such as enumerating
  517. through all the files in a directory. Also be sure to read Inside Macintosh:
  518. Files.
  519.  
  520. >     I really dont want to have to rewrite the list manager to include file
  521. > numbers.
  522.  
  523. Huh? Don't tell me you're just displaying a textual list of pathnames. Ewwwww!
  524.  
  525. --Jens Alfke
  526.   jens_alfke@powertalk              Rebel girl, rebel girl,
  527.             .apple.com              Rebel girl you are the queen of my world
  528.  
  529. ---------------------------
  530.  
  531. >From ankh@leland.Stanford.EDU (graham hesselroth)
  532. Subject: MacTCP Berkeley socket wrapper?
  533. Date: 23 Jun 1994 17:48:39 GMT
  534. Organization: Stanford University, CA 94305, USA
  535.  
  536.     Hello,
  537.  
  538.         I was looking for some library of C or C++ code that
  539. acted as a simplified interface to the MacTCP calls, preferably
  540. compliant with the Berkeley sockets API.  Does any such beast exist,
  541. or anyother package that provides socket like calls on the Mac
  542. (socket, bind, connect, recvrfrom, sendto, etc)?
  543. Pls send replies to ankh@leland.stanford.edu 
  544.     Thanks
  545.         Graham
  546.  
  547.  
  548. +++++++++++++++++++++++++++
  549.  
  550. >From rypma@waterloo.hp.com (Ted Rypma)
  551. Date: 23 Jun 1994 20:53:01 GMT
  552. Organization: H-P Panacom Div, Waterloo, ON Canada
  553.  
  554. graham hesselroth (ankh@leland.Stanford.EDU) wrote:
  555. :     Hello,
  556.  
  557. :         I was looking for some library of C or C++ code that
  558. : acted as a simplified interface to the MacTCP calls, preferably
  559. : compliant with the Berkeley sockets API.  Does any such beast exist,
  560.  
  561. >From an earlier post...
  562.  
  563. % Get sockets.hqx from explorer.dgp.utoronto.ca in /pub/macsockets.
  564. % Be warned, though, you have to build it yourself (MPW), and it is imcomplete.
  565. % For just connecting to some server, snarf data, and close, it works fine.
  566. % One of these days I'll get around to supplying Tom with a list of patches
  567. % and then someday he'll get around to supplying an updated .hqx file of
  568. % compiled libraries and headers.
  569. % enjoy!
  570. % --
  571. % !@$^&*)($#$@!@#$^&*()_+_)(*&^$#@!$^&*()_+)(*&^$#@$^&*+_(*&^$#@#^&*()&*$#@(*&
  572. % Dominic Richens  :  dominic@oeg.carleton.ca  :  Tel. (613) 820 0764
  573. % Ontario Telepresence Project,2670 Queensview Dr.,Ottawa,ON,K2B 8K1,CANADA
  574.  
  575. Ted Rypma
  576. Waterloo, Ontario
  577.  
  578. +++++++++++++++++++++++++++
  579.  
  580. >From nagel@Rdatasys.COM (Mark D. Nagel)
  581. Date: Fri, 24 Jun 1994 18:14:28 GMT
  582. Organization: Relational Data Systems, Irvine, CA
  583.  
  584. In <2ucsnd$73m@hppadbk.waterloo.hp.com> rypma@waterloo.hp.com (Ted Rypma) writes:
  585.  
  586. >graham hesselroth (ankh@leland.Stanford.EDU) wrote:
  587. >:         I was looking for some library of C or C++ code that
  588. >: acted as a simplified interface to the MacTCP calls, preferably
  589. >: compliant with the Berkeley sockets API.  Does any such beast exist,
  590.  
  591. >From an earlier post...
  592.  
  593. >% Get sockets.hqx from explorer.dgp.utoronto.ca in /pub/macsockets.
  594.  
  595. There's also GUSI (Grand Unified Socket Interface), available from
  596. nic.switch.ch in /software/mac/src/mpw_c.  Here'e the .info file:
  597.  
  598. - ----------------------------------------------------------------------------
  599.                  G U S I -- Grand Unified Socket Interface
  600.  
  601. INTRODUCTION
  602.  
  603. GUSI is an extension and partial replacement of the MPW C runtime
  604. library.  Its main objective is to provide a more or less simple and
  605. consistent interface across the following communication domains:
  606.  
  607. Files          Ordinary Macintosh files and MPW pseudo devices.
  608. Unix           Memory based communication within a single machine
  609. Appletalk      ADSP communication over a network.
  610. PPC            Local and remote connections with the System 7 PPC Toolbox
  611. Internet       TCP and UDP connections over MacTCP.
  612.  
  613. Additionally, GUSI adds some UNIX library calls dealing with files which
  614. were missing, like chdir(), getcwd(), symlink(), and readlink(), and changes
  615. a few other library calls to behave more like their UNIX counterparts.
  616.  
  617. REQUIREMENTS
  618.  
  619. To use GUSI, you need MPW C 3.2 or later. To modify it, you additionally need
  620. MPW C++ 3.2 or later and Perl. GUSI_120.doc.sit.bin provides the documentation
  621. for non-postscript printers. Documentation in Postscript format is included.
  622. - ----------------------------------------------------------------------------
  623.  
  624. There's also a port to THINK C in the info-mac archives.
  625.  
  626. -- 
  627. Mark D. Nagel <mark.nagel@rdatasys.com>      Relational Data Systems
  628.                                              30 Executive Park, Suite 260
  629. Eat right.  Exercise.  Die anyway.           Irvine, CA 92714
  630.                                              (714) 263-3899
  631.  
  632. +++++++++++++++++++++++++++
  633.  
  634. >From creiman@netcom.com (Charlie Reiman)
  635. Date: Sat, 25 Jun 1994 05:43:44 GMT
  636. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  637.  
  638. nagel@Rdatasys.COM (Mark D. Nagel) writes:
  639.  
  640. >In <2ucsnd$73m@hppadbk.waterloo.hp.com> rypma@waterloo.hp.com (Ted Rypma) writes:
  641.  
  642. >>graham hesselroth (ankh@leland.Stanford.EDU) wrote:
  643. >>:         I was looking for some library of C or C++ code that
  644. >>: acted as a simplified interface to the MacTCP calls, preferably
  645. >>: compliant with the Berkeley sockets API.  Does any such beast exist,
  646.  
  647. >>From an earlier post...
  648.  
  649. >>% Get sockets.hqx from explorer.dgp.utoronto.ca in /pub/macsockets.
  650.  
  651. >There's also GUSI (Grand Unified Socket Interface), available from
  652. >nic.switch.ch in /software/mac/src/mpw_c. 
  653.  
  654. My old BSD library is also still available at ftp.ncsa.uiuc.edu, in
  655. /misc/unsupported. It is, believe it or not, shipping inside NCSA 
  656. Mosaic. I assume they fixed some bugs along the way, but the Macsbugs
  657. symbols show no signifigant changes. 
  658.  
  659. My code, being hammered by hundreds (thousands?) of thousands of
  660. users every day, and do I get any credit? No. Of course not. 
  661.  
  662. What? Me bitter? Nah. It comes with the territory of working as an
  663. undergrad. 
  664.  
  665. Sorry. I'll pack up my spite and regret and move along to the next
  666. newsgroup.
  667.  
  668. -- 
  669. "You can't cancel the project! We already made the T-shirts!"
  670. Charlie Reiman
  671. creiman@netcom.com
  672.  
  673. +++++++++++++++++++++++++++
  674.  
  675. >From jbrowne@zaphod.ncsa.uiuc.edu (Jim Browne)
  676. Date: 28 Jun 94 02:44:22 GMT
  677. Organization: University of Illinois at Urbana
  678.  
  679. creiman@netcom.com (Charlie Reiman) writes:
  680.  
  681. >My code, being hammered by hundreds (thousands?) of thousands of
  682. >users every day, and do I get any credit? No. Of course not. 
  683.  
  684. What did you expect, Charlie?  This is NCSA we're talking about here.
  685.  
  686. >What? Me bitter? Nah. It comes with the territory of working as an
  687. >undergrad. 
  688.  
  689. ...and the list keeps growing...
  690.  
  691. -- 
  692. Jim Browne          Random net.person for this season         jbrowne@uiuc.edu
  693.     There are more stoplights in Sunnyvale, CA. than people in my hometown.
  694.  
  695. ---------------------------
  696.  
  697. >From tpguinn@utxvms.cc.utexas.edu (Tim Guinn)
  698. Subject: MacsBug-How Do I...
  699. Date: Fri, 24 Jun 1994 01:27:47 -0600
  700. Organization: The University of Texas at Austin, Austin, Texas
  701.  
  702. As always, please forgive the uninformed newbie nature 
  703. of this post. I'm still learning.
  704.  
  705. I've gotten to where I'm pretty comfortable entering 
  706. MacsBug [by choice 8-)] and using it to <es> out of crashed 
  707. applications and save things before <rb> or <rs>.  However...  
  708. Because it's such a new experience (entering the debugger 
  709. versus a screen freeze) I've noticed I seem to be entering 
  710. it a lot.  Well, I'd like to avoid that, of course.  Most of 
  711. the time, I get Bus Error messages.
  712.  
  713. An example:  
  714.  
  715. BusError at 00036090 while reading longword from 01A50190
  716. in Supervisor data space
  717.  
  718. I understand the *what* here, I just don't understand the 
  719. *why*.  So I did this:  
  720.  
  721. dm 36090 applname
  722.  
  723. ...thinking it would tell me the name of the offender.
  724. Nope.  I got:
  725.  
  726. "0%%%%%%/% | % % P %%%"|%%"Q"%%%0%"
  727.  
  728. Uhhhhh...what is this?  Hex, right?  How do/can I see the
  729. actual Roman script (i.e., legible) name of the app/init/
  730. whatever that went out of control?  A helpful sequence of
  731. commands would be most appreciated.
  732.  
  733. What I'd like to do is either A) isolate the offender and
  734. remove it, or B) figure out how to make it get along with
  735. everything else.
  736.  
  737. Also, What do the files MrBusError and EvenBetterBusError
  738. do, actually (in newbie-ease, please)?  The ReadMes with
  739. these files indicated each would *help* with debugging, but,
  740. like their names imply (and from experience, now) I realize
  741. they actually *cause* a BusError, not prevent one.  Am I
  742. wrong?  On separate occasions I've had each in my System
  743. folder, but found they caused more problems then I'm 
  744. presently capable of handling. 
  745.  
  746. I'm thinking maybe there's just something I haven't done to
  747. configure MacsBug so it's customized to my system...
  748.  
  749. LCIII, 8/120+270, 7.1w/HSU3.0, MacsBug 6.5d6
  750.  
  751. All pointers humbly accepted with appreciation.
  752.  
  753. -tpg
  754.  
  755. ^^
  756. Tim Guinn
  757. Austin, Texas US                  ~ Sine Metu ~
  758. tpguinn@utxvms.cc.utexas.edu
  759.  
  760. +++++++++++++++++++++++++++
  761.  
  762. >From rmah@panix.com (Robert S. Mah)
  763. Date: Fri, 24 Jun 1994 03:14:55 -0500
  764. Organization: One Step Beyond
  765.  
  766. tpguinn@utxvms.cc.utexas.edu (Tim Guinn) wrote:
  767.  
  768. > BusError at 00036090 while reading longword from 01A50190 in
  769. > Supervisor data space
  770. > I understand the *what* here, I just don't understand the *why*. 
  771. > So I did this:  
  772. > dm 36090 applname
  773. > ...thinking it would tell me the name of the offender.  Nope.  I got:
  774. > "0/ |   P "|"Q"0"
  775. > Uhhhhh...what is this?  Hex, right?  How do/can I see the actual
  776. > Roman script (i.e., legible) name of the app/init/whatever that
  777. > went out of control?  A helpful sequence of commands would be most
  778.  
  779. First, the address "000360980" is the location of the _instruction_
  780. that caused the bus error, not the location of the name of the
  781. application.  The second number is the probable address (usually
  782. bogus) that the instruction was trying to access.
  783.  
  784. The current application is always displayed in the status area on the 
  785. left, just under the title "CurApName".  Alternatively, you can type
  786. CurApName to display it.  P.S. the app's name is always at 0x0910.
  787.  
  788. To find out what caused the problem, you have to be pretty knowledgable
  789. about the OS.  You can fool around with the "wh" command, which tells
  790. you memory block containing the address or the location of a trap.  If
  791. it's in the system heap, it _may_ be an extension that's causing the 
  792. problem.  Then again, maybe not...you have to examine the code to be
  793. sure.  Other useful commands include "sc" or "sc7" which do a stack 
  794. crawl so you can see the call chain.
  795.  
  796. The long and the short of it is, however, that if you don't know the
  797. internals of the code that crashed, and "es" doesn't work, then you'll
  798. probably have to reboot.
  799.  
  800.  
  801. > Also, What do the files MrBusError and EvenBetterBusError do,
  802. > actually (in newbie-ease, please)?  The ReadMes with these files
  803. > indicated each would *help* with debugging, but, like their names
  804. > imply (and from experience, now) I realize they actually *cause*
  805. > a BusError, not prevent one.  Am I wrong?  On separate occasions
  806.  
  807. No, you are right.  Both extensions are tools to aid programmers in
  808. finding bugs in their programs by intercepting or causing certain 
  809. common errors to maniftest themselves.  If you're not developing some
  810. sort of software, remove them.
  811.  
  812. Cheers,
  813. Rob
  814. ___________________________________________________________________________
  815. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  816.  
  817. +++++++++++++++++++++++++++
  818.  
  819. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  820. Date: Fri, 24 Jun 1994 20:46:09 GMT
  821. Organization: Apple Computer
  822.  
  823. Okay, here's a tutorial on your friend EvenBetterBusError:
  824.  
  825. Tim Guinn, tpguinn@utxvms.cc.utexas.edu writes:
  826. > Also, What do the files MrBusError and EvenBetterBusError
  827. > do, actually (in newbie-ease, please)?  The ReadMes with
  828. > these files indicated each would *help* with debugging, but,
  829. > like their names imply (and from experience, now) I realize
  830. > they actually *cause* a BusError, not prevent one.
  831.  
  832. Yes. EBBE (which supersedes MrBE) is your friend -- it turns some types of
  833. bugs that ordinarily cause intermittent and hard-to-reproduce crashes, into
  834. guaranteed crashers. The types of bugs it catches are (a) dereferencing a
  835. NULL handle; and (b) writing to a NULL pointer. For instance:
  836.  
  837. PicHandle p = GetPicture(128);
  838. Rect r = (**p).picFrame ;
  839.  
  840. Oops, I forgot to put a PICT 128 resource in my application, so the second
  841. line is dereferencing a NULL pointer. Ordinarily location zero, which isn't
  842. used by anything on the system, contains some random garbage left over from
  843. startup. So the effect of the second line is to read eight bytes of stuff
  844. from some random location in memory. This is bad and may cause a crash later.
  845. And occasionally the garbage at location zero points to a nonexistent memory
  846. address, in which case you get a bus error.
  847.   What EBBE does is periodically (60x per second) write a particular garbage
  848. value, 0x50FF8001, into location 0. This value has the characteristic that
  849. it's not a valid memory address on any Mac configuration, so dereferencing it
  850. (by dereferencing a NULL pointer) will always cause a crash. So if you get a
  851. bus error and notice 50FF8001 (or some nearby value) in the register in
  852. question, suspect a NULL handle in your code.
  853.   Incidentally, you can often recover from a crash caused by EBBE by writing
  854. a valid address into the register that has 50FF8001 in it, and continuing.
  855. Just enter:
  856.   A0=@rombase; g
  857. but using the appropriate trashed register instead of A0.
  858.   EBBE also warns you of jumps to NULL (calling a procedure pointer whose
  859. value is NULL, or jumping into a purged code resource) since 50FF is an
  860. invalid 68000 instruction. Jumps to NULL will almost certainly kill you in
  861. any case, but with EBBE yor code stops immediately and it's easier to tell
  862. what happened.
  863.  
  864. The second thing EBBE does is, when it periodically writes the magic value
  865. into NULL, it first checks whether the value it last wrote has been changed.
  866. If so, this means somebody wrote to NULL, and it will then warn you via a
  867. DebugStr reading "Write to NIL!". Unfortunately up to one tick may have
  868. elapsed since the offending write, so it's harder to track down what's wrong,
  869. but it's still good to know. You can continue after this; it's just a warning.
  870. Here's an example of code that writes to NULL:
  871.  
  872. long *p = NewPtr(sizeof(long));
  873. *p = 0x12345678;
  874.  
  875. If you're out of memory, or your heap is hosed, NewPtr will fail and return
  876. NULL, whereupon the second line will write into location zero. One tick later
  877. EBBE will tell you about this. If you do a "dm 0" and look at the value
  878. there, it might tip you off...
  879.  
  880. --Jens Alfke
  881.   jens_alfke@powertalk              Rebel girl, rebel girl,
  882.             .apple.com              Rebel girl you are the queen of my world
  883.  
  884. +++++++++++++++++++++++++++
  885.  
  886. >From WalrathW@rferl.org (Wayne Walrath)
  887. Date: Mon, 27 Jun 1994 15:02:35 +0100
  888. Organization: RFE/RL Inc.
  889.  
  890. In article <tpguinn-240694012747@slip-4-2.ots.utexas.edu>,
  891. tpguinn@utxvms.cc.utexas.edu (Tim Guinn) wrote:
  892.  
  893. > As always, please forgive the uninformed newbie nature 
  894. > of this post. I'm still learning.
  895. > I've gotten to where I'm pretty comfortable entering 
  896. > MacsBug [by choice 8-)] and using it to <es> out of crashed 
  897. > applications and save things before <rb> or <rs>.  However...  
  898. > Because it's such a new experience (entering the debugger 
  899. > versus a screen freeze) I've noticed I seem to be entering 
  900. > it a lot.  Well, I'd like to avoid that, of course.  Most of 
  901. > the time, I get Bus Error messages.
  902.  
  903. <snip>
  904.  
  905. > All pointers humbly accepted with appreciation.
  906. > -tpg
  907. > ^^
  908. > Tim Guinn
  909. > Austin, Texas US                  ~ Sine Metu ~
  910. > tpguinn@utxvms.cc.utexas.edu
  911.  
  912. Tim,
  913.   If you are interested in understanding a little better what Macsbug is
  914. showing you, and being able to maneuver a bit better in that "underworld",
  915. pick up a copy of the book, "Debugging Mac Software with Macsbug" by Straus
  916. and Othmer $34.95 and available from APDA. It's a great reference and
  917. tutorial to have around.
  918.  
  919. -wayne
  920.  
  921. ________)|(________
  922. walrathw@rferl.org
  923.    RFE/RL Inc.
  924.  
  925. +++++++++++++++++++++++++++
  926.  
  927. >From hammel@skisas.usask.ca
  928. Date: 27 Jun 1994 16:41:27 GMT
  929. Organization: Institute of Space and Atmospheric Studies, Univ. of Sask.
  930.  
  931. In article <WalrathW-270694150235@mumcec.rferl.org> WalrathW@rferl.org (Wayne Walrath) writes:
  932. >  If you are interested in understanding a little better what Macsbug is
  933. >showing you, and being able to maneuver a bit better in that "underworld",
  934. >pick up a copy of the book, "Debugging Mac Software with Macsbug" by Straus
  935. >and Othmer $34.95 and available from APDA. 
  936.  
  937. Would anyone happen to have the ISBN number for that book?
  938.  
  939. Thanks in advance,
  940. Greg.
  941.  
  942. - ------------------------------------------------------------------------
  943. |     Greg Hammel :  HAMMEL@skisas.usask.ca or HAMMEL@sask.usask.ca      |
  944. |                                                                        |
  945. |     Disclaimer: I'm not quite sure who I speak for.                    |
  946. |                                                                        |
  947. |     "I'm a citizen of Legoland travellin Incommunicado" - Fish         |
  948. - ------------------------------------------------------------------------
  949.  
  950. +++++++++++++++++++++++++++
  951.  
  952. >From tpguinn@utxvms.cc.utexas.edu (Tim Guinn)
  953. Date: Mon, 27 Jun 1994 22:30:05 -0600
  954. Organization: The University of Texas at Austin, Austin, Texas
  955.  
  956. In article <2umvfn$pu6@tribune.usask.ca>, hammel@skisas.usask.ca wrote:
  957.  
  958. > In article <WalrathW-270694150235@mumcec.rferl.org> WalrathW@rferl.org (Wayne Walrath) writes:
  959. > >  If you are interested in understanding a little better what Macsbug is
  960. > >showing you, and being able to maneuver a bit better in that "underworld",
  961. > >pick up a copy of the book, "Debugging Mac Software with Macsbug" by Straus
  962. > >and Othmer $34.95 and available from APDA. 
  963. > Would anyone happen to have the ISBN number for that book?
  964. =======================================
  965.  
  966. 0-201-57049-1
  967.  
  968. I'm *SLOWLY* working my way through it 8-)  The only problem
  969. I have with it is that it comes with the older MacsBug.  But
  970. you can get v6.5d6 in two places I know of: 
  971.  
  972. a. develop
  973. b. ftp.apple.com (sorry, don't know the path)
  974.  
  975. -tpg
  976.  
  977. ^^
  978. Tim Guinn
  979. Austin, Texas US                  ~ Sine Metu ~
  980. tpguinn@utxvms.cc.utexas.edu
  981.  
  982. ---------------------------
  983.  
  984. >From Ricardo Marimon <rmarimon@leland.stanford.edu>
  985. Subject: Receiving Events in AppleScript
  986. Date: 28 Jun 1994 01:30:00 GMT
  987. Organization: Stanford University
  988.  
  989. Hi people,
  990.  
  991. I want to know if there is any way in which I could write a
  992. Script (using Apple's ScriptEditor) that accepts events send
  993. to it from other applications.  My particular use would be to
  994. instruct Eudora to send my Script a message whenever it
  995. receives a new message.  
  996.  
  997. I know that Eudora sends an 'eNot' event with parameters the 
  998. references to all the newly received messages.  Then my script 
  999. could do some processing on this messages, such as delete 
  1000. them, or automatically reply to some of them; things easily 
  1001. done using AppleScript and Eudora.
  1002.  
  1003. I will appreciate any help on this issue.  Thanks in advance,
  1004.  
  1005.  
  1006. Ricardo Marimon
  1007. rmarimon@leland.stanford.edu
  1008.  
  1009. - -
  1010. I type my signature every time.  And you?  :-)
  1011.  
  1012. +++++++++++++++++++++++++++
  1013.  
  1014. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1015. Date: Tue, 28 Jun 1994 21:11:25 GMT
  1016. Organization: Apple Computer
  1017.  
  1018. Ricardo Marimon, rmarimon@leland.stanford.edu writes:
  1019. > I want to know if there is any way in which I could write a
  1020. > Script (using Apple's ScriptEditor) that accepts events send
  1021. > to it from other applications.
  1022.  
  1023. You add a handler for that event to the script, then save it as an app. There
  1024. are sample scripts that come with AS (on the CD at least) that illustrate
  1025. this. It gets trickier when the event is non-standard, since AS doesn't know
  1026. the terminology for the event. You probably have to use the << ... >>
  1027. notation with the raw 4-letter codes, and I can never remember where that
  1028. syntax is documented...
  1029.  
  1030. --Jens Alfke
  1031.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1032.             .apple.com              Rebel girl you are the queen of my world
  1033.  
  1034. +++++++++++++++++++++++++++
  1035.  
  1036. >From hector@cs.toronto.edu (Hector Levesque)
  1037. Date: 28 Jun 94 17:19:49 GMT
  1038. Organization: U. of Toronto
  1039.  
  1040. In article <2unueo$5b4@nntp2.Stanford.EDU>, Ricardo Marimon
  1041. <rmarimon@leland.stanford.edu> wrote:
  1042. > I want to know if there is any way in which I could write a
  1043. > Script (using Apple's ScriptEditor) that accepts events send
  1044. > to it from other applications.  My particular use would be to
  1045. > instruct Eudora to send my Script a message whenever it
  1046. > receives a new message.  
  1047. > I know that Eudora sends an 'eNot' event with parameters the 
  1048. > references to all the newly received messages.  Then my script 
  1049. > could do some processing on this messages, such as delete 
  1050. > them, or automatically reply to some of them; things easily 
  1051. > done using AppleScript and Eudora.
  1052.  
  1053. Yup.  Write a script with a handler like this
  1054.  
  1055.      on <<event CSOmeNot>> msgList
  1056.         --
  1057.         -- actions to take when notified
  1058.         --
  1059.      end <<event CSOmeNot>>
  1060.  
  1061. where << means option-\ and >> means option-shift-\, then save it as a
  1062. stay-open application. Then you need to tell Eudora to send its notify
  1063. message to this application, at which time your handler will be called. 
  1064. Note that the application needs to be a stay-open application, so that if
  1065. you want to quit after you've handled the notification, you need to inlcude
  1066. a quit command. 
  1067.  
  1068. -- 
  1069. Hector Levesque
  1070. U. of Toronto
  1071. hector@cs.toronto.edu
  1072.  
  1073. ---------------------------
  1074.  
  1075. >From martino@husc10.harvard.edu (Carlo Martino)
  1076. Subject: [Q] ReleaseResource, PICTs and handles
  1077. Date: 24 Jun 94 02:37:19 GMT
  1078. Organization: Harvard University, Cambridge, Massachusetts
  1079.  
  1080. I began programming for the Mac less than a week ago, although
  1081. I have some prior familiarity with C and C++ for DOS/Windows.
  1082.  
  1083. I am using Symantec C++.  My question regards PictHandles and
  1084. generic resource handles and the relations between them.  I get
  1085. a PICT using GetPicture(int ResID).  When it comes time to 
  1086. release said PICT, ReleaseResource will not accept the PictHandle
  1087. returned by GetPicture.  This is somewhat sensible, as
  1088. ReleaseResource is defined as accepting a Handle, not a
  1089. PictHandle.  But I assume there is some way to release my PICT
  1090. resource.
  1091.  
  1092. Any help would be greatly appreciated.
  1093.  
  1094. Thank you in advance.
  1095.  
  1096. +++++++++++++++++++++++++++
  1097.  
  1098. >From jwbaxter@olympus.net (John W. Baxter)
  1099. Date: Fri, 24 Jun 1994 08:37:37 -0700
  1100. Organization: Internet for the Olympic Peninsula
  1101.  
  1102. In article <martino.772425439@husc10.harvard.edu>,
  1103. martino@husc10.harvard.edu (Carlo Martino) wrote:
  1104.  
  1105. > I began programming for the Mac less than a week ago, although
  1106. > I have some prior familiarity with C and C++ for DOS/Windows.
  1107. > I am using Symantec C++.  My question regards PictHandles and
  1108. > generic resource handles and the relations between them.  I get
  1109. > a PICT using GetPicture(int ResID).  When it comes time to 
  1110. > release said PICT, ReleaseResource will not accept the PictHandle
  1111. > returned by GetPicture.  This is somewhat sensible, as
  1112. > ReleaseResource is defined as accepting a Handle, not a
  1113. > PictHandle.  But I assume there is some way to release my PICT
  1114. > resource.
  1115.  
  1116. Cast the PicHandle to a generic Handle:
  1117.  
  1118.    ReleaseResource ((Handle)myPictureHandle);
  1119.  
  1120. Yes...casts are evil.  For things like this, they are necessary.
  1121. -- 
  1122. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  1123.    No hablo Intel.
  1124.    jwbaxter@pt.olympus.net
  1125.  
  1126. +++++++++++++++++++++++++++
  1127.  
  1128. >From Mark Hanrek <hanrek@cts.com>
  1129. Date: Sun, 26 Jun 1994 07:02:32 GMT
  1130. Organization: The Information Workshop
  1131.  
  1132. In article <martino.772425439@husc10.harvard.edu> Carlo Martino,
  1133. martino@husc10.harvard.edu writes:
  1134.  
  1135. > I am using Symantec C++.  My question regards PictHandles and
  1136. > generic resource handles and the relations between them.  I get
  1137. > a PICT using GetPicture(int ResID).  When it comes time to 
  1138. > release said PICT, ReleaseResource will not accept the PictHandle
  1139. > returned by GetPicture.  This is somewhat sensible, as
  1140. > ReleaseResource is defined as accepting a Handle, not a
  1141. > PictHandle.  But I assume there is some way to release my PICT
  1142. > resource.
  1143.  
  1144. When there is a type mismatch, it helps to think of it as simply the
  1145. signal that a human must intervene and decide what to do.
  1146.  
  1147. Unfortunately, there are no clear cut rules, otherwise, the compiler
  1148. could handle it.  The rules are ones that humans can easily deal with,
  1149. but only once we have learned what they are.
  1150.  
  1151. Chicken or the egg.
  1152.  
  1153. In order to learn, you must have working example source code handy, so
  1154. you can see what others have done.  I don't know of any reference book
  1155. that can help you with this, and when you think about it, the best
  1156. language to communicate such things is "example source code".
  1157.  
  1158. I and many others live by the approach of always keeping an eye peeled
  1159. for example source code that covers certain areas of programming that we
  1160. either need at the moment or will be needing, and downloading it when we
  1161. come across it.
  1162.  
  1163. - ---
  1164.  
  1165. There is no convenient way to declare types for things, yet also indicate
  1166. when certain types are "equivalent" in given certain situations.
  1167.  
  1168. In your case, it is 100% okay to ReleaseResource a PicHandle obtained
  1169. from GetResource.  A handle is a handle from ReleaseResource and
  1170. DisposeHandle's point of view, yet in the real programming world we also
  1171. have sub-types of handles based on what is in them, such as PicHandles.
  1172.  
  1173. Casting is a way the language allows us to temporarily change the type of
  1174. something, in a given situation, to get the COMPILER out of the fix of
  1175. not being able to understand "programming" adequately.
  1176.  
  1177.  
  1178. Hope this helps clarify things.
  1179.  
  1180. Mark Hanrek
  1181.  
  1182. P.S. Another really helpful thing to do is:  you should ALWAYS have
  1183. enabled "Check Pointer Types" and "Require Prototypes".
  1184.  
  1185. ---------------------------
  1186.  
  1187. >From jgrass@cs.umass.edu (Joshua Grass)
  1188. Subject: computer strategy
  1189. Date: 27 Jun 1994 21:34:30 GMT
  1190. Organization: University of Massachusetts, Amherst
  1191.  
  1192. I finished writing a mac game that is a pretty fun to play with two
  1193. people, but I would like to make it so that the computer can play as
  1194. well.  I'm pretty well versed in AI so I understand how hard it can
  1195. be for a computer to play any game, but I was curious if anyone had
  1196. any experience on computer strategy and possible "cheats" in the sense
  1197. of fairly simple algorithms that make the computer play (or appear to
  1198. play) a game well.  My game is cross between spaceward ho! and strategic
  1199. conquest if that helps any.  Any ideas about small memory, fairly quick
  1200. time algorithms that would help the computer would be great.  Thanks
  1201.  
  1202.                         Joshua
  1203.  
  1204.  
  1205.  
  1206. +++++++++++++++++++++++++++
  1207.  
  1208. >From rmah@panix.com (Robert S. Mah)
  1209. Date: Tue, 28 Jun 1994 00:24:34 -0500
  1210. Organization: One Step Beyond
  1211.  
  1212. jgrass@cs.umass.edu (Joshua Grass) wrote:
  1213.  
  1214. > I finished writing a mac game that is a pretty fun to play with two
  1215. > people, but I would like to make it so that the computer can play as
  1216. > well.  I'm pretty well versed in AI so I understand how hard it can
  1217. > be for a computer to play any game, but I was curious if anyone had
  1218. > any experience on computer strategy and possible "cheats" in the sense
  1219. > of fairly simple algorithms that make the computer play (or appear to
  1220. > play) a game well.  My game is cross between spaceward ho! and strategic
  1221. > conquest if that helps any.  Any ideas about small memory, fairly quick
  1222. > time algorithms that would help the computer would be great.  Thanks
  1223.  
  1224. Ooooh, sounds like a game I would love!
  1225.  
  1226. I think it would help a lot if you could describe the game a bit more,
  1227. but here are some off-the-cuff suggestions.
  1228.  
  1229. First is to have different behaviours associated with each unit, depend-
  1230. ing upon it's condition, locality of allied units and locality of enemy
  1231. units.  For example, a unit could have three modes: aggressive, defensive,
  1232. "dig in", retreat, etc.  Based on relative strengths and this mode, one
  1233. could determine the unit's behaviour.
  1234.  
  1235. As for attacks, have the unit do some sort of calculation on enemy units
  1236. to the unit to attack.  Note that, the algorithm used is dependent upon
  1237. what kinds of military tactics you subscribe to.  Or possibly let the
  1238. choice of algorithm be based on the kind of virtual general.
  1239.  
  1240. Finally, there is a book called "Computer Games" or somesuch that 
  1241. describes a wide variety of tactics that computer games can take vs
  1242. human beings.  Can't remember the title, but I _know_ it had sections
  1243. on military style simulations.  Another book I remember reading was 
  1244. one that did simulations based on "spheres of infulence".  This may
  1245. help the computer set up global level strategies.
  1246.  
  1247. Cheers,
  1248. Rob
  1249. ___________________________________________________________________________
  1250. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1251.  
  1252. +++++++++++++++++++++++++++
  1253.  
  1254. >From raubvogel@gauss.aero.ufl.edu (Doctor Caligari)
  1255. Date: 28 Jun 1994 13:38:56 GMT
  1256. Organization: Cesare Somnambulisms
  1257.  
  1258. In article <rmah-280694002434@rmah.dialup.access.net>, rmah@panix.com
  1259. (Robert S. Mah) wrote:
  1260.  
  1261. > jgrass@cs.umass.edu (Joshua Grass) wrote:
  1262.  
  1263. [...]
  1264.  
  1265. > Finally, there is a book called "Computer Games" or somesuch that 
  1266. > describes a wide variety of tactics that computer games can take vs
  1267. > human beings.  Can't remember the title, but I _know_ it had sections
  1268. > on military style simulations.  Another book I remember reading was 
  1269. > one that did simulations based on "spheres of infulence".  This may
  1270. > help the computer set up global level strategies.
  1271.     Could you dig out the names of those books?
  1272.  
  1273. +++++++++++++++++++++++++++
  1274.  
  1275. >From nick@cs.stanford.edu (Nick Parlante)
  1276. Date: 28 Jun 1994 22:41:47 GMT
  1277. Organization: Stanford University
  1278.  
  1279. In article <rmah-280694002434@rmah.dialup.access.net>, rmah@panix.com
  1280. (Robert S. Mah) wrote:
  1281.  
  1282. > jgrass@cs.umass.edu (Joshua Grass) wrote:
  1283. > > I finished writing a mac game that is a pretty fun to play with two
  1284. > > people, but I would like to make it so that the computer can play as
  1285. > > well.  I'm pretty well versed in AI so I understand how hard it can
  1286. > > be for a computer to play any game, but I was curious if anyone had
  1287. > > any experience on computer strategy and possible "cheats" in the sense
  1288. > > of fairly simple algorithms that make the computer play (or appear to
  1289. > > play) a game well.  My game is cross between spaceward ho! and strategic
  1290. > > conquest if that helps any.  Any ideas about small memory, fairly quick
  1291. > > time algorithms that would help the computer would be great.  Thanks
  1292. > Ooooh, sounds like a game I would love!
  1293. > I think it would help a lot if you could describe the game a bit more,
  1294. > but here are some off-the-cuff suggestions.
  1295. > First is to have different behaviours associated with each unit, depend-
  1296. > ing upon it's condition, locality of allied units and locality of enemy
  1297. > units.  For example, a unit could have three modes: aggressive, defensive,
  1298. > "dig in", retreat, etc.  Based on relative strengths and this mode, one
  1299. > could determine the unit's behaviour.
  1300. > As for attacks, have the unit do some sort of calculation on enemy units
  1301. > to the unit to attack.  Note that, the algorithm used is dependent upon
  1302. > what kinds of military tactics you subscribe to.  Or possibly let the
  1303. > choice of algorithm be based on the kind of virtual general.
  1304. > Finally, there is a book called "Computer Games" or somesuch that 
  1305. > describes a wide variety of tactics that computer games can take vs
  1306. > human beings.  Can't remember the title, but I _know_ it had sections
  1307. > on military style simulations.  Another book I remember reading was 
  1308. > one that did simulations based on "spheres of infulence".  This may
  1309. > help the computer set up global level strategies.
  1310. > Cheers,
  1311. > Rob
  1312. > ___________________________________________________________________________
  1313. > Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1314.  
  1315. Here's a technique that's worked well for me (I used it to create 
  1316. a strategy for playing Tetris well, but it should work for any 
  1317. game)--
  1318.  
  1319. 1) Code up a BestMove() or whatever function which 
  1320. numerically evaluates the quality of a given move or position. 
  1321. Internally, the function should rely liberally on numeric 
  1322. constants such as...
  1323.  
  1324. kTankOffense // the offensive value of a "tank"
  1325. kTankOffenseDecay // how much the threat of a tank decreases 
  1326. the further you are from it
  1327.  
  1328. // A squadron of planes has a net offense which is a linear 
  1329. function of the number of planes
  1330. kPlaneY  // the y-intercept 
  1331. kPlaneSlope  // the slope
  1332.  
  1333.  
  1334. etc. etc.
  1335.  
  1336. So the point is, you structure a strategy which seems 
  1337. reasonable, but any time there's a tradeoff or something you're 
  1338. not sure about, you defer it to a float constant.
  1339.  
  1340. 2) So now the problem is reduced to finding values for the 
  1341. constants which yield a good strategy. Traditional hill-climbing 
  1342. methods to optimize the constants will have problems because 
  1343. the search space has a large number of dimensions (one for 
  1344. each constant) and whatever "rating" function you make up to 
  1345. rate the quality of a particular strategy is likely to be 
  1346. discontinuous.
  1347.  
  1348. Fortunately, Genetic Algorithms are ideal for searching this sort 
  1349. of large, discontinuous space. Here's the 10-second guide to 
  1350. genetic algorithms: create a population of maybe 500 different 
  1351. randomly generated strategies. Rate them all in some way by 
  1352. having them all play a fixed strategy, or by having them play 
  1353. each other. And finally recombine/breed the best individuals 
  1354. from the old generation to make children for a new generation. 
  1355. Just as it goes in the real world according to Darwin, the 
  1356. individuals from the old generation with the highest ratings 
  1357. should be proportionately more likely to be chosen as parents.
  1358.  
  1359. Genetic algorithms are not too hard to code up, but they can 
  1360. consume a lot of CPU time. Check out Goldberg's book Genetic 
  1361. Algorithms in Optimization and Somethingorother. Koza's 
  1362. mammoth GA book describes a more flexible but potentially 
  1363. more costly approach.
  1364.  
  1365. The quality of the strategy you get will depend very much on 
  1366. the metrics and insights which you encode in the BestMove() 
  1367. function in step (1) as well as the "rating" function you use to 
  1368. guide the optimization in step (2). I've used this technique to 
  1369. create a strategy which plays Tetris an order of magnitude 
  1370. better than anything I was able to code up on my own without 
  1371. the genetic algorithm doing the optimization.
  1372.  
  1373. Cheers,
  1374.  
  1375. Nick
  1376.  
  1377. ---------------------------
  1378.  
  1379. End of C.S.M.P. Digest
  1380. **********************
  1381.  
  1382.  
  1383.