home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-003 < prev    next >
Text File  |  2010-09-21  |  34KB  |  928 lines

  1. Received-Date: Mon, 14 Mar 1994 14:36:51 +0100
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: C.S.M.P. Digest, Issue 3
  4. To: csmp-digest@ens.fr
  5. Date: Mon, 14 Mar 94 14:36:48 MET
  6. X-Mailer: ELM [version 2.3 PL11]
  7. Errors-To: listman@ens.fr
  8. Reply-To: pottier@clipper.ens.fr
  9. X-Sequence: 4
  10.  
  11. C.S.M.P. Digest             Mon, 14 Mar 94       Volume 3 : Issue 3
  12.  
  13. Today's Topics:
  14.  
  15.         A4 Worlds in MPW c-c++? Is it possible?
  16.         Documented sliders?
  17.         How do I know if AppleTalk uses print port?
  18.         How to convert date to seconds *correctly*?
  19.         To Handle or not to Handle?
  20.         When to unlock?
  21.  
  22.  
  23.  
  24. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  25. (pottier@clipper.ens.fr).
  26.  
  27. The digest is a collection of article threads from the internet newsgroup
  28. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  29. regularly and want an archive of the discussions.  If you don't know what a
  30. newsgroup is, you probably don't have access to it.  Ask your systems
  31. administrator(s) for details.  If you don't have access to news, you may
  32. still be able to post messages to the group by using a mail server like
  33. anon.penet.fi (mail help@anon.penet.fi for more information).
  34.  
  35. Each issue of the digest contains one or more sets of articles (called
  36. threads), with each set corresponding to a 'discussion' of a particular
  37. subject.  The articles are not edited; all articles included in this digest
  38. are in their original posted form (as received by our news server at
  39. nef.ens.fr).  Article threads are not added to the digest until the last
  40. article added to the thread is at least two weeks old (this is to ensure that
  41. the thread is dead before adding it to the digest).  Article threads that
  42. consist of only one message are generally not included in the digest.
  43.  
  44. The digest is officially distributed by two means, by email and ftp.
  45.  
  46. If you want to receive the digest by mail, send email to listserv@ens.fr
  47. with no subject and one of the following commands as body:
  48.     help                        Sends you a summary of commands
  49.     subscribe csmp-digest Your Name    Adds you to the mailing list
  50.     signoff csmp-digest            Removes you from the list
  51. Once you have subscribed, you will automatically receive each new
  52. issue as it is created.
  53.  
  54. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  55. Questions related to the ftp site should be directed to
  56. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  57. digest are available there.
  58.  
  59. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  60.  
  61.  
  62. -------------------------------------------------------
  63.  
  64. >From btodorof@hmc.edu. (Brian Todoroff)
  65. Subject: A4 Worlds in MPW c-c++? Is it possible?
  66. Date: 26 Feb 1994 08:51:25 GMT
  67. Organization: Harvey Mudd College, Claremont CA
  68.  
  69. Does anyone know if it is possible to do A4 worlds such as those in
  70. Think C in MPW C.  This would be very useful to me in writing some
  71. external code modules for Photoshop.  Please help if you can.
  72.  
  73. +++++++++++++++++++++++++++
  74.  
  75. >From macguru@halcyon.com. (Allan Foster)
  76. Date: 27 Feb 1994 22:22:01 GMT
  77. Organization: Guru Inc
  78.  
  79. In article <2kn2id$pvi@jaws.cs.hmc.edu>
  80. btodorof@hmc.edu. (Brian Todoroff) writes:
  81.  
  82. > Does anyone know if it is possible to do A4 worlds such as those in
  83. > Think C in MPW C.  This would be very useful to me in writing some
  84. > external code modules for Photoshop.  Please help if you can.
  85.  
  86. Well, no.  Not A4 worlds exactly.  But it is fairly easy to use A5
  87. worlds from stand alone code resources in MPW.  For MPW C, it is very
  88. check out technote 256 to show you how to do it.
  89.  
  90. Doing it with MPW C++ is a little more exciting.  The main problem is
  91. dealing with static constructors, and the need for a jump table.  I
  92. wrote a paper for MacHack 91 about doing this, and the code was
  93. released public domain.  I know it is up on AOL, and on CI$,  and is
  94. probv available on one of the internet acrhives as well.
  95.  
  96. Regards
  97.  
  98. Allan Foster
  99.  
  100. ----------------------------------------------------------
  101. I am responsible for what I say and do. -- Allan Foster --
  102.  
  103. ---------------------------
  104.  
  105. >From hellstrm@access3.digex.net (Ben Hellstrom)
  106. Subject: Documented sliders?
  107. Date: 21 Feb 1994 14:44:13 -0500
  108. Organization: Express Access Online Communications, Greenbelt, MD USA
  109.  
  110. I am trying to put a slider in a modeless dialog.  I have tried swiping
  111. the slider from the "Sound" CDEV and also from "Appmaker" (which I own).
  112. After I load in the resource and set up the contrlRect, contrlValue, etc
  113. the slider comes up looking OK and is updated properly.  Furthermore,
  114. when I click on it, FindWindow() returns a code of 'inThumb'.  But when
  115. I try to track it the slider thumb just sits there. TrackControl doesn't
  116. return until I release the mouse button, but the contrlValue field is
  117. unchanged.
  118.  
  119. Any suggestions? 
  120.  
  121. Are there any *documented* slider CNTL resources around.  Without
  122. any documentation, they are hard to figure out.  I searched through
  123. Apple's IM and the TNs and didn't find anything under "slider".
  124.  
  125. Thanks for any help.
  126.  
  127. Ben Hellstrom
  128. hellstrm@access.digex.net
  129.  
  130.  
  131. +++++++++++++++++++++++++++
  132.  
  133. >From marshall@kauri.vuw.ac.nz (Stephen Marshall)
  134. Date: 24 Feb 1994 20:54:50 GMT
  135. Organization: Victoria University of Wellington
  136.  
  137. In article <2kb2ud$nth@access3.digex.net>, hellstrm@access3.digex.net (Ben
  138. Hellstrom) wrote:
  139.  
  140. > Are there any *documented* slider CNTL resources around.  Without
  141. > any documentation, they are hard to figure out.  I searched through
  142. > Apple's IM and the TNs and didn't find anything under "slider".
  143. > Thanks for any help.
  144. > Ben Hellstrom
  145. > hellstrm@access.digex.net
  146.  
  147. Somewhat foolishly I have posted a request for such a beast on
  148. Alt.sources.mac (apparently a no-no). No responses yet. For such a commonly
  149. implemented beast it seems to be quite uncommon to post code for it. If
  150. anyone does post source or an explanation of how to use the sound cdevs
  151. CNTL I would be greatful. 
  152.  
  153. PS: is there not a slight copyright problem with using the CNTL resource
  154. out of the Sound CDEV? I would have thought that Apples copyright would
  155. prohibit plundering?
  156.  
  157. Stephen
  158. -- 
  159. Macintosh Consultant                              Marshall@kauri.vuw.ac.nz
  160. Victoria University of Wellington
  161. New Zealand
  162.  
  163. +++++++++++++++++++++++++++
  164.  
  165. >From egurney@vcd.hp.com (Eddy J. Gurney)
  166. Date: Fri, 25 Feb 1994 18:23:20 GMT
  167. Organization: Hewlett-Packard VCD
  168.  
  169. Stephen Marshall (marshall@kauri.vuw.ac.nz) wrote:
  170. >In article <2kb2ud$nth@access3.digex.net>, hellstrm@access3.digex.net (Ben
  171. >Hellstrom) wrote:
  172. >> Are there any *documented* slider CNTL resources around.  Without
  173. >> any documentation, they are hard to figure out.  I searched through
  174. >> Apple's IM and the TNs and didn't find anything under "slider".
  175.  
  176. >Somewhat foolishly I have posted a request for such a beast on
  177. >Alt.sources.mac (apparently a no-no). No responses yet. For such a commonly
  178. >implemented beast it seems to be quite uncommon to post code for it. If
  179. >anyone does post source or an explanation of how to use the sound cdevs
  180. >CNTL I would be greatful. 
  181.  
  182. There is a very nice freeware slider CDEF that is used in Jersey 
  183. Scientific's CMaster.  The only reason I know it's freeware is from the 
  184. little blurb in the manual (which is at home right now).  If someone
  185. knows where this CDEF is available as a nice little package, with
  186. documentation and maybe even (we can always hope) source, please let
  187. us know!
  188.  
  189. If no one can find it, I'll extract the CDEF and explain how it works
  190. (someone sent me e-mail a while ago explaining that it is pretty easy
  191. to use, just use SetMinCtrl/SetMaxCtrl, etc.) in a short read me and
  192. submit it to alt.sources.mac...
  193.  
  194. --
  195. Eddy J. Gurney N8FPW   Hewlett-Packard Company, Vancouver (USA!) Division
  196. egurney@vcd.hp.com                       #include <standard-disclaimer.h>
  197. "Failures are divided into two classes-- those who thought and never did,
  198.       and those who did and never thought."     John Charles Salak
  199.  
  200. +++++++++++++++++++++++++++
  201.  
  202. >From hpoppe@ncar.ucar.edu (Herb Poppe)
  203. Date: 25 Feb 1994 19:17:04 GMT
  204. Organization: National Center for Atmospheric Research
  205.  
  206. In article <marshall-250294095436@makomako.its.vuw.ac.nz> 
  207. marshall@kauri.vuw.ac.nz (Stephen Marshall) writes:
  208.  
  209. > In article <2kb2ud$nth@access3.digex.net>, hellstrm@access3.digex.net 
  210. (Ben
  211. > Hellstrom) wrote:
  212. >  
  213. > > Are there any *documented* slider CNTL resources around.  Without
  214. > > any documentation, they are hard to figure out.  I searched through
  215. > > Apple's IM and the TNs and didn't find anything under "slider".
  216. > > ...
  217. > Somewhat foolishly I have posted a request for such a beast on
  218. > Alt.sources.mac (apparently a no-no). No responses yet. For such a 
  219. commonly
  220. > implemented beast it seems to be quite uncommon to post code for it. If
  221. > anyone does post source or an explanation of how to use the sound cdevs
  222. > CNTL I would be greatful. 
  223. >...
  224.  
  225. Source code (in C) for a slider CDEF (horiz. orientation only) is 
  226. available at the alt.sources.mac archive:
  227.  
  228. ftpbio.bgsu.edu
  229.  
  230. in:
  231.  
  232. "/Bio Mail Server/ftp/pub/alt.sources.mac/"
  233.  
  234. as:
  235.  
  236. cdef-slider.cpt
  237. cdef-slider.info
  238.  
  239. Herb Poppe                 National Center for Atmospheric Research (NCAR)
  240. hpoppe@ncar.ucar.edu       1850 Table Mesa Dr.
  241. (303) 497-1296             Boulder, CO  80303
  242.  
  243. +++++++++++++++++++++++++++
  244.  
  245. >From hellstrm@access2.digex.net (Ben Hellstrom)
  246. Date: 26 Feb 1994 14:30:41 -0500
  247. Organization: Express Access Online Communications, Greenbelt, MD USA
  248.  
  249. In article <marshall-250294095436@makomako.its.vuw.ac.nz>,
  250. Stephen Marshall <marshall@kauri.vuw.ac.nz> wrote:
  251. >In article <2kb2ud$nth@access3.digex.net>, hellstrm@access3.digex.net (Ben
  252. >Hellstrom) wrote:
  253. >> Are there any *documented* slider CNTL resources around.  Without
  254. >> any documentation, they are hard to figure out.  I searched through
  255. >> Apple's IM and the TNs and didn't find anything under "slider".
  256. >> 
  257. >> Thanks for any help.
  258. >> 
  259. >> Ben Hellstrom
  260. >> hellstrm@access.digex.net
  261. >
  262. >Somewhat foolishly I have posted a request for such a beast on
  263. >Alt.sources.mac (apparently a no-no). No responses yet. For such a commonly
  264. >implemented beast it seems to be quite uncommon to post code for it. If
  265. >anyone does post source or an explanation of how to use the sound cdevs
  266. >CNTL I would be greatful. 
  267. >
  268. >PS: is there not a slight copyright problem with using the CNTL resource
  269. >out of the Sound CDEV? I would have thought that Apples copyright would
  270. >prohibit plundering?
  271. >
  272. >Stephen
  273. >-- 
  274. The sound CDEV is already in public domain (ftp.apple.com) with liscence
  275. to copy.  I didn't intend to distribute it. BTW, I also own AppMaker 1.5.4
  276. which *also* has the identical slider and liscence to distribute.  The
  277. darndest thing is that I can easily put together an AppMaker project where
  278. the slider works but when I transfer the code resources over to my project
  279. it stops working!!
  280.  
  281. Ben Hellstrom
  282. hellstrm@access.digex.net
  283.  
  284.  
  285.  
  286. ---------------------------
  287.  
  288. >From johnc@flora.ruakura.cri.nz (John Curtis)
  289. Subject: How do I know if AppleTalk uses print port?
  290. Date: 21 Feb 1994 20:48:20 GMT
  291. Organization: Hort+Research
  292.  
  293. How do I find out if AppleTalk is controlling the printer port?
  294.  
  295. I can check to see if the serial drivers are in use via CRMIsDriverOpen().
  296. Likewise I can see if .MPP or .ATP is open, but can't tell if they're using
  297. ethernet or the printer port...
  298.  
  299. Basically I want my app to ask before stealing the printer port...
  300.  
  301. Thanks!
  302. -- 
  303. -----------------------------------------------------------------------------
  304. John Curtis            | 
  305. Hort+Research          |                  johnc@flora.ruakura.cri.nz
  306. Hamilton, New Zealand  |                  curtisj@ruakura.cri.nz
  307.  
  308. +++++++++++++++++++++++++++
  309.  
  310. >From Bob@lapwing.demon.co.uk (Bob Lindsey)
  311. Date: Tue, 22 Feb 1994 05:35:50 +0000
  312. Organization: LapWing Communications Ltd
  313.  
  314. In article <johnc-220294085249@160.4.128.121>
  315.            johnc@flora.ruakura.cri.nz "John Curtis" writes:
  316. > How do I find out if AppleTalk is controlling the printer port?
  317.  
  318. IM vol II, pages 304 to 305 cover this. 
  319.  
  320. -- 
  321. Bob Lindsey on bob@lapwing.demon.co.uk
  322.  
  323. +++++++++++++++++++++++++++
  324.  
  325. >From d88-jwa@hemul.nada.kth.se (Jon Wdtte)
  326. Date: 22 Feb 1994 17:09:22 GMT
  327. Organization: Royal Institute of Technology, Stockholm, Sweden
  328.  
  329. In <johnc-220294085249@160.4.128.121> johnc@flora.ruakura.cri.nz (John Curtis) writes:
  330.  
  331. >How do I find out if AppleTalk is controlling the printer port?
  332. >Basically I want my app to ask before stealing the printer port...
  333.  
  334. Just call OpenDriver on the out port; if LocalTalk is using it,
  335. you will get a port busy error back.
  336.  
  337. Of course, you should use the Comms Resource Manager to build
  338. a pop-up menu for the user to selects what port to use. See
  339. code in the FAQ.
  340. -- 
  341.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  342.  
  343.    What we need is a good GNU [...] licence manager implementation.
  344.                      -- Raphael Manfredi
  345.  
  346. +++++++++++++++++++++++++++
  347.  
  348. >From leonardr@netcom.com (Leonard Rosenthol)
  349. Date: Wed, 23 Feb 1994 18:58:51 GMT
  350. Organization: Aladdin Systems, Inc.
  351.  
  352. In article <2kde82$836@news.kth.se>, d88-jwa@hemul.nada.kth.se (Jon Wtte)
  353. wrote:
  354.  
  355. > In <johnc-220294085249@160.4.128.121> johnc@flora.ruakura.cri.nz (John Curtis) writes:
  356. > >How do I find out if AppleTalk is controlling the printer port?
  357. > >Basically I want my app to ask before stealing the printer port...
  358. > Just call OpenDriver on the out port; if LocalTalk is using it,
  359. > you will get a port busy error back.
  360.      Nope, won't work!   _OpenDriver does NOT return "Port in Use" :(.
  361.  
  362.     Also, the other issue that no one has yet brought up is that on certain
  363. machines (ie. Duos) there is only ONE external serial port which doubles as
  364. both modem & printer port.   This is a very special case you need to worry
  365. about when trying things like this.
  366.  
  367. Leonard
  368. --------------------------------------------------------------------------
  369. Leonard Rosenthol                      Internet:       leonardr@netcom.com
  370. Director of Advanced Technology        AppleLink:      MACgician
  371. Aladdin Systems, Inc.                  GEnie:          MACgician
  372.  
  373. +++++++++++++++++++++++++++
  374.  
  375. >From jvp@tools1.ee.iastate.edu (Jim Van Peursem)
  376. Date: 24 Feb 94 21:55:42 GMT
  377. Organization: Iowa State University, Ames, Iowa
  378.  
  379.  
  380. >> In <johnc-220294085249@160.4.128.121> johnc@flora.ruakura.cri.nz (John Curtis) writes:
  381. >> 
  382. >> >How do I find out if AppleTalk is controlling the printer port?
  383. >> >Basically I want my app to ask before stealing the printer port...
  384.  
  385. >In article <2kde82$836@news.kth.se>, d88-jwa@hemul.nada.kth.se (Jon Wtte)
  386. >wrote:
  387. >> Just call OpenDriver on the out port; if LocalTalk is using it,
  388. >> you will get a port busy error back.
  389.  
  390. In <leonardr-230294105851@leonardr.slip.netcom.com> leonardr@netcom.com (Leonard Rosenthol) writes:
  391.  
  392. >     Nope, won't work!   _OpenDriver does NOT return "Port in Use" :(.
  393.  
  394.   It returns error -97 (portInUse) every time I do it. This may be on
  395. the particular machines I'm testing this on, but I doubt it. Error -97
  396. is an AppleTalk error.
  397.  
  398.   This may be confused with "how do I tell if a port is open" which is
  399. NOT possible. But if the port is using AppleTalk, it IS possible.
  400.  
  401. >    Also, the other issue that no one has yet brought up is that on certain
  402. >machines (ie. Duos) there is only ONE external serial port which doubles as
  403. >both modem & printer port.   This is a very special case you need to worry
  404. >about when trying things like this.
  405.  
  406.   Or worse yet, inconsistancies in the API between machines. Read my
  407. message regarding the PB100 difference I recently discovered.
  408.  
  409. +---------------------------------------------------------------+
  410. | Jim Van Peursem - Ph.D. Candidate - Ham Radio -> KE0PH        |
  411. | Department of Electrical Engineering and Computer Engineering |
  412. | Iowa State University - Ames, IA 50011 : (515) 294-8339       |
  413. | internet - jvp@iastate.edu  -or-  jvp@cpre1.ee.iastate.edu    |
  414. +---------------------------------------------------------------+
  415.  
  416. +++++++++++++++++++++++++++
  417.  
  418. >From egurney@vcd.hp.com (Eddy J. Gurney)
  419. Date: Fri, 25 Feb 1994 18:45:24 GMT
  420. Organization: Hewlett-Packard VCD
  421.  
  422. Jim Van Peursem (jvp@tools1.ee.iastate.edu) wrote:
  423.  
  424. >>> In <johnc-220294085249@160.4.128.121> johnc@flora.ruakura.cri.nz writes:
  425. >>> 
  426. >>> >How do I find out if AppleTalk is controlling the printer port?
  427. >>> >Basically I want my app to ask before stealing the printer port...
  428.  
  429. >  It returns error -97 (portInUse) every time I do it. This may be on
  430. >the particular machines I'm testing this on, but I doubt it. Error -97
  431. >is an AppleTalk error.
  432.  
  433. >  This may be confused with "how do I tell if a port is open" which is
  434. >NOT possible. But if the port is using AppleTalk, it IS possible.
  435.  
  436. Why is it NOT possible?  Can't you call GetDCtrlEntry on ports 5,6,7,8
  437. (depending on which port you want to know is open... .Ain, .Aout, .Bin,
  438. or .Bout, respectively) and check bit 5 of the dCtlFlags, which is set
  439. if the driver is open?
  440.  
  441. This should work for the built-in ports; don't know how you'd do it for 
  442. Comm Toolbox drivers (since you don't know the driver's refNum... or
  443. do you?) 
  444.  
  445. --
  446. Eddy J. Gurney N8FPW   Hewlett-Packard Company, Vancouver (USA!) Division
  447. egurney@vcd.hp.com                       #include <standard-disclaimer.h>
  448. "Failures are divided into two classes-- those who thought and never did,
  449.       and those who did and never thought."     John Charles Salak
  450.  
  451. +++++++++++++++++++++++++++
  452.  
  453. >From leonardr@netcom.com (Leonard Rosenthol)
  454. Date: Fri, 25 Feb 1994 23:13:12 GMT
  455. Organization: Aladdin Systems, Inc.
  456.  
  457. In article <CLsMro.Dn7@vcd.hp.com>, egurney@vcd.hp.com (Eddy J. Gurney)
  458. wrote:
  459.  
  460. > Jim Van Peursem (jvp@tools1.ee.iastate.edu) wrote:
  461. > >  This may be confused with "how do I tell if a port is open" which is
  462. > >NOT possible. But if the port is using AppleTalk, it IS possible.
  463. > Why is it NOT possible?  Can't you call GetDCtrlEntry on ports 5,6,7,8
  464. > (depending on which port you want to know is open... .Ain, .Aout, .Bin,
  465. > or .Bout, respectively) and check bit 5 of the dCtlFlags, which is set
  466. > if the driver is open?
  467.      You can certainly do this - works like a champ and it is how most
  468. applications today check for "port in use" since _OpenDriver is not
  469. guaranteed to do it (see appropriate Tech Note).
  470.  
  471. > This should work for the built-in ports; don't know how you'd do it for 
  472. > Comm Toolbox drivers (since you don't know the driver's refNum... or
  473. > do you?) 
  474.      You can get the names of each port via the Communications Resource
  475. Manager (CRM), and then walk through the DCE's to find the entry for the
  476. port in question.
  477.  
  478. Leonard
  479. --------------------------------------------------------------------------
  480. Leonard Rosenthol                      Internet:       leonardr@netcom.com
  481. Director of Advanced Technology        AppleLink:      MACgician
  482. Aladdin Systems, Inc.                  GEnie:          MACgician
  483.  
  484. +++++++++++++++++++++++++++
  485.  
  486. >From jvp@tools1.ee.iastate.edu (Jim Van Peursem)
  487. Date: 26 Feb 94 20:18:14 GMT
  488. Organization: Iowa State University, Ames, Iowa
  489.  
  490. >> Jim Van Peursem (jvp@tools1.ee.iastate.edu) wrote:
  491. >> 
  492. >> >  This may be confused with "how do I tell if a port is open" which is
  493. >> >NOT possible. But if the port is using AppleTalk, it IS possible.
  494.  
  495. >In article <CLsMro.Dn7@vcd.hp.com>, egurney@vcd.hp.com (Eddy J. Gurney)
  496. >wrote:
  497.  
  498. >> Why is it NOT possible?  Can't you call GetDCtrlEntry on ports 5,6,7,8
  499. >> (depending on which port you want to know is open... .Ain, .Aout, .Bin,
  500. >> or .Bout, respectively) and check bit 5 of the dCtlFlags, which is set
  501. >> if the driver is open?
  502.  
  503. In <leonardr-250294151312@leonardr.slip.netcom.com> leonardr@netcom.com (Leonard Rosenthol) writes:
  504.  
  505. >     You can certainly do this - works like a champ and it is how most
  506. >applications today check for "port in use" since _OpenDriver is not
  507. >guaranteed to do it (see appropriate Tech Note).
  508.  
  509.   Ah, but is bit 5 guaranteed? From the tech note it looks like a bit of
  510. a kludge. From the language, is sounded like it's how the CRM does it, but
  511. it's not guaranteed.
  512.  
  513. +---------------------------------------------------------------+
  514. | Jim Van Peursem - Ph.D. Candidate - Ham Radio -> KE0PH        |
  515. | Department of Electrical Engineering and Computer Engineering |
  516. | Iowa State University - Ames, IA 50011 : (515) 294-8339       |
  517. | internet - jvp@iastate.edu  -or-  jvp@cpre1.ee.iastate.edu    |
  518. +---------------------------------------------------------------+
  519.  
  520. ---------------------------
  521.  
  522. >From cbo@cs.toronto.edu (Calvin Bruce Ostrum)
  523. Subject: How to convert date to seconds *correctly*?
  524. Date: 24 Feb 94 19:56:23 GMT
  525. Organization: Department of Computer Science, University of Toronto
  526.  
  527.  
  528. This may strike people as an ignorant and trivial question, but I need
  529. to know the answer anyway.  How does one convert a date (y/m/d h:m:s) to
  530. seconds elapsed since Jan 1 1904?  I don't have very complete documentation
  531. for the tools I have available, and in MPW 3.2 am using mktime.  This seems
  532. to pick up the local time zone okay, but it does not seem to pick up whether
  533. daylight savings time is active.  This is what I need it to do.  When I read
  534. in a file of dates without timezone specified, it should use the local time
  535. zone, which it does.  But it should also subtract an hour from the date 
  536. before doing the conversion if the date is during the time of year when
  537. daylight savings time is active.  This it does not do.  Is there something
  538. I can set to make it do this?  (If not, is there a simple uniform rule that
  539. determines when dst stops and starts? I suppose I should have picked this
  540. rule up by now, but I haven't).
  541.  
  542. Please email responses.  Thank you.
  543.  
  544. ---------------------------------------------------------------------------
  545. Calvin Ostrum                                            cbo@cs.toronto.edu
  546. ---------------------------------------------------------------------------
  547.   It is a far, far better thing to have a firm anchor in nonsense than
  548.   to put out on the troubled seas of thought.  -- John Kenneth Galbraith
  549. ---------------------------------------------------------------------------
  550.  
  551. +++++++++++++++++++++++++++
  552.  
  553. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  554. Date: Sun, 27 Feb 1994 13:10:02 -0600
  555. Organization: University of Illinois at Urbana-Champaign
  556.  
  557. In article <94Feb24.145607est.48169@neat.cs.toronto.edu>,
  558. cbo@cs.toronto.edu (Calvin Bruce Ostrum) wrote:
  559.  
  560. >This may strike people as an ignorant and trivial question, but I need
  561. >to know the answer anyway.  How does one convert a date (y/m/d h:m:s) to
  562. >seconds elapsed since Jan 1 1904?
  563.  
  564. The system routines String2Date and String2Time will convert string
  565. representations into a date record. These will work for all kinds of
  566. international representations and other variations on the standard by
  567. using the system tokenizer. The date record can be converted to number of
  568. seconds since 1/1/1904 by using LongDate2Secs.
  569.  
  570. >This seems to pick up the local time zone okay, but it does not seem to pick
  571. >up whether daylight savings time is active. This is what I need it to do. When
  572. >I read in a file of dates without timezone specified, it should use the local
  573. >time zone, which it does. But it should also subtract an hour from the date
  574. >before doing the conversion if the date is during the time of year when
  575. >daylight savings time is active. This it does not do. Is there something I can
  576. >set to make it do this? (If not, is there a simple uniform rule that
  577. >determines when dst stops and starts? I suppose I should have picked this rule
  578. >up by now, but I haven't).
  579.  
  580. The rules for daylight savings time not only vary from country to country,
  581. but they also vary within countries. (Arizona and parts of Indiana do not
  582. use daylight savings). The only way to account for it is to have the time
  583. zone encoded in the date string itself, either using rules which tell you
  584. whether daylight savings is in effect, like using "CST" for Central
  585. Standard Time and "CDT" for Central Daylight Time,  or using an absolute
  586. offset from GMT, like "-0600" for Central Standard Time (6 hours less than
  587. GMT) or "-0500" for Central Daylight Time (5 hours less than GMT).
  588.  
  589. I am working on a routine that uses all of the international routines
  590. properly to encode and decode such strings according to RFC 822 and RFC
  591. 1123 rules, including parsing out comments. I will post it to the net when
  592. I am finished.
  593.  
  594. pr
  595. -- 
  596. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  597. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  598. System manager - Cognitive Science Group, Beckman Institute, UIUC
  599. Internet: resnick@cogsci.uiuc.edu
  600.  
  601. ---------------------------
  602.  
  603. >From francis@pinza.demon.co.uk (Francis H. Knight)
  604. Subject: To Handle or not to Handle?
  605. Date: Fri, 25 Feb 1994 19:33:16 GMT
  606. Organization: Hertfordshire Mac Oasis
  607.  
  608.  
  609. Recently finding myself with an unanticipated amount of free time, I'm
  610. using
  611. the opportunity to get up to speed with Think C (5.0.4).
  612.  
  613. I've got myself a deeply nested struct, which contains a load of
  614. configuration stuff, etcetera, and I've referred to this struct by a
  615. Handle,
  616. so the memory manager those kind folks at Apple gave us can do its stuff.
  617. Now, a lot of the general-purpose lower-level functions operate on
  618. components
  619. of the struct, so I'm dereferencing them before entering the functions. 
  620.  
  621. I'm finding it very laborious, and not very creative, to work out where to
  622. bracket (de-)references to the struct with HLock/HUnlock, given that a heap
  623. compaction trigger may be hidden within several layers of function calls.
  624. In
  625. fact, I'm sure I've missed some, as I'm still experiencing Bus Errors.
  626.  
  627. To help my thinking, can anyone offer any good:
  628.  
  629.       Methods of deciding where to HLock/HUnlock? I'm using the manual method
  630.       of combing through my code line by line and checking against the list
  631.       of memory-moving routines in Inside Mac. I feel my Mac ought to be able 
  632.       to flag the potential triggers for me!
  633.     
  634.       Criteria for judging at the outset of a project whether the hassle
  635.       of correct HLock/HUnlocking is going to outweigh the benefits of using 
  636.       NewHandle over NewPtr?
  637.     
  638.       Methods for debugging CDEVs under System 7? Or is this problem a good 
  639.       reason to create the interface as a small Application, in this age
  640.       of MultiFinder and AppleEvents?
  641.     
  642.     
  643. Cheers and thanks,
  644.  
  645.  
  646. Francis K.
  647.  
  648. At a Mac Oasis Somewhere in Suburban Hertfordshire
  649.  
  650. +++++++++++++++++++++++++++
  651.  
  652. >From jwbaxter@olympus.net (John W. Baxter)
  653. Date: Fri, 25 Feb 1994 15:04:07 -0800
  654. Organization: Internet for the Olympic Peninsula
  655.  
  656. In article <francis-250294193316@pinza.demon.co.uk>,
  657. francis@pinza.demon.co.uk (Francis H. Knight) wrote:
  658.  
  659. > I'm finding it very laborious, and not very creative, to work out where to
  660. > bracket (de-)references to the struct with HLock/HUnlock, given that a heap
  661. > compaction trigger may be hidden within several layers of function calls.
  662. > In
  663. > fact, I'm sure I've missed some, as I'm still experiencing Bus Errors.
  664. > To help my thinking, can anyone offer any good:
  665. >       Methods of deciding where to HLock/HUnlock? I'm using the manual method
  666. >       of combing through my code line by line and checking against the list
  667. >       of memory-moving routines in Inside Mac. I feel my Mac ought to be able 
  668. >       to flag the potential triggers for me!
  669.  
  670. Any function call may move memory (by loading a segment), unless you *KNOW*
  671. that every segment which might be called by the function you call is
  672. already loaded, and that the function you call will never be modified to
  673. change what you once knew.  IMHO:  assume a function call moves memory. 
  674. Someone may "improve" the code next week.  And of course:  "that little
  675. change couldn't hurt anything, we don't need to retest before the
  676. deadline."
  677.  
  678. Even those traps listed as not moving memory may (someday, if not now). 
  679. SysBeep is a classic example;  it didn't...it often does now.
  680.  
  681. Any trap may have been patched.  The patch should behave, with respect to
  682. moving memory, no "worse" than the version in ROM (any ROM, by the way). 
  683. But...both shareware and commercial ware messes this up, too.  IMHO:  treat
  684. any trap as moving memory.
  685.  
  686. >       Criteria for judging at the outset of a project whether the hassle
  687. >       of correct HLock/HUnlocking is going to outweigh the benefits of using 
  688. >       NewHandle over NewPtr?
  689.  
  690. Years of experience combined with lucky guesses.
  691.  
  692. >       Methods for debugging CDEVs under System 7? Or is this problem a good 
  693. >       reason to create the interface as a small Application, in this age
  694. >       of MultiFinder and AppleEvents?
  695.  
  696. There's not much reason for writing Control Panels any more, if you only
  697. support System 7 and later.  If you never write one, you never have to
  698. learn how.
  699.  
  700. -- 
  701. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  702.    jwbaxter@pt.olympus.net
  703.  
  704. +++++++++++++++++++++++++++
  705.  
  706. >From AIKEN <INRA000@MUSICB.MCGILL.CA>
  707. Date: Sat, 26 Feb 1994 01:13:20 GMT
  708. Organization: McGill University
  709.  
  710. In article <jwbaxter-250294150408@ptpm006.olympus.net> jwbaxter@olympus.net (John W. Baxter) writes:
  711. >In article <francis-250294193316@pinza.demon.co.uk>,
  712. >francis@pinza.demon.co.uk (Francis H. Knight) wrote:
  713. >>    Methods for debugging CDEVs under System 7? Or is this problem a good
  714. >>    reason to create the interface as a small Application, in this age
  715. >>    of MultiFinder and AppleEvents?
  716. >
  717. >There's not much reason for writing Control Panels any more, if you only
  718. >support System 7 and later.  If you never write one, you never have to
  719. >learn how.
  720.  
  721.     A quick note on this: I still feel constrained to write a Control
  722. Panel if I have nothing to put in the Menu Bar of a possible replacement
  723. application. Control Panels still have the advantage of being window-
  724. only and opening in the Finder's layer. If Apple seriously wanted to
  725. junk the whole Control Panel interface, I would love to see a new type
  726. of application: 'mbla' -- menu bar-less app. To open with a face but
  727. without a menu bar. Or will this go away when Apple kills off
  728. application layers alltogether? :-)
  729.  
  730.     Mark Aiken
  731.     inra@musicb.mcgill.ca
  732.  
  733.  
  734. +++++++++++++++++++++++++++
  735.  
  736. >From aep@world.std.com (Andrew E Page)
  737. Date: Sat, 26 Feb 1994 15:08:18 GMT
  738. Organization: The World Public Access UNIX, Brookline, MA
  739.  
  740.  
  741.    Way back when, when I was learing to program a mac(do no ask) I
  742. think the best peice of advice I picked up from a technote or a
  743. BBS(can't remember where), was that when handles are concerned:
  744.  
  745.      IT PAYS TO BE PARANOID.  ALWAYS LOCK THEM BEFORE USING THEM.
  746.  
  747.   When you're using your own data structs in handles sometimes it
  748. becomes a royal pain to be always typing:
  749.  
  750.     HLock((Handle)MyHandle) ;
  751.     HUnlock((Handle)MyHandle) ;
  752.  
  753.   So I created the folowing macros in my personal 'types' file:
  754.  
  755.  
  756. #define HLOCK(h) HLock((Handle)h)
  757. #define HLOCKHI(h) HLockHi((Handle)h)
  758. #define HUNLOCK(h) HUnlock((Handle)h)
  759.  
  760.  
  761.   Save's alot of extra typing, improves the readability of the code.
  762. Always check MemError() afterwards though, Admittedly, it can get
  763. cumbersome, but it's better than spending a couple days of debugging
  764. just to find out you passed a function a bogus handle at some point.
  765.  
  766. foo()
  767. {
  768. MyStruct **MyHnd, *MyPtr ;
  769. OSErr err ;
  770.  
  771.     HLOCK(MyHnd) ;
  772.     if( err = MemError() )
  773.         HandleMemError(err) ;
  774.  
  775.     MyPtr = *MyHnd ;
  776.  
  777.     MyPtr->someData = X ;
  778.     /*
  779.     *   other arcane and silly operations.
  780.     */
  781.     
  782.  
  783.     HUNLOCK(MyHnd) ;
  784.  
  785. }
  786.  
  787.    Lately though I've been using the calls HGetState and HSetState
  788. more frequently, to guarantee that I'm not going to unlock something
  789. that had been locked somewhere else before.  (That's an ouch)
  790.  
  791.  
  792. #define HGETSTATE(h) HGetState(h)
  793. #define HSETSTATE(h, c) HSetState(h, c)
  794.  
  795. foo(MyStruct **MyHnd)
  796. {
  797. MyStruct *MyPtr ;
  798. OSErr err ;
  799. char hndState ;
  800.     
  801.     hndState = HGETSTATE(MyHnd) ;
  802.         HLOCK(MyHnd) ;
  803.         if( err = MemError() )
  804.                 HandleMemError(err) ;
  805.  
  806.         MyPtr = *MyHnd ;
  807.  
  808.         MyPtr->someData = X ;
  809.         /*
  810.         *   other arcane and silly operations.
  811.         */
  812.  
  813.  
  814.         HSETSTATE(MyHnd, hndState) ;
  815.  
  816. }
  817.  
  818.  
  819.    By doing this religiously you can save yourself MUCH trouble
  820. throughout a programming project where you're passing back and forth
  821. alot of data in handles.  
  822.  
  823. -- 
  824. Andrew E. Page   (Warrior Poet) |   Decision and Effort The Archer and Arrow
  825. Mac Consultant                  |     The difference between what we are
  826. Macintosh and DSP Technology    |           and what we want to be.
  827.  
  828. ---------------------------
  829.  
  830. >From gurgle@netcom.com (Pete Gontier)
  831. Subject: When to unlock?
  832. Date: Sat, 26 Feb 1994 22:25:50 GMT
  833. Organization: cellular
  834.  
  835. Submitted-by: gurgle@netcom.com
  836. Archive-name: oHandleLocker.cp
  837.  
  838. francis@pinza.demon.co.uk (Francis H. Knight) writes:
  839.  
  840. >I'm finding it very laborious, and not very creative, to work out where
  841. >to bracket (de-)references to the struct with HLock/HUnlock, given
  842. >that a heap compaction trigger may be hidden within several layers
  843. >of function calls.
  844.  
  845. Essential Secret of Macintosh Programming #412
  846. ----------------------------------------------
  847. Never call HUnlock.
  848.  
  849. Instead, do this:
  850.  
  851.    OSErr WhackHandle (Handle foo)
  852.    {
  853.       OSErr oe = noErr;
  854.  
  855.       char hState = HGetState (foo);
  856.       if (!(oe = MemError ( )))
  857.       {
  858.          HLock (foo);
  859.          if (!(oe = MemError ( )))
  860.          {
  861.             // whack the handle
  862.  
  863.             HSetState (foo,hState);
  864.             if (!oe) oe = MemError ( );
  865.          }
  866.       }
  867.       return oe;
  868.    }
  869.  
  870. The above is laborious, but that's what C++ is for:
  871.  
  872.    class oHandleLocker
  873.    {
  874.          char     fState;
  875.          Handle   fHandle;
  876.  
  877.       public :
  878.  
  879.          oHandleLocker (Handle h)
  880.         { fState = HGetState (h); HLock (h); fHandle = h; }
  881.          ~oHandleLocker (void) // not virtual deliberately
  882.                 { HSetState (fHandle, fState); }
  883.    }
  884.  
  885.    void WhackHandle (Handle h)
  886.    {
  887.       oHandleLocker locked (h);
  888.  
  889.       // whack the handle;
  890.       // it will automagically be unlocked at function exit
  891.    }
  892.  
  893. Note that the C++ version omits calls to MemError; that's the price you
  894. pay for a C++ compiler without exceptions. Most people don't bother with
  895. MemError when calling HLock/HGetState/HSetState anyway. I do, but that's
  896. neither here nor there. Just be aware of it.
  897.  
  898. Also, oHandleLocker might benefit (depending on your world-view) from
  899. dealing with 'void *' instead of 'Handle'. I've used Handle here in
  900. order to avoid explaining why 'void *' might be useful.
  901.  
  902. (By the way, none of the enclosed code has been compiled, but it should
  903. only require minimal changes, and the principles are sound; I have used
  904. them before.)
  905. -- 
  906.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  907.  
  908. ---------------------------
  909.  
  910. End of C.S.M.P. Digest
  911. **********************
  912.  
  913.  
  914.