Ch4_5Crossword

water + a salt is a word equation for the process called ____", _ "turns phenolphthalein pink", _ "a unit used to measure heat energy", _ "a uniform mixture of a solute and solvent is called a", _ "exhaust products in cars are broken down by a catalytic __", _ "a reaction in which the temperature of the surroundings decreases") WordX = Array(11, 18, 6, 12, 21, 2, 7, 18, 8, 1, 10, 11, 21, 10, 3, 16, 16, 0, 20, 21, 13, 9, 22, 2, 7, 16, 5, 11, 18, 4, 15, 6, 17, 25, 27) WordY = Array(1, 3, 5, 5, 6, 8, 10, 11, 12, 13, 14, 16, 17, 18, 19, 19, 22, 24, 24, 28, 0, 1, 3, 5, 5, 5, 7, 10, 11, 12, 13, 15, 16, 16, 19) LastHorizontalWord = 19 ' The next step is to generate the TableLetters() and TableWords() arrays. Redim TableLetters(CrosswordWidth, CrosswordHeight) Redim TableAcrossWord(CrosswordWidth, CrosswordHeight) Redim TableDownWord(CrosswordWidth, CrosswordHeight) For y = 0 to CrosswordHeight - 1 For x = 0 to CrosswordWidth - 1 TableLetters(x, y) = "" TableAcrossWord(x, y) = -1 TableDownWord(x, y) = -1 Next Next ' First, add the horizontal words to the puzzle. For i = 0 to LastHorizontalWord x = WordX(i) y = WordY(i) For j = 1 to Len(Word(i)) TableLetters(x + j - 1, y) = Mid(Word(i), j, 1) TableAcrossWord(x + j - 1, y) = i Next Next ' Second, add the vertical words to the puzzle. For i = LastHorizontalWord + 1 to Words - 1 x = WordX(i) y = WordY(i) For j = 1 to Len(Word(i)) TableLetters(x, y + j - 1) = Mid(Word(i), j, 1) TableDownWord(x, y + j - 1) = i Next Next ' Now, insert the rows into the table. For y = 0 to CrosswordHeight - 1 document.write "" For x = 0 to CrosswordWidth - 1 If Len(TableLetters(x, y)) Then ' This is an actual word. document.write "" Else document.write "" End if Next document.write "" & vbNewLine Next ' Finally, show the crossword and hide the wait message. document.all.waitmessage.style.display = "none" document.all.crossword.style.display = "block" ' Following are functions used by the events. Function PadNumber(Number) ' This function pads a number to three digits, i.e. 3 goes to 003. If Number < 10 Then PadNumber = "00" & Number ElseIf Number < 100 Then PadNumber = "0" & Number Else PadNumber = Number End If End Function Sub DeselectCurrentWord () ' This sub is called by SelectWord to deselect the previous word, if needed. Dim x, y, i ' If nothing's selected, just exit quietly. Nobody has to know... If CurrentWord < 0 Then Exit Sub ' First, hide the answer area. document.all.answerbox.style.display = "none" ' Just iterate through the cells of the selected word, and change their style. x = WordX(CurrentWord) y = WordY(CurrentWord) If CurrentWord <= LastHorizontalWord Then ' They selected an across word. For i = 1 to Len(Word(CurrentWord)) eval("c" & PadNumber(x + i - 1) & PadNumber(y)).className = "box" Next Else ' They selected a down word. For i = 1 to Len(Word(CurrentWord)) eval("c" & PadNumber(x) & PadNumber(y + i - 1)).className = "box" Next End if End Sub Sub SelectThisWord () ' This sub selects the new word. This is done by analyzing the name of the TD ' referenced by the "event" object, and then applying styles as necessary. Dim x, y, i, TheirWord, TableCell ' Start off by deselecting the previous word, if applicable. If CrosswordFinished Then Exit Sub DeselectCurrentWord ' Now, determine the current coordinates of the cell they clicked. x = CLng(Mid(window.event.srcElement.id, 2, 3)) y = CLng(Mid(window.event.srcElement.id, 5, 3)) ' Okay, now which word did they click? If TableAcrossWord(x, y) > -1 And TableDownWord(x, y) > -1 Then ' They clicked an intersection, so choose the type of word (across or ' down) that was NOT selected last time. If PrevWordHorizontal Then ' The last word they selected was horizontal, so select a vertical ' one this time. CurrentWord = TableDownWord(x, y) Else ' The last word they selected was vertical. CurrentWord = TableAcrossWord(x, y) End If ElseIf TableAcrossWord(x, y) > -1 Then ' They clicked an across word. CurrentWord = TableAcrossWord(x, y) ElseIf TableDownWord(x, y) > -1 Then ' They clicked a down word. CurrentWord = TableDownWord(x, y) End if If CurrentWord <= LastHorizontalWord Then PrevWordHorizontal = 1 Else PrevWordHorizontal = 0 ' Now, iterate through the cells of the selected word, and change their style. x = WordX(CurrentWord) y = WordY(CurrentWord) If CurrentWord <= LastHorizontalWord Then ' They selected an across word. For i = 1 to Len(Word(CurrentWord)) eval("c" & PadNumber(x + i - 1) & PadNumber(y)).className = "highlight" Next Else ' They selected a down word. For i = 1 to Len(Word(CurrentWord)) eval("c" & PadNumber(x) & PadNumber(y + i - 1)).className = "highlight" Next End if ' Now, prepare the answering area. x = WordX(CurrentWord) y = WordY(CurrentWord) If CurrentWord <= LastHorizontalWord Then ' This is an across word. For i = 1 to Len(Word(CurrentWord)) Set TableCell = eval("c" & PadNumber(x + i - 1) & PadNumber(y)) If Len(Trim(TableCell.innerText)) Then TheirWord = TheirWord & TableCell.innerText Else TheirWord = TheirWord & Chr(149) End If Next Else ' This is a down word. For i = 1 to Len(Word(CurrentWord)) Set TableCell = eval("c" & PadNumber(x) & PadNumber(y + i - 1)) If Len(Trim(TableCell.innerText)) Then TheirWord = TheirWord & TableCell.innerText Else TheirWord = TheirWord & Chr(149) End If Next End If wordlabel.innerText = TheirWord If CurrentWord <= LastHorizontalWord Then wordinfo.innerText = "Across, " & Len(Word(CurrentWord)) & " letters." Else wordinfo.innerText = "Down, " & Len(Word(CurrentWord)) & " letters." End If wordclue.innerText = Clue(CurrentWord) worderror.style.display = "none" wordentry.value = "" ' Finally, show the answering area. answerbox.style.display = "block" On Error Resume Next wordentry.focus On Error Goto 0 End Sub Function ContainsBadChars(TheirWord) ' Returns True if the string passed contains any characters prone to evil. Dim i ContainsBadChars = True For i = 1 to Len(TheirWord) If InStr(BadChars, Mid(TheirWord, i, i)) Then Exit Function Next ContainsBadChars = False End Function Sub WordEntryKeyPress ' If they press Enter, treat it as a click on the OK button. If CrosswordFinished Then Exit Sub If CurrentWord > -1 Then If window.event.keyCode = 13 Then OKClick End Sub Sub OKClick ' Called when they click the OK link. Dim TheirWord, x, y, i, TableCell If CrosswordFinished Then Exit Sub ' First, validate their entry. TheirWord = Trim(document.all.wordentry.value) If Len(TheirWord) = 0 Then ' They didn't type anything -- just assume they meant to cancel. DeselectCurrentWord Exit Sub End If If ContainsBadChars(TheirWord) Then document.all.worderror.innerText = "The word that you typed contains invalid characters. Please type only letters in the box above." document.all.worderror.style.display = "block" Exit Sub End If If Len(TheirWord) < Len(Word(CurrentWord)) Then document.all.worderror.innerText = "You did not type enough letters. This word has " & Len(Word(CurrentWord)) & " letters." document.all.worderror.style.display = "block" Exit Sub End If If Len(TheirWord) > Len(Word(CurrentWord)) Then document.all.worderror.innerText = "You typed too many letters. This word has " & Len(Word(CurrentWord)) & " letters." document.all.worderror.style.display = "block" Exit Sub End If ' If we made it this far, apparently they typed an acceptable word. ' So, add these letters to the puzzle, and hide the entry box. x = WordX(CurrentWord) y = WordY(CurrentWord) If CurrentWord <= LastHorizontalWord Then ' This is an across word. For i = 1 to Len(TheirWord) Set TableCell = eval("c" & PadNumber(x + i - 1) & PadNumber(y)) TableCell.innerText = Mid(TheirWord, i, 1) TableCell.style.color = "" Next Else ' This is a down word. For i = 1 to Len(TheirWord) Set TableCell = eval("c" & PadNumber(x) & PadNumber(y + i - 1)) TableCell.innerText = Mid(TheirWord, i, 1) TableCell.style.color = "" Next End If DeselectCurrentWord End Sub Sub CheckClick ' Called when the user clicks the "check puzzle" button. Dim x, y, ErrorsFound, TableCell If CrosswordFinished Then Exit Sub DeselectCurrentWord ErrorsFound = False For y = 0 To CrosswordHeight - 1 For x = 0 to CrosswordWidth - 1 If TableAcrossWord(x, y) > -1 or TableDownWord(x, y) > -1 Then ' There's a letter here - check it. Set TableCell = eval("c" & PadNumber(x) & PadNumber(y)) If Len(TableCell.innerText) > 0 Then If UCase(TableLetters(x, y)) <> UCase(TableCell.innerText) Then ' This cell is incorrect -- paint it red. TableCell.style.color = "#c00000" ErrorsFound = True End If Else ErrorsFound = True End If End If Next Next ' If we found errors, just exit -- the cells are already colored. If ErrorsFound Then Exit Sub ' Congratulations! They have finished the puzzle. CrosswordFinished = True checkbutton.style.display = "none" congratulations.style.display = "block" End Sub Sub CheatClick ' Called when the user clicks the "cheat" button. If CrosswordFinished Then Exit Sub wordentry.value = Word(CurrentWord) OKClick End Sub

check puzzle

Sorry, but this interactive crossword puzzle requires Microsoft Windows and Internet Explorer 5 or later.


 

This crossword puzzle was created by dcolgur with EclipseCrossword. Try it today—it's free!