home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / hypercar / 4617 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.3 KB  |  49 lines

  1. Newsgroups: comp.sys.mac.hypercard
  2. Path: sparky!uunet!uunet.ca!xgml!emp
  3. From: emp@xgml.com (Eric Promislow)
  4. Subject: Re: Initializing HC variables
  5. Message-ID: <1992Dec20.012151.1166@xgml.com>
  6. Organization: Exoterica Corporation
  7. References: <7183@ucsbcsl.ucsb.edu>
  8. Date: Sun, 20 Dec 1992 01:21:51 GMT
  9. Lines: 38
  10.  
  11. In article <7183@ucsbcsl.ucsb.edu> sekey@engrhub.ucsb.edu (Andrew Sekey) writes:
  12. >
  13. >    Suppose we have an array of variables x1, x2, x3, etc, and we want to
  14. >initialize them to zero, i.e. to set:
  15. >
  16. >    x1 = 0;  x2 = 0, ........xN = 0.
  17. >
  18. >    Can this be done in a "repeat" structure?
  19. >
  20. >(What would be obvious in e.g. Fortran, does not work:
  21. >
  22. >    repeat with j = 0 to N
  23. >        put 0 into x & j
  24. >        end repeat
  25. >
  26. >since even including a line  'put x & j into dummy', when followed by 
  27. >'put 0 into dummy', will only change 'dummy', not xj.)
  28. >
  29. >Any offers?
  30. >
  31. >Andrew
  32. >
  33.  
  34. repeat with j = 1 to N
  35.   do "put 0 into x" & j
  36. end repeat
  37.  
  38.   It wasn't "obvious" because Fortran can't interpret itself.
  39.  
  40. The real question is why you aren't just treating x as an array with N
  41. items (you don't code like this in Fortran, I hope)?  Then you could
  42. just use the repeat loop:
  43.  
  44. repeat with j = 1 to N
  45.   put 0 into item j of x
  46. end repeat
  47. -- 
  48. -- Eric Promislow--emp@xgml.com--Exoterica Corporation, Ottawa, Ontario
  49.