home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.hypercard
- Path: sparky!uunet!uunet.ca!xgml!emp
- From: emp@xgml.com (Eric Promislow)
- Subject: Re: Initializing HC variables
- Message-ID: <1992Dec20.012151.1166@xgml.com>
- Organization: Exoterica Corporation
- References: <7183@ucsbcsl.ucsb.edu>
- Date: Sun, 20 Dec 1992 01:21:51 GMT
- Lines: 38
-
- In article <7183@ucsbcsl.ucsb.edu> sekey@engrhub.ucsb.edu (Andrew Sekey) writes:
- >
- > Suppose we have an array of variables x1, x2, x3, etc, and we want to
- >initialize them to zero, i.e. to set:
- >
- > x1 = 0; x2 = 0, ........xN = 0.
- >
- > Can this be done in a "repeat" structure?
- >
- >(What would be obvious in e.g. Fortran, does not work:
- >
- > repeat with j = 0 to N
- > put 0 into x & j
- > end repeat
- >
- >since even including a line 'put x & j into dummy', when followed by
- >'put 0 into dummy', will only change 'dummy', not xj.)
- >
- >Any offers?
- >
- >Andrew
- >
-
- repeat with j = 1 to N
- do "put 0 into x" & j
- end repeat
-
- It wasn't "obvious" because Fortran can't interpret itself.
-
- The real question is why you aren't just treating x as an array with N
- items (you don't code like this in Fortran, I hope)? Then you could
- just use the repeat loop:
-
- repeat with j = 1 to N
- put 0 into item j of x
- end repeat
- --
- -- Eric Promislow--emp@xgml.com--Exoterica Corporation, Ottawa, Ontario
-