home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 3.ddi / BIGSTRIN.BA$ / BIGSTRIN.bin
Encoding:
Text File  |  1990-06-24  |  1.6 KB  |  58 lines

  1. 'Define arrays which will be passed to each new level
  2. '       of recursion.
  3. DECLARE SUB BigStrings (n%, s1$(), s2$(), s3$(), s4$())
  4. DEFINT A-Z
  5. DIM s1$(1 TO 2), s2$(1 TO 2), s3$(1 TO 2), s4$(1 TO 2)
  6. ' Compute the # of 64K blocks available in far memory.
  7. n = FRE(-1) \ 65536
  8. CLS
  9. 'Quit if not enough memory.
  10. IF n < 1 THEN
  11.              PRINT "Not enough memory for operation."
  12.              END
  13. END IF
  14.  
  15. ' Start the recursion.
  16. CALL BigStrings(n, s1$(), s2$(), s3$(), s4$())
  17.  
  18. SUB BigStrings (n, s1$(), s2$(), s3$(), s4$())
  19. ' Create a new array (up to 64K) for each level of recursion.
  20. DIM a$(1 TO 2)
  21. ' Have n keep track of recursion level.
  22. SELECT CASE n
  23. ' When at highest recusion level, process the strings.
  24.         CASE 0
  25.                 PRINT s1$(1); s1$(2); s2$(1); s2$(2); s3$(1); s3$(2); s4$(1); s4$(2)
  26.         CASE 1
  27.                 a$(1) = "Each "
  28.                 a$(2) = "word "
  29.                 s1$(1) = a$(1)
  30.                 s1$(2) = a$(2)
  31.         CASE 2
  32.                 a$(1) = "pair "
  33.                 a$(2) = "comes "
  34.                 s2$(1) = a$(1)
  35.                 s2$(2) = a$(2)
  36.         CASE 3
  37.                 a$(1) = "from "
  38.                 a$(2) = "separate "
  39.                 s3$(1) = a$(1)
  40.                 s3$(2) = a$(2)
  41.         CASE 4
  42.                 a$(1) = "recursive "
  43.                 a$(2) = "procedures."
  44.                 s4$(1) = a$(1)
  45.                 s4$(2) = a$(2)
  46. END SELECT
  47.  
  48. ' Keep going until we're out of memory.
  49. IF n > 0 THEN
  50.                 n = n - 1
  51. ' For each recursion, pass in previously created arrays.
  52.                 CALL BigStrings(n, s1$(), s2$(), s3$(), s4$())
  53. END IF
  54.  
  55. END SUB
  56.  
  57.  
  58.