home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / hypercar / xfcn / methods.sit / Numerical Methods / stack_-1.xml < prev   
Encoding:
Extensible Markup Language  |  1991-04-18  |  8.0 KB  |  17 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in</name>
  5.     <id>-1</id>
  6.     <cardCount>40</cardCount>
  7.     <cardID>5954</cardID>
  8.     <listID>18912</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><false /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>512</width>
  14.         <height>342</height>
  15.     </cardSize>
  16.     <script>ΓÇöΓÇöΓÇöΓÇö Numerical Methods Version 1.1.1
  17. ΓÇöΓÇöΓÇöΓÇö ┬⌐1988-91 Brian P. Arnold
  18. ΓÇöΓÇöΓÇöΓÇö
  19. ΓÇöΓÇöΓÇöΓÇö All rights Reserved.  This stack contains a ShareWare notice.
  20. ΓÇöΓÇöΓÇöΓÇö
  21. ΓÇöΓÇöΓÇöΓÇö HyperTalk functions for numerical methods are in card scripts.
  22. ΓÇöΓÇöΓÇöΓÇö Method XFCNs: contact author for XFCN source info.
  23. ΓÇöΓÇöΓÇöΓÇö
  24. ΓÇöΓÇöΓÇöΓÇö I'm no longer impressed with this stack.  It needs a rewrite.
  25. ΓÇöΓÇöΓÇöΓÇö
  26. ΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇö
  27.  
  28. on openStack
  29. global gLastResult -- define for XCMDs
  30. setPreferences
  31. pass openStack
  32. end openStack
  33.  
  34. on closeStack
  35. put card field "ScrapSaved" of card "Scrapbook" into scrapSaved
  36. if scrapSaved is not "yes" then
  37. answer "Stack Scrapbook contains Results.  Save?" with┬¼
  38. "Cancel" or "Discard" or "Save"
  39. if it is "OK" then
  40. saveScrapbook
  41. else if it is "Cancel" then exit to HyperCard
  42. end if
  43. pass closeStack
  44. end closeStack
  45.  
  46. ΓÇöΓÇöΓÇöΓÇö set global preferences from "Preferences" card ΓÇöΓÇöΓÇöΓÇö
  47. on setPreferences
  48. global gFormat, gHT, gSeconds, gIterations
  49.  
  50. put card field "numFormat" of card "Preferences" into gFormat
  51. put the hilite of card btn "HyperTalk" of card "Preferences" into gHT
  52. put the hilite of card btn "Seconds" of card "Preferences" into foo
  53. if foo is true then
  54. put card field "Seconds" of card "Preferences" into gSeconds
  55. else put 0 into gSeconds
  56. put the hilite of card btn "Iterations" of card "Preferences" into foo
  57. if foo is true then
  58. put card field "Iterations" of card "Preferences" into gIterations
  59. else put 0 into gIterations
  60. end setPreferences
  61.  
  62. ΓÇöΓÇöΓÇöΓÇö iterative fcns and XFCNs call for time-outs ΓÇöΓÇöΓÇöΓÇö
  63. on waitMouse iterations
  64. global howLong,howMuch,gSeconds,gIterations
  65. if ((gSeconds is 0) and (gIterations is 0)) then exit waitMouse
  66.  
  67. if (((the seconds-howLong)>=gSeconds)and(gSeconds>0)) then
  68. tell gSeconds & " more seconds"
  69. put the seconds into howLong
  70. end if
  71. if (((iterations-howMuch)>=gIterations)and(gIterations>0)) then
  72. tell gIterations & " more iterations"
  73. put iterations into howMuch
  74. end if
  75.  
  76. if the version ΓëÑ 1.2 then set cursor to busy
  77. else set cursor to 4
  78.  
  79. if the optionKey is down then
  80. repeat until the mouse is down
  81. end repeat
  82. end if
  83. end waitMouse
  84.  
  85. ΓÇöΓÇöΓÇöΓÇö utility
  86. on tell thing
  87. beep
  88. answer "We've been computing for "&thing&".  Continue?" with ┬¼
  89. "Stop" or "Continue"
  90. if it is "Stop" then
  91. done
  92. exit to HyperCard
  93. end if
  94. end tell
  95.  
  96. ΓÇöΓÇöΓÇöΓÇö functions and XFCNs call when done ΓÇöΓÇöΓÇöΓÇö
  97. on done lastResult
  98. global gLastResult
  99. play "Harpsichord" tempo 380 g4 c5
  100. setPreferences -- resets any overridden changes in "method" below
  101. if lastResult is not empty then put lastResult into gLastResult
  102. end done
  103.  
  104. ΓÇöΓÇöΓÇöΓÇö Prepare to call methods external ΓÇöΓÇöΓÇöΓÇö
  105. on method theMethod, aStopSeconds, aStopIterations, aUseHT, numFormat
  106. global gSeconds,gIterations,gHT,gFormat
  107. InitSolve
  108. if aStopSeconds is not empty then put aStopSeconds into gSeconds
  109. if aStopIterations is not empty
  110. then put aStopIterations into gIterations
  111. if numFormat is not empty
  112. then set numberFormat to numFormat
  113.  
  114. set cursor to 4
  115. put (aUseHT contains "HT") into gHT
  116. go first cd of bkgnd "Method Scripts"
  117. find theMethod in bkgnd field "Methods"
  118. return the result -- in case you want error checking
  119. end method
  120.  
  121. ΓÇöΓÇöΓÇöΓÇö used by 'solve' buttons, 'method' handler
  122. on InitSolve
  123. global gFormat,howLong,howMuch
  124. set numberFormat to gFormat
  125. put the seconds into howLong
  126. put 0 into howMuch
  127. end InitSolve
  128.  
  129. ΓÇöΓÇöΓÇöΓÇö Stack Scrapbook
  130. on addScrapbook thing
  131. put card field "Scrapbook" of card "Scrapbook" into scrap
  132. if scrap is not empty
  133. then put return & "--" & return & thing after scrap
  134. else put thing into scrap
  135. put scrap into card field "Scrapbook" of card "Scrapbook"
  136. put "no" into card field "ScrapSaved" of card "Scrapbook"
  137. end addScrapbook
  138.  
  139. on saveScrapbook
  140. put NewFileName("Save Scrapbook into File:","Untitled") into myFile
  141. if myFile is not empty then
  142. open file myFile
  143. write card field "Scrapbook" of card "Scrapbook" to file myFile
  144. close file myFile
  145. put "yes" into card field "ScrapSaved" of card "Scrapbook"
  146. end if
  147. end saveScrapbook
  148.  
  149. on showMethods
  150. put "About Numerical MethodsΓǪ;(-;"& ┬¼
  151. "Solution of ODE's,RungeKutta,Euler,ModEuler,exportData;" & ┬¼
  152. "Root Solving,Bisection,Newton,Secant;" & ┬¼
  153. "Systems of Equations,GaussJordan,GaussSeidel;" & ┬¼
  154. "Fitting Data,LeastSquares;Interpolation,Lagrange,NewtonPoly;" & ┬¼
  155. "Numerical Integration,GaussLegendre,Romberg,Simpson,Trapezoidal;" & ┬¼
  156. "Matrices,MAdd,SMultiply,MMultiply,Transpose,Decompose,RInvert," & ┬¼
  157. "GInvert,exportMatrix;(-;PreferencesΓǪ;Stack ScrapbookΓǪ" into foo
  158. put the rect of card window into cardRect
  159. put HPopupMenu(foo,0,22,22) into myResult
  160. if myResult is not empty then
  161. if item 3 of myResult is 1 then
  162. pushCard "About"
  163. else if item 3 of myResult is 11 then
  164. pushCard "Preferences"
  165. else if item 3 of myResult is 12 then
  166. pushCard "Scrapbook"
  167. else
  168. if item 2 of myResult is not empty then
  169. visual barn door open
  170. find (item 2 of myResult) in bkgnd field "Methods"
  171. if ((the version ΓëÑ 1.2) and (item 3 of myResult Γëá 9)) then
  172. send mouseUp to card btn (item 4 of myResult)
  173. end if
  174. end if
  175. end if
  176. end if
  177. end showMethods
  178.  
  179. ΓÇöΓÇöΓÇöΓÇö commonly used
  180. on abort prompt
  181. beep
  182. answer prompt
  183. exit to HyperCard
  184. end abort
  185.  
  186. ΓÇöΓÇöΓÇöΓÇö check if matrix is square
  187. on isSquare c
  188. put the number of words in line 1 of c into n
  189. put the number of lines in c into cols
  190. if n = cols then repeat with count = 1 to cols
  191. if the number of words in line count in c is not n
  192. then abort "Matrix is not filled in completely."
  193. end repeat
  194. else abort "Matrix is not square."
  195. end isSquare
  196.  
  197. ΓÇöΓÇöΓÇöΓÇö check if rows of vector r equals size of matrix
  198. on isRows c,r,prompt1,prompt2
  199. put the number of lines in c into n
  200. put the number of lines in r into m
  201. if m Γëá n
  202. then abort prompt1 & " size Γëá " & prompt2
  203. end isRows
  204.  
  205. ΓÇöΓÇöΓÇöΓÇö utility function extracting file names
  206. function afterColons myString
  207. repeat until offset(":",myString) is 0
  208. delete char 1 to offset(":",myString) of myString
  209. end repeat
  210. return myString
  211. end afterColons
  212.  
  213. ΓÇöΓÇöΓÇöΓÇö utility function extracting path names
  214. function beforeColons myString
  215. put myString into oldString
  216. put 0 into myOffset
  217. repeat until offset(":",myString) is 0
  218. add offset(":",myString) to myOffset
  219. delete char 1 to offset(":",myString) of myString
  220. end repeat
  221. return char 1 to myOffset of oldString
  222. end beforeColons
  223.  
  224. on myFind
  225. global lastFind
  226. ask "Find what numerical method:" with lastFind
  227. if it is not empty then
  228. put it into lastFind
  229. set lockScreen to true
  230. go next -- my perogative
  231. find lastFind in bkgnd field 2
  232. if the result is "Not Found" then
  233. go previous
  234. exit myFind
  235. end if
  236. click at 0,0
  237. if the version ΓëÑ 1.2 then unlock screen with zoom open
  238. else set lockScreen to false
  239. end if
  240. end myFind
  241.  
  242. function kwote string
  243. return quote & string & quote
  244. end kwote
  245.  
  246. function clickLine
  247. return ((the mouseV - item 2 of the rect of the target-4)┬¼
  248. div the textheight of the target) + 1
  249. end clickLine
  250.  
  251. ΓÇöΓÇöΓÇöΓÇöΓÇöΓÇóΓÇóΓÇó NAVIGATION ΓÇóΓÇóΓÇóΓÇöΓÇöΓÇöΓÇöΓÇö
  252. on arrowKey which
  253. if which is "right" then nextCard
  254. else if which is "left" then previousCard
  255. else pass arrowKey
  256. end arrowKey
  257.  
  258. on nextCard
  259. visual effect scroll left
  260. go next card
  261. end nextCard
  262.  
  263. on previousCard
  264. visual effect scroll right
  265. go previous card
  266. end previousCard
  267.  
  268. on pushCard theCard
  269. push card
  270. visual zoom open
  271. go card theCard
  272. end pushCard
  273.  
  274. on popCard
  275. pop card into myCard
  276. if myCard contains "Home" then -- shit happens
  277. answer "Return to home stack?" with "OK" or "Cancel"
  278. if it is "Cancel" then exit popCard
  279. end if
  280. visual zoom close
  281. go to myCard
  282. end popCard
  283. </script>
  284.     <background id="2806" file="background_2806.xml" n