Android Question Wordsearch Puzzle

brianwiz12

Active Member
Licensed User
Longtime User
Im getting a syntax error and invalid number of indices.2 expected in the following code

 

emexes

Expert
Licensed User
Longtime User
Is wordSearchGrid() a 1-dimensional array, or 2-dimensional?

If it is an array of arrays, then it is new to me that you could access it using two indices inside one set of brackets.
 
Upvote 0

emexes

Expert
Licensed User
Longtime User
Lol you could put the letter check inside a Try so that if you access wordSearchGrid() past its edges then it does a Catch Return False.

Should work, but feels dangerous.
 
Upvote 0

emexes

Expert
Licensed User
Longtime User
The Year of Programming Dangerously:
Sub CheckHorizontal(row As Int, col As Int, checkLength As Int, word As String) As Boolean
    For i = 0 To checkLength - 1
        Try
            If wordSearchGrid(row, col + i) <> word.CharAt(i) Then
                Return False ' Mismatch found, word not present horizontally
            End If
        Catch
            Return False ' Word goes out of bounds
        End Try
    Next
    Return True ' Word found horizontally
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…