home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / c / 11727 < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.4 KB  |  43 lines

  1. Newsgroups: comp.lang.c
  2. From: jes@grendel.demon.co.uk (Jim Segrave)
  3. Path: sparky!uunet!pipex!demon!grendel.demon.co.uk!jes
  4. Subject: Re: converting C 'for' to PASCAL 'FOR'
  5. Distribution: world
  6. References: <1992Jul28.151937.247@falcon.navsses.navy.mil>
  7. Organization: None
  8. Lines: 30
  9. Date: Wed, 29 Jul 1992 13:28:59 +0000
  10. Message-ID: <712441739snx@grendel.demon.co.uk>
  11. Sender: usenet@gate.demon.co.uk
  12.  
  13.  
  14. In article <1992Jul28.151937.247@falcon.navsses.navy.mil> huynh@falcon.navsses.navy.mil writes:
  15.  
  16. > Hello,
  17. > I am curious if there is a way to translate the "C" for(i,start,last,incr)
  18. > statement into the PASCAL FOR i = start to last DO (* incr = 1 *).
  19. > I am interested in doing this using the #define statement.
  20. > Has anyone done this? Help is much appreciated.
  21. > Here is an example of how the "C" 'for' statement is translate into FORTRAN
  22. > 'DO':
  23. > #define DO(i,start,last,incr) for((i)=(start);(i)<=(last);(i)+=(incr))
  24. I think the Pascal FOR doesn't do the assignment if the condition is not met:
  25. so
  26.     i := 2;
  27.     FOR i := 3 TO 0 ...
  28. would never assign 3 to i, since the loop wouldn't execute.
  29. I could be wrong, it's been years since I read the User Manual and
  30. Report (which may not be ANSI/ISO anyway).
  31. > Thanks in advance.
  32. > Nhan H. Huynh, PASCAL 's structure 's best
  33. > Science and Engineering Aprrentice, Naval Base, Philadelphia PA.
  34. --
  35. Jim Segrave (Segrave Software Services)     jes@grendel.demon.co.uk
  36.  
  37.