Guest User

Untitled

a guest
Dec 8th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. 'Crossreference
  3. 'Benjy Berkowicz
  4. '6/9/11
  5. window 1, "Cross Reference", (0,0)-(700,530)
  6. dim linesarray$(50), wordsarray$(50), linescount(50), wordscount(50), wordappear(50)
  7. nonunique = 0
  8. DO
  9. gosub "heading"
  10. locate x,y:input "Enter your line of text: "; thisline$
  11. i = 0
  12. wordcount = 0
  13. wordsarray$(0) = "0"
  14. while thisline$ <> "*"
  15. i = i + 1
  16. linesarray$(i) = thisline$
  17. linesarray$(0) = str$(val(linesarray$(0)) + 1)
  18. locate x,y+i:input "Enter your line of text: "; thisline$
  19. wend
  20. gosub "ReadThrough"
  21. gosub "SortArray"
  22. gosub "PrintList"
  23. gosub "Clean"
  24. UNTIL ucase$(done$) = "N"
  25. end
  26.  
  27. "Clean"
  28. wordsarray$(0) = "0"
  29. linesarray$(0) = "0"
  30. unique = 0
  31. nonunique = 0
  32. RETURN
  33.  
  34. "Heading"
  35. cls
  36. TEXT _times, 20, _boldBit%
  37. color _zRed
  38. print %(160,30) "Welcome To Cross Reference!"
  39. TEXT _applFont, 16, 0
  40. color _zBlack
  41. let x = 2
  42. let y = 2
  43. RETURN
  44.  
  45. "ReadThrough"    
  46. FOR i = 1 to val(linesarray$(0))
  47. tempword$ = ""
  48. FOR j = 1 to len(linesarray$(i))
  49. extr$ = mid$(linesarray$(i),j,1)
  50.  
  51. punc = 0
  52. gosub "CheckPunc"
  53.  
  54. long if letter <> 1
  55. long if tempword$ <> " "
  56. gosub "IfWordExistsAdd"
  57. end if
  58. xelse
  59. tempword$ = tempword$ + mid$(linesarray$(i),j,1)
  60. end if
  61. long if j = len(linesarray$(i))
  62. 'gosub "IfWordExistsAdd"
  63. end if
  64.  
  65. NEXT j
  66. NEXT i
  67. RETURN
  68.  
  69. "CheckPunc"
  70. letter = 0
  71. alph$ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  72. FOR k = 1 to len(alph$)
  73. long if extr$ = mid$(alph$,k,1)
  74. letter = 1
  75. end if
  76. NEXT k
  77. RETURN
  78.  
  79. "IfWordExistsAdd"
  80. thisnum = 0
  81. unique = 1
  82. DEF LCASE(tempword$)
  83. FOR m = 1 to val(wordsarray$(0))
  84. long if wordsarray$(m) = tempword$
  85. unique = 0
  86. thisnum = m
  87. END IF
  88. NEXT m
  89.  
  90. LONG IF unique = 1
  91. tz = val(wordsarray(0)) + 1
  92. wordsarray$(0) = str$(tz)
  93. tz = 0
  94. temp = val(wordsarray$(0))
  95. wordsarray$(temp) = tempword$
  96. wordscount(temp) = 1
  97. wordappear(temp) = val(wordsarray$(0))
  98. linescount(temp) = i
  99. XELSE
  100. wordscount(thisnum) = wordscount(thisnum) + 1
  101. nonunique = nonunique + 1
  102. END IF
  103. tempword$ = ""
  104. RETURN
  105.  
  106. "SortArray"
  107. DO
  108. swapped = 0
  109. FOR j = 1 to val(wordsarray$(0))-1
  110. temp = wordscount(j)
  111. temp2 = wordscount(j+1)
  112. LONG IF temp < temp2
  113. gosub "Swap"
  114. swapped = 1
  115. END IF
  116. NEXT j
  117. UNTIL swapped = 0
  118. RETURN
  119.  
  120. "PrintList"
  121. gosub "Heading"
  122. print "Word", "Frequency", "In Line", "Word Number"
  123. FOR i = 1 to val(wordsarray$(0))
  124. locate x,y+i+1:print wordsarray$(i), wordscount(i), linescount(i), wordappear(i)
  125. NEXT i
  126. print ""
  127. locate x,y+val(wordsarray$(0))+3:print "Total words = " + str$(val(wordsarray$(0)) + nonunique)
  128. locate x,y+val(wordsarray$(0))+4:print "Total unique words = " + wordsarray$(0)
  129. locate x,y+val(wordsarray$(0))+5:input "Do you want to go again (Y/N)? ";done$
  130. RETURN
  131.  
  132. "Swap"
  133. temp1$ = wordsarray$(j)
  134. temp2 = wordscount(j)
  135. temp3 = linescount(j)
  136. temp4 = wordappear(j)
  137. wordsarray$(j) = wordsarray$(j+1)
  138. wordscount(j) = wordscount(j+1)
  139. linescount(j) = linescount(j+1)
  140. wordappear(j) = wordappear(j+1)
  141. wordsarray$(j+1) = temp1$
  142. wordscount(j+1) = temp2
  143. linescount(j+1) = temp3
  144. wordappear(j+1) = temp4
  145. RETURN
Add Comment
Please, Sign In to add comment