Jump to content

WordSearch


gamerman2360
 Share

Recommended Posts

It's not anywhere near finished... I just need a way to get it to my other computer. If someone wants to help. Take it, edit it, post it. This will be the topic that has the finished code so I didn't post in the wrong place. I think.

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0+
; Author:        Steve B
;
; Script Function:
;   Searches through word searches.
;
; ----------------------------------------------------------------------------
; vvv (under construction) vvv
Opt("ExpandVarStrings", 1)
Opt("ExpandEnvStrings", 1)
Opt("GUIOnEventMode", 1)
HotKeySet("^s", "Save"); CTRL(^) + s
$width = UBound($puzzle) * 7 + 20
$height = UBound($puzzle, 2) * 9 + 20
GUICreate("SearchWord", $width, $height, (@DesktopWidth - $width) / 2, (@DesktopHeight - $height))
GUISetFont(8, Default, Default, "Lucida Console")

$open = Open()

Dim $words[InputBox("SearchWord", "Please type the number of words there are.", "", " M")][3]
Dim $puzzle[InputBox("X", "Please type the number of columns there are.", "", " M")][InputBox("Y", "Please type the number of rows there are.", "", " M")][3]
; ^^^ (under construction) ^^^
For $x = 0 To UBound($puzzle) - 1
    For $y = 0 To UBound($puzzle, 2) - 1
        $puzzle[$x][$y][0] = StringUpper(InputBox($x & ", " & $y, "Type the letter in column $x$ and row $y$.", "", " M1"))
        $puzzle[$x][$y][1] = GUICtrlCreateLabel($puzzle[$x][$y][0], $x * 7 + 10, $y * 9 + 10)
    Next
Next

For $i = 0 To UBound($words) - 1
    $words[$i][0] = StringUpper(InputBox($i, "Type word #" & $x+1 & ".", "", " M"))
    $puzzle[$x][$y][1] = GUICtrlCreateLabel($puzzle[$x][$y][0], $x * 7 + 10, $y * 9 + 10)
Next

For $x = 0 To UBound($puzzle) - 1; reset
    For $y = 0 To UBound($puzzle, 2) - 1
        GUICtrlSetData($puzzle[$x][$y][1], $puzzle[$x][$y][0])
        GUICtrlSetStyle($puzzle[$x][$y][1], )
    Next
Next

;~      GUICtrlSetData
;~    GUICtrlSetTip
;~    GUICtrlSetStyle
;~      GUICtrlSetColor

