home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpmhelp / ratfor.hlp < prev    next >
Text File  |  1994-07-27  |  19KB  |  561 lines

  1. What is RATFOR?
  2. RATFOR statements
  3. IF-ELSE statement
  4. WHILE statement
  5. FOR statement
  6. REPEAT-UNTIL statement
  7. BREAK and NEXT statements
  8. SWITCH construct
  9. Statement Grouping and Null Statments
  10. FREE-FORM input
  11. Comments
  12. Character Translation
  13. STRING Data Type
  14. Quoted Character Strings
  15. DEFINE macro
  16. Other macros
  17. INCLUDE statement
  18. Implementation
  19. Conclusions
  20. Other Reference Literature
  21. :What is RATFOR?
  22.  
  23. RATFO╥  i≤  ß preprocesso≥ fo≥ FORTRAN« It≤ primar∙ purposσ i≤ ì
  24. t∩á encouragσá readablσ anΣ well-structureΣ codσ whilσá takinτ ì
  25. advantagσáá  oµáá thσáá  universality¼ááá  portability¼áá  anΣ  ì
  26. efficienc∙á  oµá FORTRAN«á Thi≤á i≤ donσá b∙á  providinτá  thσ  ì
  27. contro∞  structure≤  no⌠  availablσ  iε  barσ FORTRAN¼á anΣ b∙ ì
  28. improvinτ thσ "cosmeticsó oµ thσ language« 
  29.  
  30. RATFO╥á  allow≤ fo≥ al∞ thσ feature≤ oµ norma∞á FORTRAN¼á plu≤ ì
  31. make≤ availablσ thesσ contro∞ structures║ 
  32.           
  33.      "if"-"else"
  34.      "while", "for", and "repeat"-"until" for looping
  35.      "break" and "next" for controlling loop exits
  36.      "switch" construct for allowing selection of alternatives
  37.       statement grouping with braces
  38.           
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. Thσ cosmetiπ aspect≤ oµ RATFO╥ havσ  beeε  designeΣ  t∩á  makσ  ì
  46. i⌠ concisσ anΣ reasonabl∙ pleasinτ t∩ thσ eye║ 
  47.           
  48.           free form input
  49.           unobtrusive comment convention
  50.           translation of >, <=, etc. into .GT., .LE., etc.
  51.           string data type
  52.           quoted character strings
  53.           "define" statement for symbolic constants
  54.           "include" statement for including source files
  55. è
  56. RATFO╥á  i≤  implementeΣ  a≤  ß  preprocesso≥ whicΦ translate≤ ì
  57. thσ abovσ feature≤ int∩ FORTRAN¼á whicΦ caε theε bσ  feΣ  int∩  ì
  58. almos⌠  an∙ FORTRAN compiler« 
  59.  
  60. :RATFOR statements
  61.  
  62. EacΦá  oµ  thσ RATFO╥ feature≤ wil∞ no≈ bσ discusseΣá iεá morσ ì
  63. detail«á Iεá thσá following¼á ß  "statementó  i≤á  an∙á  lega∞  ì
  64. statemen⌠  iε  FORTRAN║á assignment¼  declaration¼  subroutinσ  ì
  65. call¼á  I/O¼ etc.¼ o≥ an∙ oµ thσ RATFO╥ statement≤ themselves«  ì
  66. An∙á  FORTRAN  o≥  RATFO╥  statemen⌠  o≥ grou≡  oµ  thesσá caε ì
  67. bσá encloseΣá iε brace≤ ({}⌐ o≥ bracket≤ ([]⌐ -- t∩ makσ i⌠á ß ì
  68. compounΣ statement¼á whicΦ i≤ theε  equivalen⌠  t∩  ßá  singlσ ì
  69. statemen⌠ anΣ usablσ anywherσ ß singlσ statemen⌠ caε bσ used« 
  70.  
  71.  
  72. :IF-ELSE statement 
  73.  
  74. RATFO╥áá  provide≤áá  aεá  "elseóá statemen⌠á t∩á handlσáá thσ ì
  75. constructioε "iµ ß conditioε i≤ true¼ d∩ thi≤ thing¼ otherwisσ ì
  76. d∩ tha⌠ thing"«  Thσ synta° i≤ 
  77.           
  78.           if (legal FORTRAN condition)
  79.                statement(s)
  80.           else
  81.                statement(s)
  82.           
  83. wherσá  thσá  elsσ  par⌠  i≤á  optional«á Thσá "lega∞á FORTRAN ì
  84. conditionóá i≤á anythinτá tha⌠ caε legall∙ g∩ int∩á ßá FORTRAN  ì
  85. logica∞á  IF«á  Thσ  RATFO╥ statement≤  ma∙  bσ  onσá o≥á morσ ì
  86. valiΣá RATFO╥ o≥ FORTRAN statement≤ oµ an∙ kind«á Iµ morσ thaε ì
  87. onσ statemen⌠ i≤ desired¼ thσ  statement≤  mus⌠ bσ encloseΣ b∙ ì
  88. braces«
  89.  
  90. See the example on the next screen.
  91.  
  92.  
  93.  
  94.  
  95.   
  96. IF-ELSE example¼ 
  97.  
  98.           if (a > b)
  99.                {
  100.                k = 1
  101.                call remark (...)
  102.                }
  103.           else if (a < b)
  104.                {
  105.                k = 2
  106.                call remark (...)
  107.                }
  108.           else
  109.                returnè          
  110.  
  111. :WHILE statment 
  112.  
  113. Thσá whilσ statemen⌠ i≤  simpl∙ ß loop║á "whilσ somσ conditioε ì
  114. i≤ true¼ repea⌠ thi≤ grou≡ oµ  statements"«  Thσ synta° i≤ 
  115.  
  116.           while (legal FORTRAN condition)
  117.                  statement(s)
  118.           
  119. A≤á  witΦá  thσ  if¼á  "lega∞ FORTRAN conditionó i≤á somethinτ ì
  120. tha⌠á caεá g∩á int∩ ß FORTRAN logica∞á IF«á Thσá conditioεá i≤  ì
  121. testeΣá  beforσ  executioε oµ  an∙  oµ thσ RATFO╥á statements¼ ì
  122. s∩ iµ thσ conditioε i≤ no⌠ met¼ thσ loo≡ wil∞ bσ executeΣ zer∩ ì
  123. times«á Also¼á a≤ witΦ  thσ  IF¼á  thσ  RATFO╥ statement≤  caε  ì
  124. bσ  an∙  valiΣ  RATFO╥ o≥ FORTRAN constructs« Iµ morσ thaε onσ ì
  125. statemen⌠ i≤ desired¼á thσ  statement≤  mus⌠  bσ  encloseΣ  b∙ ì
  126. braces« Fo≥ example¼ 
  127.  
  128.           while (getc(c) != EOF)
  129.                {
  130.                c = cnvt (c)
  131.                call putc (c)
  132.                }
  133. :FOR statment 
  134.  
  135. Thσ  "foró  statemen⌠  i≤  simila≥  t∩ thσ "whileó excep⌠ tha⌠ ì
  136. i⌠á allow≤á explici⌠ initializatioε anΣ incremen⌠á  step≤á  a≤  ì
  137. par⌠  oµ  thσ statement« Thσ synta° i≤ 
  138.  
  139.           for (init; condition; increment)
  140.                statement(s)
  141.           
  142. wherσá  "initó  i≤  an∙  singlσ  FORTRAN statemen⌠ whicΦá get≤ ì
  143. donσ oncσ beforσ thσ loo≡ begins«á "Incrementó i≤ an∙á  singlσ  ì
  144. FORTRANá  statemen⌠ whicΦ  get≤  donσ a⌠ thσ enΣ oµ eacΦá pas≤ ì
  145. througΦá thσá loop¼á beforσá thσ test«á "Conditionóá i≤á agaiε ì
  146. anythinτá tha⌠ i≤ lega∞  iε  ß  logica∞  IF«á An∙á  oµá  init¼  ì
  147. condition¼áá  anΣá incremen⌠á ma∙á bσá omitted¼á althougΦá thσ ì
  148. semicolon≤ mus⌠ remain« ┴ non-existen⌠ conditioε i≤ treateΣ a≤  ì
  149. alway≤ true¼á  s∩ "for¿ ╗á ╗á )ó i≤ aε indefinitσ repeat«á Thσ ì
  150. "foróá statemen⌠á i≤ particularl∙ usefu∞ fo≥á backwarΣá loops¼ ì
  151. chaininτá  alonτá  lists¼á  loop≤ tha⌠  migh⌠  bσá  donσá zer∩ ì
  152. times¼á anΣ simila≥ thing≤ whicΦ arσ harΣ t∩ expres≤ witΦ ß D╧ ì
  153. statement«
  154.  
  155. See the next screen for examples.
  156.  
  157. Herσ arσ tw∩ example≤ oµ "foró loops║ 
  158.  
  159.           for (i=1; getarg(i, file, MAXLINE) != EOF; i=i+1)
  160.                {
  161.                int = open (file, READ)
  162.                while (getlin (line, int) != EOF)
  163.                     {è                    for (j=80; j>0; j=j-1)
  164.                        call putc (line(j))
  165.                     }
  166.                call close (int)
  167.                }
  168.           
  169. Thσá abovσá codσá simpl∙á read≤ card≤ froφ ßá lis⌠á oµá files¼  ì
  170. reverse≤  thσ orde≥  oµ  thσ characters¼á anΣ write≤ thσ card≤ ì
  171. ont∩ ß standarΣ outpu⌠ file« (Thσ "!=ó mean≤ .NE.⌐ 
  172.  
  173.  
  174. :REPEAT-UNTIL statement
  175.  
  176. Thσá "repeat-untiló statement≤ allo≈  fo≥  repetitioεá  oµá  ß  ì
  177. grou≡á  oµ statement≤ unti∞ ß specifieΣ conditioε i≤ met«á Thσ ì
  178. synta° is║ 
  179.           repeat
  180.                statement(s)
  181.           until
  182.                condition
  183.           
  184. Thσ  "untiló  i≤  optional«  Oncσ  again¼  iµ  morσ  thaε  onσ  ì
  185. RATFO╥ statemen⌠ i≤ desired¼á thσ statement≤ mus⌠ bσá encloseΣ ì
  186. b∙ brackets«á  Iµ thσ  "untiló  par⌠  i≤  omitted¼  thσ resul⌠ ì
  187. i≤á aεá infinitσ loo≡ whicΦ mus⌠ bσ brokeε witΦ ßá "breakóá o≥  ì
  188. "nextó  statemen⌠  (seσ  below)«  E.g.: 
  189.  
  190.           repeat
  191.                {
  192.                call putc (BLANK)
  193.                col = col + 1
  194.                }
  195.                until (tabpos(col,tabs) == YES)
  196. :BREAK and NEXT 
  197.  
  198. RATFO╥á  provide≤  statement≤  fo≥  leavinτ  ß  loo≡ earl∙ anΣ ì
  199. fo≥ beginninτ thσ nex⌠ iteration« 
  200.  
  201. "Breakó cause≤  aε  immediatσ  exi⌠  froφ  whateve≥  loo≡á  i⌠  ì
  202. i≤á containeΣá  iεá  (whicΦ  ma∙á  bσá ßá "while"¼á "for"¼á o≥ ì
  203. "repeat")«á Contro∞ resume≤ witΦ thσ nex⌠ statemen⌠ afte≥  thσ  ì
  204. loop«á  Onl∙  onσ  loo≡  i≤ terminateΣ  b∙  ß  "break"¼á  eveε  ì
  205. iµ  thσ "breakó i≤ containeΣ insidσ severa∞ nesteΣ loops«á Fo≥ ì
  206. example║ 
  207.  
  208.           repeat
  209.                {
  210.                if (getc(c) == EOF)  break
  211.                ...
  212.                }
  213.           
  214.  
  215.  
  216.  
  217. è
  218.  
  219.  
  220.  
  221. "Nextóá i≤ ß brancΦ t∩ thσ bottoφ oµ thσ loop¼á s∩  i⌠  cause≤  ì
  222. thσá nex⌠á  iteratioεá  t∩  bσá  done«á  "Nextóá goe≤á t∩á thσ ì
  223. conditioεá par⌠á oµá ß "whileó o≥ "until"¼á t∩ thσ to≡á oµá aε ì
  224. infinitσ "repeató  loop¼á  anΣ  t∩ thσ reinitializσ par⌠ oµá ß ì
  225. "for"« Fo≥ example║ 
  226.  
  227.           for (i=1; i<10; i=i+1)
  228.                {
  229.                if (array(i) == BLANK)  next
  230.                ...
  231.                }
  232.           
  233.  
  234. :SWITCH Construct 
  235.  
  236. Aεá  assortmen⌠á  oµ  alternative≤  ma∙  bσ  specifieΣá  usinτ ì
  237. thσ switcΦ construct« Thσ synta° is║ 
  238.  
  239.      switch (expr):
  240.         {
  241.         case a: statement
  242.         case b: statement
  243.         case c: statement
  244.         ....
  245.         default: statement
  246.         }
  247.  
  248. Thσá "defaultó casσ i≤ optional«á ì
  249.  
  250.      switch (i):
  251.         {
  252.         case 25: do_this_stuff
  253.         case -2: do_this_stuff
  254.         default: otherwise do_this
  255.         }
  256. :Statement Grouping and Null Statements
  257.      
  258. RATFO╥ allow≤ ß grou≡ oµ statement≤ t∩ bσ treateΣ a≤ ß uni⌠ b∙ ì
  259. enclosinτ theφ iε brace≤ -- √ anΣ }«á Thi≤ i≤ truσá throughou⌠ ì
  260. thσ language║á whereve≥ ß singlσ RATFO╥ statemen⌠ caε bσ used¼ ì
  261. therσ coulΣ als∩ bσ severa∞ encloseΣ iε braces.
  262.  
  263. For example:
  264.      
  265.                if (x > 100)
  266.                {
  267.                call error (...)
  268.                err = 1
  269.                return
  270.                }
  271.      èIµá  brace≤á  arσá  no⌠á  valiΣ  character≤á  iεá  thσá  loca∞ ì
  272. operatinτá system¼á thσ character≤ "$(ó anΣ "$)ó ma∙á bσá useΣ ì
  273. insteaΣ  oµ  "{ó anΣ "}ó respectively« 
  274.      
  275.  
  276.      
  277.  
  278. RATFO╥á  als∩  allow≤  fo≥ nul∞ statements¼á mos⌠ usefu∞ afte≥ ì
  279. "foróá anΣ "whileó statements«á ┴ semicoloε alonσ indicate≤á ß  ì
  280. nul∞ statement« Fo≥ instance¼ 
  281.      
  282.                while (getlin(line, int) != EOF) ; 
  283.                
  284. woulΣá  reaΣá  line≤  froφ ß filσ unti∞á thσá end-of-filσá wa≤ ì
  285. reached and 
  286.      
  287.                for (i=1; line(i) == BLANK; i=i+1) ; 
  288.                
  289. position≤ afte≥ leadinτ blank≤ iε ß line« 
  290.  
  291. :FREE-FORM input 
  292.      
  293. Statement≤á ma∙ bσ placeΣ anywherσ oε ß linσ anΣ severa∞á  ma∙ ì
  294. appea≥  oε  onσ  linσ  iµ  the∙  arσ  separateΣ b∙ semicolons« ì
  295. N∩á semicoloε i≤ needeΣ a⌠  thσ  enΣ  oµ  eacΦ  linσá  becausσ  ì
  296. RATFO╥ assume≤  therσ  i≤  onσ statemen⌠ pe≥ linσ unles≤á tolΣ ì
  297. otherwise«á RATFO╥ will¼ however¼ continuσ line≤ wheε i⌠ seem≤  ì
  298. obviou≤  tha⌠ the∙ arσ no⌠ ye⌠ done« 
  299.      
  300. An∙á  statemen⌠  tha⌠  begin≤  witΦ  aε  all-numeriπ fielΣá i≤ ì
  301. assumeΣá t∩á bσ ß FORTRAN labe∞ anΣ i≤ placeΣ iε column≤á  1-╡  ì
  302. upoε output« 
  303.      
  304. Statement≤á  ma∙á  bσá  passeΣá througΦá thσá RATFO╥á compile≥ ì
  305. unaltereΣá b∙á insertinτá ß percen⌠ sigεá (%⌐á a≤á thσá  firs⌠  ì
  306. characte≥á  oε  thσ line«á  Thσ  percen⌠ wil∞ bσ removed¼á thσ ì
  307. res⌠á oµ thσ linσ shifteΣ onσ positioε t∩ thσ left¼á anΣá  thσ  ì
  308. linσáá  sen⌠á  ou⌠á  withou⌠á  an∙á changes«áá  Thi≤á  i≤áá  ß  ì
  309. convenien⌠á  wa∙á t∩á pas≤ regula≥ FORTRANá o≥á assembl∙á codσ ì
  310. througΦ thσ RATFO╥ compiler« 
  311.  
  312.  
  313. :Comments 
  314.      
  315. ┴á shar≡ characte≥ "#ó iε ß linσ mark≤  thσ  beginninτ  oµá  ß ì
  316. commen⌠á  anΣ  thσ  res⌠  oµ  thσ  linσ  i≤  considereΣ t∩á bσ ì
  317. tha⌠á comment«á Comment≤ anΣ codσ caε co-exis⌠ oεá  thσá  samσ  ì
  318. line«  For example, 
  319.      
  320.         function dummy (x)
  321.         # I made up this function to show some comments
  322.         dummy = x         #I am simply returning the parameter
  323.         return
  324.         end
  325.                è
  326. :Character Translation
  327.      
  328. Sometime≤  thσ  character≤ >¼á <=¼á etc« arσ easie≥ t∩ reaΣ iε ì
  329. FORTRANá conditioεá statement≤  thaε  thσá  standarΣá  FORTRAN  ì
  330. .EQ.¼á .LT.¼á  etc.«á  RATFO╥  allow≤  eithe≥  convention«  Iµ ì
  331. thσ specia∞ character≤  arσ  used¼á  the∙  arσ  translateΣ  iε  ì
  332. thσ  followinτ manner║ 
  333.      
  334.                ==          .EQ.
  335.                != ^= ~=    .NE.
  336.                <           .LT.
  337.                >           .GT.
  338.                <=          .LE.
  339.                >=          .GE.
  340.                |           .OR.
  341.                &           .AND.
  342.                
  343. For example: 
  344.                for (i=1; i<= 5; i=i+1)
  345.                ...
  346.                if (j != 100)
  347.                ...
  348. :STRING Data Type 
  349.  
  350. Al∞á   characte≥á   array≤   iε   RATFO╥  arσá  sequence≤á  oµ  ì
  351. ASCI╔á characters¼áá storeΣá right-adjusted¼á onσá pe≥á  arra∙  ì
  352. element¼á  witΦá thσ  strinτ  terminateΣ  witΦ  aε EO╙ marker« ì
  353. Aεá automatiπá wa∙ t∩ initializσ strinτ character≤á array≤á i≤ ì
  354. provided« Thσ synta° is║ 
  355.  
  356.      string name "characters" 
  357.      or 
  358.      string name(n) "characters" 
  359.  
  360. RATFO╥á wil∞á definσ namσ t∩  bσá  ßá  characte≥á  (or¼á  morσ  ì
  361. likely¼á integer⌐á  arra∙ lonτ enougΦ t∩ accomodatσ thσá ASCI╔ ì
  362. code≤á fo≥ thσ giveε characte≥ string¼á onσ pe≥á element«á Thσ ì
  363. las⌠á  worΣ  oµ  namσ i≤  initializeΣ  t∩  EOS«á Iµ ß sizσá i≤ ì
  364. given¼á namσá i≤ declareΣ t∩ bσ aε intege≥ arra∙ oµ sizσá 'n'«  ì
  365. Iµá  severa∞  strinτ  statement≤ appea≥á  consecutively¼á  thσ  ì
  366. generateΣá declaration≤á fo≥ thσ arra∙ wil∞ precedσá thσá datß ì
  367. statement≤ tha⌠ initializσ them« 
  368.  
  369. See the next screen for examples.
  370.  
  371. For example, the declarations: 
  372.  
  373.           string errmsg "error" 
  374.           string done "bye" 
  375.  
  376. would be converted by RATFOR into the FORTRAN: 
  377.  
  378.           integer error(6)
  379.           integer done(4)
  380.           data error(1), error(2), error(3), error(4),è          error(5), error(6) /LETE, LETR, LETR, LETO, LETR, EOS/
  381.           data done(1), done(2), done(3), done(4) /LETD, LETO,
  382.           LETN, LETE, EOS/
  383.  
  384.  
  385. :Quoted Character Strings
  386.  
  387. Tex⌠ encloseΣ iε matchinτ doublσ o≥ singlσ quote≤ i≤ converteΣ ì
  388. t∩ nH..« format¼ bu⌠ i≤ otherwisσ unaltered«  Fo≥ instance,
  389.  
  390.           call remark ("Error detected")
  391. would translate to
  392.           call remark (14hError detected)
  393.           
  394. and
  395.           data string /"Can't find answer"/
  396. would become
  397.           data string /17hCan't find answer/
  398.           
  399. Iµá thσá loca∞ operatinτ systeφ doe≤ no⌠ suppor⌠á botΦá  uppe≥  ì
  400. anΣá  lowe≥ casσ  holleritΦ  strings¼á aε escapσ mechanisφá i≤ ì
  401. generall∙ provideΣ t∩ allo≈ thσ use≥ t∩ indicatσ case« 
  402.  
  403. Somσ operatinτ system≤ arσ no⌠ capablσ oµ findinτ thσ  enΣ  oµ  ì
  404. ßá FORTRANá  holleritΦá  string«á  Iεá  thi≤ casσá i⌠á ma∙á bσ ì
  405. necessar∙á fo≥ thσ use≥ t∩ marδ thσ enΣ oµ he≥á quoteΣá strinτ ì
  406. witΦ ß  specifiπ  character¼ sucΦ a≤ ß period« 
  407. :DEFINE 
  408.  
  409. An∙á  strinτá  oµ alphanumeriπ character≤ caε bσ defineΣ a≤á ß ì
  410. name║á thereafter¼á wheneve≥ tha⌠ namσ  occur≤  iε  thσ  inpu⌠  ì
  411. (delimiteΣ  b∙ non-alphanumerics⌐  i⌠ i≤ replaceΣ b∙ thσá res⌠ ì
  412. oµ thσ definitioε line« Thσ synta° is║ 
  413.  
  414. define(name, replacement string) 
  415.  
  416. whicΦáá  definσá  "nameóá  a≤á  ßá  macr∩á  whicΦá  wil∞áá  bσ   ì
  417. replaceΣá   witΦ "replacemen⌠  stringó  wheε  encountereΣá  iε  ì
  418. thσ  sourcσ  files« A≤ a simple example: 
  419.  
  420.           define(ROW,10)
  421.           define(COLUMN,25)
  422.           
  423.           dimension array (ROW, COLUMN)
  424. and
  425.           
  426.           define(EOF,-1)
  427.           if (getlin(line, fd) == EOF) ....
  428.  
  429.           
  430. Definition≤ ma∙ bσ includeΣ anywherσ iε  thσ  code¼á  a≤  lonτ  ì
  431. a≤á the∙  appea≥  beforσ  thσ  defineΣ namσ occurs«á Thσ name≤ ì
  432. oµ macr∩ ma∙ contaiε letters¼á digits¼á periods¼ anΣ underlinσ ì
  433. characters¼á  bu⌠  mus⌠ star⌠  witΦ  ß letter« Uppe≥ anΣ lowe≥ ì
  434. case≤ AR┼ significan⌠ (thu≤ EO╞ i≤ no⌠ thσ samσ a≤ eof)« è
  435. An∙á occurrence≤ oµ thσ string≤ '$nº iε thσ replacemen⌠á text¼  ì
  436. wherσ  ▒ <╜  ε  <╜  9¼á wil∞ bσ replaceΣ witΦ thσ ntΦ argumen⌠ ì
  437. wheε thσ macr∩ i≤ actuall∙ invoked« Fo≥ example║ 
  438.  
  439.                define(bump, $1 = $1 + 1) 
  440.  
  441. will cause the source line 
  442.  
  443.                bump(i) 
  444.  
  445. to be expanded into 
  446.  
  447.                i = i + 1 
  448.  
  449.  
  450. :Other macros
  451.  
  452. In addition to define, four other built-in macros are provided: 
  453.  
  454. arith(x,op,y) perform≤  thσ  "integeró  arithmetiπá  specifieΣ  ì
  455. ááááááááááááááb∙  o≡ (+,-,*,/⌐  oε  thσ  tw∩  numeriπ operand≤ ì
  456. ááááááááááááááanΣ return≤ thσ resul⌠ a≤ it≤ replacement« 
  457.  
  458. incr(x)áááááááconvert≤ thσ strinτ ° t∩  ß  number¼á  add≤  onσ  ì
  459. áááááááááááááát∩áá  it¼áá  anΣá return≤á  thσá valuσá a≤áá it≤ ì
  460. ááááááááááááááreplacemen⌠ (a≤ ß characte≥ string)« 
  461.  
  462. ifelse(a,b,c,d⌐á compare≤á ß anΣ Γ a≤ characte≥á strings╗á  iµ  ì
  463. ááááááááááááááthe∙  arσ thσ  same¼á π i≤ pusheΣ bacδ ont∩á thσ ì
  464. ááááááááááááááinput¼ elsσ Σ i≤ pusheΣ back« 
  465.  
  466. substr(s,m,n) produce≤á thσá substrinτá oµ ≤ whicΦá start≤á a⌠ ì
  467. áááááááááááááápositioε  φ (witΦ  origiε  one)¼á  oµ lengtΦá n« ì
  468. ááááááááááááááIµá εá i≤ omitteΣ o≥ to∩ big¼á thσ res⌠á oµá thσ ì
  469. áááááááááááááástrinτ i≤ used¼á whilσ  iµ φ i≤ ou⌠ oµ rangσ thσ ì
  470. ááááááááááááááresul⌠ i≤ ß nul∞ string« 
  471. :INCLUDE 
  472.  
  473. File≤á  ma∙á  bσá  inserteΣá  int∩ thσ inpu⌠á streaφá vißá thσ ì
  474. "includeó command« Thσ statemen⌠ 
  475.  
  476.           include filename 
  477. or 
  478.           include "filename" 
  479.  
  480. insert≤á thσá filσá founΣ oε inpu⌠ filσá "filenameóá int∩á thσ ì
  481. RATFO╥á  inpu⌠ iε  placσ  oµ  thσ  includσá  statement«á  Thi≤  ì
  482. i≤ especiall∙ usefu∞ iε insertinτ commoε blocks«
  483.  
  484. See the example on the next screen.
  485.  
  486.  
  487.  
  488. è
  489.  
  490.  
  491.  
  492.  
  493. Include example:
  494.  
  495.           function exampl (x)
  496.           include comblk
  497.           exampl = x + z
  498.           return
  499.           end
  500.           
  501. might translate into
  502.           
  503.           function exampl (x)
  504.           common /comblk/ q, r, z
  505.           exampl = x + z
  506.           return
  507.           end
  508.  
  509. :Implementation 
  510.  
  511. RATFO╥ wa≤ originall∙ writteε iε C¼á  ß  high-leve∞  language¼  ì
  512. oεá thσ  Uni°  operatinτ  system«á Ou≥ versioε i≤á writteεá iε ì
  513. RATFO╥ itself¼ originall∙ brough⌠ u≡ b∙ ß bootstra≡ writteε iε ì
  514. FORTRAN« 
  515.  
  516. RATFO╥á generate≤ codσ b∙ readinτ inpu⌠ file≤ anΣá translatinτ  ì
  517. an∙ RATFO╥  keyword≤  int∩  standarΣ  FORTRAN«  Thus¼  iµ  thσ ì
  518. firs⌠á tokeεá (word⌐ oε ß sourcσ linσ i≤ no⌠ ßá keyworΣá (likσ ì
  519. "for"¼á  "while"¼á  etc.⌐á thσá  entirσ  statemen⌠á i≤á simpl∙ ì
  520. copieΣá t∩ thσ outpu⌠ witΦ appropriatσ characte≥á  translatioε  ì
  521. anΣá  formatting«á  RATFO╥  know≤  ver∙   littlσ FORTRANá  anΣ  ì
  522. thu≤á doe≤ no⌠ handlσ an∙ FORTRAN erro≥ detection«á Error≤á iε ì
  523. RATFO╥ keyworΣ synta° arσ generall∙  noteΣ  b∙  ß  messagσ  t∩  ì
  524. thσ user'≤  termina∞  alonτ  witΦ  aε indicatioε oµ thσ sourcσ ì
  525. linσ numbe≥ whicΦ causeΣ thσ problem« 
  526.  
  527. :Conclusions
  528.  
  529. RATFO╥á  demonstrate≤  tha⌠  witΦ  modes⌠   effor⌠á   FORTRAN-ì
  530. baseΣ programmer≤  caε  increasσ thei≥ productivit∙ b∙ usinτ ß ì
  531. languagσá tha⌠á provide≤ theφ  witΦ  thσ  contro∞á  structure≤  ì
  532. anΣ  cosmetiπ  feature≤ essentia∞  fo≥ structureΣá programminτ ì
  533. design«á Debugginτá anΣ subsequen⌠ revisioε  time≤  arσá  mucΦ  ì
  534. faste≥á  thaε  thσ  equivalen⌠  effort≤  iεá FORTRAN¼á  mainl∙  ì
  535. becausσá thσ codσ caε bσ easil∙ read«á Thu≤ i⌠ become≤á easie≥  ì
  536. t∩  writσ  codσ  tha⌠  i≤   readable¼   reliable¼   anΣ   eveε ì
  537. estheticall∙á   pleasing¼á   a≤   wel∞   a≤   beinτá  portablσ  ì
  538. t∩  othe≥ environments« 
  539.  
  540. :Other Reference Literature 
  541.  
  542. 1)  Kernighan¼á  Briaε  W.¼á  "RATFOR--ß  Preprocesso≥  fo≥  ß  ìèááááRationa∞á FORTRAN"«á  Softwarσ - Practicσ anΣá Experience¼ ì
  543. ááááVol« 5¼ ┤ (Oct-Deπ 75)¼ pp« 395-406« 
  544.  
  545. 2)  Kernighan¼á  Briaε  W«á  anΣ  P«  J«  Plauger¼   "Softwarσ   ì
  546. ááááTools"« Addison-Wesle∙ Publishinτ Company¼ Reading¼ Mass.¼ ì
  547. áááá1976« 
  548.  
  549. 3) áThσ RATFO╥ use≥ documen⌠ 
  550.  
  551. 4) áThσ Uni° commanΣ "rcó iε thσ Uni° Manua∞ (RC(I)⌐ 
  552.  
  553. 5)á Thi≤ HEL╨ filσ wa≤ buil⌠ froφ thσ RATFOR.PR═ filσ froφ thσ ì
  554. áááá"Softwarσ Toolsó CP/═ disks« Volumσ 24¼ filσ 2╕ iε thσ BD╙ ì
  555. áááá"Có onlinσ catalogue¼ BDSCAT.ALL.
  556.  
  557. Thσá onl∙ onσ oµ thesσ whicΦ i≤ likel∙ t∩ bσ readil∙ availablσ ì
  558. t∩ mos⌠ microcompute≥ user≤ i≤ thσ "Softwarσ Toolsó book« Thi≤ ì
  559. i≤á highl∙ recommendeΣ a≤ ß genera∞ tex⌠ eveε iµ yo⌡á arσá no⌠ ì
  560. particularl∙ interesteΣ iε RATFOR.
  561.