chuq%plaid@Sun.COM (Chuq Von Rospach) (10/21/87)
Since there's been a number of requests for this, here is a Script Report
version of the buttons I use to implement doubly linked lists in Hypercard.
This is somewhat primitive, as you'll see, but it works.
There are two backgrounds. The first background is the primary list, and the
second background is the list of linked cards attached to a single card from
the first background. The first background has two hidden fields:
ListEditions and NumEditions. The former is the pointer to the head of the
linked list for that card, the latter the number of cards ni the linked
list.
The second background has two fields, "Next Title" and "Prev Title".
Insertion and movement around the double linked list should be relatively
simple to understand from the code (if you've ever worked with Double linked
lists. Thank Ghod for Knuth....)
Anyway, I don't know how much polishing I"m going to do to this code, as I"m
redesigning the modality out of the stack (Hypercard is wonderful, since it
is so EASY to prototype I don't mind throwing away stuff). But I expect to
use this stuff later, and I'm sure someone else can use it now, so I thought
I'd post it... Enjoy!
[Editorial side comment: Why design away modality?
o Modality makes the menubar useless, especially clover-{prev,first,next,last}
because HC's concepts of those become useless.
o HC Sorting becomes useless.
o inserting, sorting and (especially) deleting cards becomes a royal pain.
HC WANTS you to write modeless stacks (for good reason, I might
add).
Anyway, what I'm doing is replacing all this double-linked list complexity
with a single field on the stack. The field will be placed with a value that
identifies the card (in my case, an author/title pair as a text string) with
an appended card number: "anthony-vale of the vole-01". From there, you can
sort by the field, and everything will line up. Buttons to move to the
next/prev card in a given background handles staying within a background
type, and you can use another button to go to the first card of the
background type (this form allows infinite backgrounds without requiring
infinite sets of double linked lists!) you want simply by manipulating the
value of that field and going to it. So I'm zapping a lot of complexity and
getting a stack that does the same thing (perhaps more!) while not
overriding Hypercard.
Isn't prototyping wonderful?]
SCRIPTS FOR STACK: Book Index
======================================================
** BACKGROUND #1: Book Background ************************************
on openStack
-- hide message box
-- hide menuBar
pass openStack
end openStack
** BKGND #1, BUTTON #1: Browse Editions ************************************
on mouseUp
if field listEditions is empty then
answer "No list of editions to browse"
exit mouseUp
end if
push card
go to field listEditions
end mouseUp
** BKGND #1, BUTTON #10: New Title ************************************
on mouseUp
set lockscreen to true
put id of this card into oldcard
put background field "next title" into nextLink
domenu "New Card"
put id of this card into newcard
put oldcard into background field "Prev Title"
put nextLink into background field "Next Title"
go to oldcard
put newcard into background field "Next Title"
go to newcard
global bookType
put "Novel" into bookType
set hilight of background button NovelButton to true
set hilight of background button AnthButton to false
set hilight of background button CollButton to false
set hilight of background button NonButton to false
set hilight of background button bwbutton to false
set hilight of background button clgbutton to false
set hilight of background button otherbutton to false
put empty into listEditions
put "0" into numEditions
set visible of background button "Browse Editions" to false
set lockscreen to false
end mouseUp
** BKGND #1, BUTTON #14: New Edition ************************************
on mouseUp
set lockscreen to true
put the id of this card into oldcard
push card
go to background "Edition Background"
doMenu "New card"
put the id of this card into newcard
go to oldcard
set visible of background button "browse editions" to true
if field "listEditions" is empty then
put newcard into field listEditions
put 1 into field numEditions
go to newcard
put empty into field "listPrev"
put empty into field "listNext"
else
add 1 to field "numEditions"
put field numEditions into numEditions
put field listEditions into listOfCards
put newcard into field "listEditions"
go to listOfCards
put newcard into field "listPrev"
go to newcard
put empty into field "listPrev"
put listOfCards into field "listNext"
end if
visual effect dissolve very slowly
set lockscreen to false
end mouseUp
** BKGND #1, BUTTON #15: Prev Title ************************************
on mouseUp
go to previous card of this background
end mouseUp
** BKGND #1, BUTTON #16: Next Title ************************************
on mouseUp
go to next card of this background
end mouseUp
** BACKGROUND #2: Edition Background ************************************
on openCard
if field listPrev is empty then
set visible of background button 2 to false
else
set visible of background button 2 to true
end if
if field listNext is empty then
set visible of background button 3 to false
else
set visible of background button 3 to true
end if
end openCard
** BKGND #2, BUTTON #1: New Button ************************************
on mouseUp
pop card
end mouseUp
** BKGND #2, BUTTON #2: prevButton ************************************
on mouseUp
if field listPrev is empty then
answer "no previous edition in list"
exit mouseUp
end if
go to field listPrev
end mouseUp
** BKGND #2, BUTTON #3: nextButton ************************************
on mouseUp
if field listNext is empty then
answer "no previous edition in list"
exit mouseUp
end if
go to field listNext
end mouseUp
Chuq Von Rospach chuq@sun.COM
Editor, OtherRealms Delphi: CHUQ