Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!scdpyr!hpoppe From: hpoppe@scdpyr.UUCP (Herb Poppe) Newsgroups: comp.sys.mac Subject: Re: HyperCard arrays Message-ID: <192@scdpyr.UUCP> Date: Mon, 26-Oct-87 14:33:56 EST Article-I.D.: scdpyr.192 Posted: Mon Oct 26 14:33:56 1987 Date-Received: Thu, 29-Oct-87 23:06:41 EST References: <173@stech.UUCP> <191@scdpyr.UUCP> Organization: Natl Ctr Atmospheric Research, Boulder, CO Lines: 47 Summary: HyperCard variables work like fields In article <191@scdpyr.UUCP>, faulkner@scdpyr.UUCP (Bill Faulkner) writes: > In article <173@stech.UUCP>, sysop@stech.UUCP (Jan Harrington) writes: > > > HyperTalk doesn't directly support arrays. Is there some way to get the > > same effect (by using variables names like VName & k, where k contains > > a number that changes?)? Has anyone come across this yet and found a > > good solution? > > One thing that would work, but isn't really elegant is to create an > invisable field and use the various lines as elements of the array. > The refernce to this would be similar to: > > add 23 to line k of field "Array" > > You could even extend this to two dimensions by using the word of a line, > such as > > put 5 into word i of line j of field "2-D Array" > > Does anybody know of a better solution? Yes, you can use variables in a manner similar to fields to simulate arrays. For example, you can say "line 1 of data", where "data" is the name of a local or global variable. For example: put 1 into line 1 of data put 2 into line 2 of data put 4 into line 3 of data put (line 1 of data) + (line 2 of data) + (line 3 of data) into message Of course, you can use variables instead of literals: put 3 into n put line n of data into message Instead of 'lines' you can use 'items': put "ABC" into item 2 of data For multiply-dimensioned arrays you can do: put "ABC" into item 2 of line 3 of data -- Herb Poppe NCAR INTERNET: hpoppe@scdpyr.UCAR.EDU (303) 497-1296 P.O. Box 3000 CSNET: hpoppe@ncar.CSNET Boulder, CO 80307 UUCP: hpoppe@scdpyr.UUCP