boz@eleazar.dartmouth.edu (John Boswell) (08/18/88)
Hi there. I have a slight problem that I hope someone can help me with. I have created a stack which I use to keep track of the *many* references I have filed away in my file cabinet and elsewhere (I'm a chemistry grad student). Each reference has its own card, and is also assigned a unique number which I write in the corner of the reference. I then simply file the paper sequencially. The system works well, and I like it, however there *must* be an easier way to assign that unique reference number. Currently, I use a global variable (maxFileNumber) to hold the highest used number. When I create a new card, I automatically increment the current maxFileNumber by one, and put that new number both into the "Reference Number" field and back into maxFileNumber. The problem is that all info on maxFile- Number is lost when I close the stack/ Quit Hypercard. To get around this, the stack always opens and closes by going to a "Title" card first. When the stack opens, it gets maxFileNumber from a field on this card...When the stack closes, it puts maxFilenumber into that field before closing. This *works*, but I'd like to know if there is an easier/ more elegant way of doing this... Thanks for any help.... John Boswell boz@eleazar.dartmouth.edu
dan@Apple.COM (Dan Allen) (08/20/88)
In article <9843@dartvax.Dartmouth.EDU> boz@eleazar.dartmouth.edu (John Boswell) writes: >Hi there. > I have a slight problem that I hope someone can help me with. I have >created a stack which I use to keep track of the *many* references I have filed >away in my file cabinet and elsewhere (I'm a chemistry grad student). Each >reference has its own card, and is also assigned a unique number which I write >in the corner of the reference. I then simply file the paper sequencially. The >system works well, and I like it, however there *must* be an easier way to >assign that unique reference number. > Currently, I use a global variable (maxFileNumber) to hold the highest >used number. When I create a new card, I automatically increment the current >maxFileNumber by one, and put that new number both into the "Reference Number" >field and back into maxFileNumber. The problem is that all info on maxFile- >Number is lost when I close the stack/ Quit Hypercard. To get around this, >the stack always opens and closes by going to a "Title" card first. When the >stack opens, it gets maxFileNumber from a field on this card...When the stack >closes, it puts maxFilenumber into that field before closing. Just use the number of the card in the stack. You could have a background button for creating a new reference (card) that would have a script something like this: on mouseUp go last card doMenu "New Card" put the number of this card into field "reference number" end mouseUp You could also take over the New Card command for ease of use as well as getting a command key by: on doMenu what if what is "New Card" then go last card else pass doMenu end doMenu on newCard put the number of this card into field "reference number" end mouseUp Note that even if you have a title card or sort the stack, going to the end of the stack and creating a card there will always guarantee that reference numbers will be "strictly monotonically increasing". However, if you DELETE any cards, then some reference numbers could be reused, which is probably not a good thing, depending upon your situation. In that case you would also want to prevent deletions by a handler like this in your background or stack script: on doMenu what if what is "Cut Card" or what is "Delete Card" then answer "Sorry, do deleto of cards" with "OK" exit doMenu else pass doMenu end doMenu Of course, this script would ideally be dove-tailed into the other doMenu script. Happy scripting! Dan Allen Apple Computer