Func Search()
    For $y = 0 To UBound($puzzle, 2) - 1; Check Left => Right
        $check = ""
        For $x = 0 To UBound($puzzle) - 1; Asseble Line
            $check &= $puzzle[$x][$y][0]
        Next
        For $i = 0 To UBound($words) - 1; Check for word
            $search = StringInStr($check, $words[$i][0])
            If $search <> 0 Then; Found
                $len = StringLen($words[$i][0])
                $words[$i][2] &= "(" & $search - 1 & ", $y$)=>(" & $search - 1 + StringLen($words[$i][0]) & ", " & $y + StringLen($words[$i][0]) & ")"
            EndIf
        Next
    Next

    For $y = 0 To UBound($puzzle, 2) - 1; Check Right => Left
        $check = ""
        For $x = UBound($puzzle) - 1 To 0 Step -1; Asseble Line
            $check &= $puzzle[$x][$y][0]
        Next
        For $i = 0 To UBound($words) - 1; Check for word
            $search = StringInStr($check, $words[$i][0])
            If $search <> 0 Then; Found
                StringLen($words[$i][0])
                $words[$i][2] &= "(" & $search - 1 & ", $y$)=>(" & $search - 1 + StringLen($words[$i][0]) & ", " & $y + StringLen($words[$i][0]) & ")"
            EndIf
        Next
    Next

    For $x = 0 To UBound($puzzle) - 1; Check Top => Bottom
        $check = ""
        For $y = 0 To UBound($puzzle, 2) - 1; Asseble Line
            $check &= $puzzle[$x][$y][0]
        Next
        For $i = 0 To UBound($words) - 1; Check for word
            $search = StringInStr($check, $words[$i][0])
            If $search <> 0 Then; Found
                $len = StringLen($words[$i][0])
                $words[$i][2] = "($x$, " & $search - 1 & ")=>(" & $x + StringLen($words[$i][0]) & ", " & $search - 1 + StringLen($words[$i][0]) & ")"
            EndIf
        Next
    Next

    For $x = 0 To UBound($puzzle) - 1; Check Bottom => Top
        $check = ""
        For $y = UBound($puzzle, 2) - 1 To 0 Step -1; Asseble Line
            $check &= $puzzle[$x][$y][0]
        Next
        For $i = 0 To UBound($words) - 1; Check for word
            $search = StringInStr($check, $words[$i][0])
            If $search <> 0 Then; Found
                $len = StringLen($words[$i][0])
                $words[$i][2] = "($x$, " & $search - 1 & ")=>(" & $x + StringLen($words[$i][0]) & ", " & $search - 1 + StringLen($words[$i][0]) & ")"
            EndIf
        Next
    Next
    
    For $i = 0 To UBound($puzzle) - 1; Check Bottom-Left => Top-Right (under construction)
        $check = ""
        $x = 0
        For $y = UBound($puzzle, 2) - 1 To 0 Step -1; Asseble Line
            
            If Not IsDeclared("puzzle[$x][$y][0]") Then ContinueLoop
            $check &= $puzzle[$x][$y][0]
            $x += 1
        Next
        For $i = 0 To UBound($words) - 1; Check for word
            $search = StringInStr($check, $words[$i][0])
            If $search <> 0 Then; Found
                $len = StringLen($words[$i][0])
                $words[$i][2] = "(" & $x & ", " & $search - 1 & ")=>(" & $x + StringLen($words[$i][0]) & ", " & $search - 1 + StringLen($words[$i][0]) & ")"
            EndIf
        Next
    Next
    
    For $i = 0 To UBound($puzzle) - 1; Check Top-Right => Bottom-Left (under construction)
        $check = ""
        For $y = UBound($puzzle, 2) - 1 To 0 Step -1; Asseble Line
            $check &= $puzzle[$x][$y][0]
        Next
        For $i = 0 To UBound($words) - 1; Check for word
            $search = StringInStr($check, $words[$i][0])
            If $search <> 0 Then; Found
                $len = StringLen($words[$i][0])
                $words[$i][2] = "(" & $x & ", " & $search - 1 & ")=>(" & $x + StringLen($words[$i][0]) & ", " & $search - 1 + StringLen($words[$i][0]) & ")"
            EndIf
        Next
    Next
    
    For $i = 0 To UBound($puzzle) - 1; Check Top-Left => Bottom-Right (under construction)
        $check = ""
        For $y = UBound($puzzle, 2) - 1 To 0 Step -1; Asseble Line
            $check &= $puzzle[$x][$y][0]
        Next
        For $i = 0 To UBound($words) - 1; Check for word
            $search = StringInStr($check, $words[$i][0])
            If $search <> 0 Then; Found
                $len = StringLen($words[$i][0])
                $words[$i][2] = "(" & $x & ", " & $search - 1 & ")=>(" & $x + StringLen($words[$i][0]) & ", " & $search - 1 + StringLen($words[$i][0]) & ")"
            EndIf
        Next
    Next
    
    For $i = 0 To UBound($puzzle) - 1; Check Bottom-Right => Top-Left (under construction)
        $check = ""
        For $y = UBound($puzzle, 2) - 1 To 0 Step -1; Asseble Line
            $check &= $puzzle[$x][$y][0]
        Next
        For $i = 0 To UBound($words) - 1; Check for word
            $search = StringInStr($check, $words[$i][0])
            If $search <> 0 Then; Found
                $len = StringLen($words[$i][0])
                $words[$i][2] = "(" & $x & ", " & $search - 1 & ")=>(" & $x + StringLen($words[$i][0]) & ", " & $search - 1 + StringLen($words[$i][0]) & ")"
            EndIf
        Next
    Next
EndFunc

Func Save($filepath = FileSaveDialog("Save SearchWord Session", @WorkingDir, "Initialization Files (*.ini)", 18, "WordSearch"))
    If WinActive("SearchWord") Then
        For $i = 0 To UBound($words) - 1
            IniWrite($filename, "Words", "", $words[$i][0])
        Next
        For $y = 0 To UBound($puzzle, 2) - 1
            $save = ""
            For $x = 0 To UBound($puzzle) - 1
                $save &= $puzzle[$x][$y][0]
            Next
            IniWrite($filepath, "Letters", $y, $save)
        Next
    Else
        HotKeySet(@HotKeyPressed)
        Send(@HotKeyPressed)
        HotKeySet(@HotKeyPressed, "Save")
    EndIf
EndFunc

Func Open($filepath = FileOpenDialog("Open SearchWord Session", @WorkingDir, "Initialization Files (*.ini)", 18, "WordSearch")); (under construction)
    IniReadSection("filename", "section")
    For $i = 0 To UBound($words) - 1
        IniWrite($filename, "Words", "", $words[$i][0])
    Next
    For $y = 0 To UBound($puzzle, 2) - 1
        $save = ""
        For $x = 0 To UBound($puzzle) - 1
            $save &= $puzzle[$x][$y][0]
        Next
        IniWrite($filepath, "Letters", $y, $save)
    Next
EndFunc

Edited by gamerman2360
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...