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