home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / hypercar / 4666 < prev    next >
Encoding:
Internet Message Format  |  1992-12-27  |  3.3 KB

  1. Path: sparky!uunet!utcsri!torn!spool.mu.edu!uwm.edu!wupost!udel!intercon!psinntp!fourd!Michael_D._Murie
  2. Message-ID: <1992Dec27.133329.92473@fourd.com>
  3. Newsgroups: comp.sys.mac.hypercard
  4. Distribution: world
  5. From: Michael_D._Murie@fourd.com
  6. Organization: 4th Dimension BBS
  7. Date: Sun, 27 Dec 1992 13:33:29 EST
  8. Subject: Re: Need equivalents to common data structures
  9. Lines: 57
  10.  
  11. <I am having a hard time getting used to hypertalk.  I think it is
  12. very intuitive and easy to use, but I wish it had arrays, records,
  13. you know, good things like that.  What I need is to be able to create
  14. a queue that will hold a list of people who are waiting for a
  15. computer (this is for a computer lab.)>
  16.  
  17. I use words and lines to do the kind of thing you want to do. i.e.
  18.     put line 1 of card field students_in_queue into line 5 of
  19. available_machines
  20.  
  21. To remove the first line (now that you've put it somewhere else) you can
  22. either delete line 1 or put line 2 to X of card field students_in_queue into
  23. card field students_in_queue (where X is the number of lines in the field.)
  24.  
  25. HyperTalk tells you how many lines in a field, so you can create a repeat loop
  26. to search through the field. Also, if you just want to put something at the
  27. end of the "queue" you can use an instruction like:
  28.       put return & card field new_student after card field students_in_queue
  29.  
  30. Note: you need the return so that it goes into a new line after the last line in the field (otherwise, the
  31. name just gets added to the last line!)
  32. Words can be a problem if what you are storing consists of multiple words
  33. (i.e. put "Fred Smith" into word 1 of line 3 of card field students; when you
  34. go to see what is in word 1 of line 3 you'll find "Fred")
  35. Therefore, to add the "third dimension" to an array, the best thing is to use
  36. multiple cards (or fields in a card if you know you only need a finite number
  37. of things.)
  38.  
  39. If you need to store multiple things about the student (i.e. time arrived,
  40. time allowed, Student ID) then you have to watch your word counts so that you
  41. can access things. For example, say you want to store time in and persons
  42. name, then you know that the time will always be one word (i.e. 00:12:23) but
  43. the name might be one, two, three or more words. Therefore, put the time as
  44. the first word, and the name as the rest.
  45.  
  46.             00:12:23 Chuck X. Williams
  47.  
  48. You can access the time simply:
  49.     put word 1 of line 1 of card field....
  50.  
  51. to access the rest:
  52.     put the number of words in line 1 of card field Students_in_queue into x
  53.     put word 2 to x of card field students_in_queue into student_name
  54.  
  55. It becomes a real pain if you more than one filed of multiple word lengths. At
  56. that point you would be best using multiple fields (one field has the name,
  57. one field has a comment etc.) If you allow free text input, it's vital that
  58. you don't allow a return to be put into the text-if you do it will create a
  59. new "line" so you should always check the input for a return (OR, just use
  60. "put line 1 of card field user_input into...  that way the return is ignored -
  61. but so is any input after the return!)
  62.  
  63. ********************************************************************
  64. System: fourd.com                                Phone: 617-494-0565
  65. Cute quote:  Being a computer means never having to say you're sorry
  66. ********************************************************************
  67.  
  68.