home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
- <stack>
- <name>in</name>
- <id>-1</id>
- <cardCount>40</cardCount>
- <cardID>5954</cardID>
- <listID>18912</listID>
- <cantModify><false /></cantModify>
- <cantDelete><false /></cantDelete>
- <cantAbort><false /></cantAbort>
- <cardSize>
- <width>512</width>
- <height>342</height>
- </cardSize>
- <script>ΓÇöΓÇöΓÇöΓÇö Numerical Methods Version 1.1.1
- ———— ©1988-91 Brian P. Arnold
- ΓÇöΓÇöΓÇöΓÇö
- ΓÇöΓÇöΓÇöΓÇö All rights Reserved. This stack contains a ShareWare notice.
- ΓÇöΓÇöΓÇöΓÇö
- ΓÇöΓÇöΓÇöΓÇö HyperTalk functions for numerical methods are in card scripts.
- ΓÇöΓÇöΓÇöΓÇö Method XFCNs: contact author for XFCN source info.
- ΓÇöΓÇöΓÇöΓÇö
- ΓÇöΓÇöΓÇöΓÇö I'm no longer impressed with this stack. It needs a rewrite.
- ΓÇöΓÇöΓÇöΓÇö
- ΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇö
-
- on openStack
- global gLastResult -- define for XCMDs
- setPreferences
- pass openStack
- end openStack
-
- on closeStack
- put card field "ScrapSaved" of card "Scrapbook" into scrapSaved
- if scrapSaved is not "yes" then
- answer "Stack Scrapbook contains Results. Save?" with¬
- "Cancel" or "Discard" or "Save"
- if it is "OK" then
- saveScrapbook
- else if it is "Cancel" then exit to HyperCard
- end if
- pass closeStack
- end closeStack
-
- ΓÇöΓÇöΓÇöΓÇö set global preferences from "Preferences" card ΓÇöΓÇöΓÇöΓÇö
- on setPreferences
- global gFormat, gHT, gSeconds, gIterations
-
- put card field "numFormat" of card "Preferences" into gFormat
- put the hilite of card btn "HyperTalk" of card "Preferences" into gHT
- put the hilite of card btn "Seconds" of card "Preferences" into foo
- if foo is true then
- put card field "Seconds" of card "Preferences" into gSeconds
- else put 0 into gSeconds
- put the hilite of card btn "Iterations" of card "Preferences" into foo
- if foo is true then
- put card field "Iterations" of card "Preferences" into gIterations
- else put 0 into gIterations
- end setPreferences
-
- ΓÇöΓÇöΓÇöΓÇö iterative fcns and XFCNs call for time-outs ΓÇöΓÇöΓÇöΓÇö
- on waitMouse iterations
- global howLong,howMuch,gSeconds,gIterations
- if ((gSeconds is 0) and (gIterations is 0)) then exit waitMouse
-
- if (((the seconds-howLong)>=gSeconds)and(gSeconds>0)) then
- tell gSeconds & " more seconds"
- put the seconds into howLong
- end if
- if (((iterations-howMuch)>=gIterations)and(gIterations>0)) then
- tell gIterations & " more iterations"
- put iterations into howMuch
- end if
-
- if the version ≥ 1.2 then set cursor to busy
- else set cursor to 4
-
- if the optionKey is down then
- repeat until the mouse is down
- end repeat
- end if
- end waitMouse
-
- ΓÇöΓÇöΓÇöΓÇö utility
- on tell thing
- beep
- answer "We've been computing for "&thing&". Continue?" with ¬
- "Stop" or "Continue"
- if it is "Stop" then
- done
- exit to HyperCard
- end if
- end tell
-
- ΓÇöΓÇöΓÇöΓÇö functions and XFCNs call when done ΓÇöΓÇöΓÇöΓÇö
- on done lastResult
- global gLastResult
- play "Harpsichord" tempo 380 g4 c5
- setPreferences -- resets any overridden changes in "method" below
- if lastResult is not empty then put lastResult into gLastResult
- end done
-
- ΓÇöΓÇöΓÇöΓÇö Prepare to call methods external ΓÇöΓÇöΓÇöΓÇö
- on method theMethod, aStopSeconds, aStopIterations, aUseHT, numFormat
- global gSeconds,gIterations,gHT,gFormat
- InitSolve
- if aStopSeconds is not empty then put aStopSeconds into gSeconds
- if aStopIterations is not empty
- then put aStopIterations into gIterations
- if numFormat is not empty
- then set numberFormat to numFormat
-
- set cursor to 4
- put (aUseHT contains "HT") into gHT
- go first cd of bkgnd "Method Scripts"
- find theMethod in bkgnd field "Methods"
- return the result -- in case you want error checking
- end method
-
- ΓÇöΓÇöΓÇöΓÇö used by 'solve' buttons, 'method' handler
- on InitSolve
- global gFormat,howLong,howMuch
- set numberFormat to gFormat
- put the seconds into howLong
- put 0 into howMuch
- end InitSolve
-
- ΓÇöΓÇöΓÇöΓÇö Stack Scrapbook
- on addScrapbook thing
- put card field "Scrapbook" of card "Scrapbook" into scrap
- if scrap is not empty
- then put return & "--" & return & thing after scrap
- else put thing into scrap
- put scrap into card field "Scrapbook" of card "Scrapbook"
- put "no" into card field "ScrapSaved" of card "Scrapbook"
- end addScrapbook
-
- on saveScrapbook
- put NewFileName("Save Scrapbook into File:","Untitled") into myFile
- if myFile is not empty then
- open file myFile
- write card field "Scrapbook" of card "Scrapbook" to file myFile
- close file myFile
- put "yes" into card field "ScrapSaved" of card "Scrapbook"
- end if
- end saveScrapbook
-
- on showMethods
- put "About Numerical Methods…;(-;"& ¬
- "Solution of ODE's,RungeKutta,Euler,ModEuler,exportData;" & ¬
- "Root Solving,Bisection,Newton,Secant;" & ¬
- "Systems of Equations,GaussJordan,GaussSeidel;" & ¬
- "Fitting Data,LeastSquares;Interpolation,Lagrange,NewtonPoly;" & ¬
- "Numerical Integration,GaussLegendre,Romberg,Simpson,Trapezoidal;" & ¬
- "Matrices,MAdd,SMultiply,MMultiply,Transpose,Decompose,RInvert," & ¬
- "GInvert,exportMatrix;(-;Preferences…;Stack Scrapbook…" into foo
- put the rect of card window into cardRect
- put HPopupMenu(foo,0,22,22) into myResult
- if myResult is not empty then
- if item 3 of myResult is 1 then
- pushCard "About"
- else if item 3 of myResult is 11 then
- pushCard "Preferences"
- else if item 3 of myResult is 12 then
- pushCard "Scrapbook"
- else
- if item 2 of myResult is not empty then
- visual barn door open
- find (item 2 of myResult) in bkgnd field "Methods"
- if ((the version ≥ 1.2) and (item 3 of myResult ≠ 9)) then
- send mouseUp to card btn (item 4 of myResult)
- end if
- end if
- end if
- end if
- end showMethods
-
- ΓÇöΓÇöΓÇöΓÇö commonly used
- on abort prompt
- beep
- answer prompt
- exit to HyperCard
- end abort
-
- ΓÇöΓÇöΓÇöΓÇö check if matrix is square
- on isSquare c
- put the number of words in line 1 of c into n
- put the number of lines in c into cols
- if n = cols then repeat with count = 1 to cols
- if the number of words in line count in c is not n
- then abort "Matrix is not filled in completely."
- end repeat
- else abort "Matrix is not square."
- end isSquare
-
- ΓÇöΓÇöΓÇöΓÇö check if rows of vector r equals size of matrix
- on isRows c,r,prompt1,prompt2
- put the number of lines in c into n
- put the number of lines in r into m
- if m Γëá n
- then abort prompt1 & " size Γëá " & prompt2
- end isRows
-
- ΓÇöΓÇöΓÇöΓÇö utility function extracting file names
- function afterColons myString
- repeat until offset(":",myString) is 0
- delete char 1 to offset(":",myString) of myString
- end repeat
- return myString
- end afterColons
-
- ΓÇöΓÇöΓÇöΓÇö utility function extracting path names
- function beforeColons myString
- put myString into oldString
- put 0 into myOffset
- repeat until offset(":",myString) is 0
- add offset(":",myString) to myOffset
- delete char 1 to offset(":",myString) of myString
- end repeat
- return char 1 to myOffset of oldString
- end beforeColons
-
- on myFind
- global lastFind
- ask "Find what numerical method:" with lastFind
- if it is not empty then
- put it into lastFind
- set lockScreen to true
- go next -- my perogative
- find lastFind in bkgnd field 2
- if the result is "Not Found" then
- go previous
- exit myFind
- end if
- click at 0,0
- if the version ≥ 1.2 then unlock screen with zoom open
- else set lockScreen to false
- end if
- end myFind
-
- function kwote string
- return quote & string & quote
- end kwote
-
- function clickLine
- return ((the mouseV - item 2 of the rect of the target-4)¬
- div the textheight of the target) + 1
- end clickLine
-
- ΓÇöΓÇöΓÇöΓÇöΓÇöΓÇóΓÇóΓÇó NAVIGATION ΓÇóΓÇóΓÇóΓÇöΓÇöΓÇöΓÇöΓÇö
- on arrowKey which
- if which is "right" then nextCard
- else if which is "left" then previousCard
- else pass arrowKey
- end arrowKey
-
- on nextCard
- visual effect scroll left
- go next card
- end nextCard
-
- on previousCard
- visual effect scroll right
- go previous card
- end previousCard
-
- on pushCard theCard
- push card
- visual zoom open
- go card theCard
- end pushCard
-
- on popCard
- pop card into myCard
- if myCard contains "Home" then -- shit happens
- answer "Return to home stack?" with "OK" or "Cancel"
- if it is "Cancel" then exit popCard
- end if
- visual zoom close
- go to myCard
- end popCard
- </script>
- <background id="2806" file="background_2806.xml" n