home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / apps / math / fcc / examples.fcc next >
Text File  |  1991-12-14  |  7KB  |  241 lines

  1. ***************** Flow Chart Design Language Examples *********************
  2. Cut these examples, load them in your editor and compile them to familiarize
  3. yourself with the Flow Chart Design Language (FDL)
  4.  
  5. {* EXAMPLE #1 : PROGRAM BRKSTR *}
  6.  
  7. ^program BRKSTR.C;
  8. ^module brkstr();
  9. ^header Module brkstr();
  10. ^footer Module brkstr();
  11. ^date dec 14 1991;
  12.  
  13. Clear the blank point array, BLNK_PTS;
  14. While not the end of the input string do
  15.         if input string character = blank then  
  16.           store the position of the blank in the BLNK_PTS;
  17.         endif;
  18.         increment the character position counter;
  19. endwhile;
  20. Save last character position in BLNK_PTS for the end of string;
  21.  
  22. Set j = number of stored blanks;
  23.  
  24. for i = 0 j + 1 do
  25.         If block = UNTIL or WHILE or IF then
  26.          Set the variable MAXLEN = 16;
  27.         endif;
  28.         If block = FOR or PROCESS then
  29.          Set MAXLEN = 18;
  30.         endif;
  31.         If block = CALL then 
  32.          Set MAXLEN = 17;
  33.         endif;
  34.         If Any words in the string > MAXLEN then
  35.           Call cg_error and pass it the input string;
  36.           Increment the code generator error count;
  37.         endif;
  38. endfor;
  39.  
  40. While All words not processed do
  41.         If Exceeded number of substrings then
  42.           CALL cg_error and pass it the input string;
  43.           Increment the code generator error count;
  44.         endif;
  45.         Clear the temporary string buffer;
  46.         While Substring length <= length allowed do
  47.             Copy next word into temporary buffer;
  48.             Ife All words not processed then
  49.                Set variable FIT = 1;
  50.             else
  51.                Set variable FIT = 0;
  52.                CALL writ_str() to write the string to the output file;
  53.                Break out of while loop;
  54.             endelse;
  55.         endwhile;  
  56.         If Fit = 1 then
  57.           Append an EOL to the temporary buffer;
  58.           CALL writ_str() to write the string to the output file;
  59.         endif;
  60.         Increment the number of substrings;
  61. endwhile;
  62. ife Error count = 0 then
  63.  Return a successful status to the calling module;
  64. else
  65.  Return a CANCELED status to the calling module;
  66. endelse;
  67. ^endmod Return To Caller;
  68.  
  69. ^module cg_error();
  70. ^header Module cg_error();
  71. ^footer Module cg_error();
  72. ^date nov 6 1988;
  73.  
  74. Build the error string to indicate the input string doesn't fit;
  75. CALL put_msg() to write the error string on the console;
  76. ^endmod Return To Caller;
  77.  
  78. ^module writ_str;
  79. ^header Module writ_str();
  80. ^footer Module writ_str();
  81. ^date nov 6 1988;
  82.  
  83. call center() to get the coords to center the string;
  84. call put_xy() to write the x,y coords;
  85. Write the string to the output file;
  86. ^endmod Return To Caller;
  87. ^endprg;
  88.  
  89. ***************** Flow Chart Design Language Examples *********************
  90.  
  91. {** EXAMPLE #2 **}
  92. ^program COMPILER.TST;
  93. ^module One;
  94. ^date Oct 22 1988;
  95. ^header MODULE One;
  96. ^footer MODULE One;
  97.  
  98. Initialize x;
  99. While x != 10 do
  100.         Input a number;
  101.         Multiple the number by 12;
  102.         If result > 144 then
  103.                 set an error indication;
  104.                 for x = maxval 0 - 4 do
  105.                         for z = minval maxval + 2 do
  106.                                 test the for statements;
  107.                                 clear another array!;
  108.                 endfor; 
  109.                         ife this is working then 
  110.                                 perform this;
  111.                         else
  112.                                 perform that;
  113.                         endelse;
  114.                 endfor;
  115.         Endif;
  116.         increment x;
  117. Endwhile;
  118. If error exists then
  119.         output message to the screen;
  120.         increment the error count;
  121.         clear all variables;
  122. endif;
  123. call Module Two to perform more number operations;
  124. for  x = 100 0 -1 do
  125.         y = y * x;
  126.         print y;
  127.         y = y/34;
  128. endfor;
  129. ^endmod Exit Program;
  130.  
  131. ^module Two;
  132. ^header MODULE Two;
  133. ^footer MODULE Two;
  134. ^date Oct 23 1988;
  135.  
  136. Repeat
  137.         input a number;
  138.         If the number is negative then
  139.                 prompt the user, get another input;
  140.         endif;
  141. Until the number is positive;
  142. Call module Three for test purposes;
  143. While the number < 100 do
  144.         multiply the number by 10;
  145.         divide the number by 7;
  146. Endwhile;
  147. ^endmod Return to Caller;  
  148.  
  149. {***^program Test;***}
  150. ^module Three;
  151. ^date Nov 19 1989;
  152. ^header Selection Test;
  153. ^footer Selection Test;
  154.  
  155. This is a test of;
  156. the module and page selector;
  157. Ife this doesn't work then
  158.         I'll have to do some more debugging;
  159.         I'm testing this program now to see if the;
  160.         on-page connectors will go to lower case;
  161. else
  162.         I'll try to work on the print routine;
  163.         need to fill in more blocks;
  164. endelse;
  165. If this exceeds complexity then
  166.         I'll fix it;
  167. endif;
  168. While I'm doing that do
  169.         I'll keep trying to create;
  170.         sample modules to test the flow chart compiler on;
  171. endwhile; 
  172. While x != 10 do
  173.         Input a number;
  174.         Multiple the number by 12;
  175.         If result > 144 then
  176.                 set an error indication; 
  177.                 for x = maxval 0 - 4 do
  178.                         for z = minval maxval + 2 do
  179.                                 test the for statements;
  180.                                 clear another array!; 
  181.                 endfor; 
  182.                         ife this is working then 
  183.                                 perform this;
  184.                         else
  185.                                 perform that;
  186.                         endelse;
  187.                 endfor;
  188.         Endif;
  189.         increment x;  
  190. Endwhile;
  191.  
  192. Another test of the FCC; {**}
  193. this is an attempt to create a page 4;
  194. I am just typing in any text;
  195. to create blocks for another page;{**}
  196. {*** If this doesn't create page 4 then
  197.         I'll have to type in more stuff;
  198. endif; **}
  199.  
  200. Move the next block down in field #2;
  201. Also add more filler in to test the increment of;
  202. the on and off page connectors;
  203.  
  204. repeat
  205.   repeat
  206.                 Saddam Hussein will not rule;
  207.                 the region will be more stable;
  208.   until the ground war is over;
  209.   more fill in to test the flow chart compiler;
  210. until we win the war with Iraq;
  211. {***************}
  212. for a = 5 0 -1 do
  213.         this is a test of the module;
  214.         that adds a WHILPAGRT block to the;
  215.         block stack when the a WHILE block follows ;
  216.         an IFE block and the WHILE block has to be ;
  217.         placed on another page;
  218. endfor;
  219.  
  220. Repeat
  221.         4+4 = 8; 8+8 = 16/1;
  222.         if 8 < 7 then 7 > 6;
  223.         endif;
  224. until 4+4 > 9;
  225. While page 4 doesn't exist do
  226. {**}    type more stuff;
  227.         I'm feeling sick today;
  228.         too bad;
  229.         I hope I'll get better by tomorrow;
  230.         me too;
  231. endwhile;
  232. {**}this is a test;
  233. this is only a test;
  234. if this were a real drill then
  235.         you would be contacted;
  236. {**}    by someone impotent; 
  237. endif;
  238. ^endmod Return to Caller;
  239.  
  240. ^endprg;
  241.