home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / xcmd / prctclxf.sit / DemoStack / stack_-1.xml < prev    next >
Extensible Markup Language  |  1990-08-28  |  8KB  |  16 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>14</cardCount>
  7.     <cardID>3017</cardID>
  8.     <listID>8397</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>on openStackglobal userNameif (not validVersion()) then go stack "Home"set userlevel to 5put (userName contains "Ari Halberstadt") into meset visible of bkgnd btn "Debugging" to meget debugging((me) and (hilite of bkgnd btn "Debugging"))set textArrows to trueget initRadio()hide menubarget lockMenuBar(false)pass openStackend openStack-- check version of HyperCardfunction validVersionif (the version < 1.2) thenanswer "This stack requires HyperCard version 1.2." with "Go Home"return falseend ifreturn trueend validVersionon closeStackif (the version < 1.2) then pass closeStackif (debugging() = true) then pass closeStackget endRadio()pass closeStackend closeStackon openCardif (debugging() = true) thenset the lockText of field "Description" to falsepass openCardend ifset the lockText of field "Description" to trueset the scroll of field "Description" to 0-- display the card's headerupdateHeaderpass openCardend openCard-- Update the header displayed on most (or all) cardson updateHeaderput "DemoStack 0.9" into field "HeaderLeft"put the short name of this card into field "HeaderRight"put "Card #" & the number of this card into field "HeaderNumber"end updateHeader------------------------------------------------------------------------ menu handlers----------------------------------------------------------------------on doMenu menuItemif (menuItem = "Help") then GoHelpelse pass doMenuend doMenu------------------------------------------------------------------------ misc. stuff------------------------------------------------------------------------ return true if debugging, else falsefunction debugging valueglobal _gDebuggingif (value Γëá empty) then put value into _gDebuggingreturn _gDebuggingend debugging-- lock state of menu barfunction lockMenuBar valueglobal _gLockMenuBarif (value Γëá empty) then put value into _gLockMenuBarreturn _gLockMenuBarend lockMenuBar------------------------------------------------------------------------ Handlers for moving around in the stack----------------------------------------------------------------------on GoPreviousvisual wipe right fastgo previousend GoPreviouson GoNextvisual wipe left fastgo nextend GoNexton GoFirstvisual scroll right fastgo card 1end GoFirston GoLastvisual scroll left fastgo card the number of cards in this stackend GoLaston GoBackvisual iris closego backend GoBackon GoHelpvisual zoom openanswer "Sorry, no help yet."exit GoHelpgo card "Help"end GoHelpon GoIndexvisual zoom opengo card "Index"end GoIndexon GoHomevisual zoom closego to this cardgo homeend GoHomeon GoThinkCanswer "Really launch THINK C?" with "No" or "Yes"if (it = "Yes") thenvisual zoom opengo to this cardopen "THINK C 1:THINK C"end ifend GoThinkC--------------------------------------------------------------------- Return the line number of the field "What" based on the point-- "Where". A typical way to call this function from a field is:--     get clickLine(the target, the clickLoc)-- This function will work both for scrolling and non-scrolling-- fields.-------------------------------------------------------------------function clickLine what, where-- get the line number user clicked onput the textHeight of what into txtHtput item 2 of where into locput item 2 of the rect of what into topput loc-top into offsetif (the style of what = "scrolling") thenreturn( trunc( (offset + scroll of what) / txtHt ) + 1 )elsereturn( trunc( offset / txtHt ) + 1 )end ifend clickLine--------------------------------------------------------------------- Put the named file into the named background field-------------------------------------------------------------------on putFileIntoField fileName, fieldNameopen file fileNameif (the result <> empty) thenanswer "Can't open file '" & fileName "'." with "OK"exit putFileIntoFieldend ifread from file fileName for 16384put it into field fieldNameclose file fileNameend putFileIntoField--------------------------------------------------------------------- Put the named background field into the named file-------------------------------------------------------------------on putFieldIntoFile fieldName, fileNameopen file fileNameif (the result <> empty) thenanswer "Can't open file '" & fileName "'." with "OK"exit putFieldIntoFileend ifwrite field fieldName to file fileNameclose file fileNameend putFieldIntoFile------------------------------------------------------------------------- Sort data using an array list. Returns the sorted data, or-- empty if error.-- Parameters:--   data      The data to sort--   compare   Rules for comparing items--   separator Character separating data items--   presorted If true, advises sort function that data are already--             nearly sorted.--   method    Either empty, "Sort", "QuickSort", or "ShellSort"-----------------------------------------------------------------------function listSort data, compare, separator, presorted, methodset cursor to watch-- use default method if none specifiedif (method = empty) then put "Sort" into method-- get a unique name for temporary listput uniqList("listSort") into list-- create listget alist(new, list)if (it = empty) then-- set sorting rulesget alist(setattribute, list, "compare", compare)if (it = empty) then-- insert dataget alist(add, list, data, separator)if (presorted = true) thenget alist(setattribute, list, sorted, true)end ifif (it = empty) then-- sort list and get resultsget alist(method, list)if (it = empty) thenput alist(get, list, separator) into dataget alist(error)end ifend ifend ifend if-- dispose of temporary listput alist(dispose, list) into junk-- report any errors and returnif (it Γëá empty) thenanswer "listSort: " & errorstring(it)exit listSortend ifreturn dataend listSort-- return a name for a unique listfunction uniqList templateglobal _uniqListCntif (_uniqListCnt = empty) then put 0 into _uniqListCntelse add 1 to _uniqListCntreturn template & _uniqListCntend uniqList------------------------------------------------------------------------- Sort data using a binary tree. Returns the sorted data, or-- empty if error.-- Parameters:--   data      The data to sort--   compare   Rules for comparing items--   separator Character separating data items--   presorted If true, advises sort function that data are already--             nearly sorted.-----------------------------------------------------------------------function treeSort data, compare, separator, presortedset cursor to watch-- get a unique name for temporary treeput uniqTree("treeSort") into tree-- create treeif (presorted = true) thenget btree(new, tree, compare, splay) -- splay trees are coming soonelseget btree(new, tree, compare)end ifif (it = empty) then-- insert data into treeget btree(insert, tree, data, empty, separator)-- traverse treeif (it = empty) thenput btree(inorder, tree, false, separator) into dataget alist(error)end ifend if-- dispose of temporary treeput btree(dispose, tree) into junk-- report any errors and returnif (it <> empty) thenanswer "treeSort: " & errorstring(it)exit treeSortend ifreturn dataend treeSort-- return a name for a unique treefunction uniqTree templateglobal _uniqTreeCntif (_uniqTreeCnt = empty) then put 0 into _uniqTreeCntelse add 1 to _uniqTreeCntreturn template & _uniqTreeCntend uniqTree--------------------------------------------------------------------- Radio button handling using ArrayList.-- An auxillary list "_allRadioGroups" contains a list of all-- radio buttons