Codemike 0 Posted February 2, 2011 Is it possible to do this simply vb.net program which finds words (or similar) in AutoIt? If is how (or can be someone so nice and shows code)? Module Module1 Sub Main() Console.Clear() Console.Write("Write text: ") Dim Text = Console.ReadLine() If ContainsSuchword(Text) Then Console.WriteLine("There is one or more such words") Else Console.WriteLine("There is no such words") End If Threading.Thread.Sleep(1000) End Sub Private Function ContainsSuchword(ByVal text As String) As Boolean Dim Suchwords = New String() {"word1", "word2", "you were"} For Each Suchword In Suchwords If text.ToLower.Contains(Suchword) Then Return True End If Next Return False End Function End Module Share this post Link to post Share on other sites
Melba23 3,457 Posted February 2, 2011 Codemike,Welcome to the AutoIt forum. You obviously missed this at the top of the page. I have asked a Mod to move it - please do NOT start another thread in the meantime. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Share this post Link to post Share on other sites
jvanegmond 306 Posted February 2, 2011 Here's a line by line conversion of your code. Your old code is put in comments behind the original lines. I have sometimes shortly highlighted the differences between AutoIt and VB. Writing a console application is not as favorable in AutoIt as it is in VB. If you want to test a console application in AutoIt you have to compile it first. Therefore I have chosen to use InputBox and MsgBox. You are probably familiar with these: VB has them too. [autoit]Main() ; Main needs to be called in AutoIt. Alternatively, you don't have to define a Main() at all Func Main() ; Sub Main() ; Console.Clear() $Text = InputBox("", "Enter text please") ; Console.Write("Write text: ") ; Dim Text = Console.ReadLine() If ContainsSuchword($Text) Then ;If ContainsSuchword(Text) Then MsgBox(0, "", "There is one or more such words") ;Console.WriteLine("There is one or more such words") Else ; Else MsgBox(0, "", "There is no such words") ; Console.WriteLine("There is no such words") EndIF ; End If Sleep(1000) github.com/jvanegmond Share this post Link to post Share on other sites
jvanegmond 306 Posted February 2, 2011 (edited) Double posted due to lag. Can't delete posts. Edited February 2, 2011 by Manadar github.com/jvanegmond Share this post Link to post Share on other sites
Codemike 0 Posted February 2, 2011 Here's a line by line conversion of your code. Your old code is put in comments behind the original lines. I have sometimes shortly highlighted the differences between AutoIt and VB. Writing a console application is not as favorable in AutoIt as it is in VB. If you want to test a console application in AutoIt you have to compile it first. Therefore I have chosen to use InputBox and MsgBox. You are probably familiar with these: VB has them too. [autoit]Main() ; Main needs to be called in AutoIt. Alternatively, you don't have to define a Main() at all Func Main() ; Sub Main() ; Console.Clear() $Text = InputBox("", "Enter text please") ; Console.Write("Write text: ") ; Dim Text = Console.ReadLine() If ContainsSuchword($Text) Then ;If ContainsSuchword(Text) Then MsgBox(0, "", "There is one or more such words") ;Console.WriteLine("There is one or more such words") Else ; Else MsgBox(0, "", "There is no such words") ; Console.WriteLine("There is no such words") EndIF ; End If Sleep(1000) Thanks very much your answer. But I'm a beginner in the programming. Can you (or some other) show working code? Don't I need this end to get my vb.net (which is not my original code) program to work? End Sub Private Function ContainsSuchword(ByVal text As String) As Boolean Dim Suchwords = New String() {"word1", "word2", "you were"} For Each Suchword In Suchwords If text.ToLower.Contains(Suchword) Then Return True End If Next Return False End Function End Module Share this post Link to post Share on other sites
jvanegmond 306 Posted February 3, 2011 Damnit. The forum was being broken for me yesterday in multiple places. I did translate that part and I saw the code was fully working after some testing, it just didn't came through in the post. Ofcourse I didn't keep a backup, so I have to re-do it. Main() ; Main needs to be called in AutoIt. Alternatively, you don't have to define a Main() at all Func Main() ; Sub Main() ; Console.Clear() $Text = InputBox("", "Enter text please") ; Console.Write("Write text: ") ; Dim Text = Console.ReadLine() If ContainsSuchword($Text) Then ;If ContainsSuchword(Text) Then MsgBox(0, "", "There is one or more such words") ;Console.WriteLine("There is one or more such words") Else ; Else MsgBox(0, "", "There is no such words") ; Console.WriteLine("There is no such words") EndIF ; End If Sleep(1000) ;Threading.Thread.Sleep(1000) EndFunc; End Sub Func ContainsSuchWord($Text) ;Private Function ContainsSuchword(ByVal text As String) As Boolean Dim $Suchwords[3] = ["word1", "word2", "you were"] ;Dim Suchwords = New String() {"word1", "word2", "you were"} For $i = 0 To UBound($Suchwords)-1 ;For Each Suchword In Suchwords If StringInStr($Text, $Suchwords[$i]) Then ;If text.ToLower.Contains(Suchword) Then Return True EndIf ;End If Next Return False EndFunc;End Function Here you go. :/ github.com/jvanegmond Share this post Link to post Share on other sites