Medic873 0 Posted May 27, 2011 Okay my task with this script is pretty simple and I feel it can be done retaily easy. what I want to do is make a program to automaticly find synonyms for all the words in a text document. So I already have a basic gui that asks for the text document you can see that here. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 445, 192, 124) $TitleLabel = GUICtrlCreateLabel("Title", 10, 16, 24, 17) $TitleInput = GUICtrlCreateInput("Insert Title Here", 10, 40, 441, 21) $ContentLabel = GUICtrlCreateLabel("Content", 10, 80, 41, 17) $ContentInput = GUICtrlCreateEdit("", 10, 104, 601, 297) GUICtrlSetData(-1, StringFormat("Insert content here.\r\n\r\nOnce all content has been entered click "&Chr(34)&"Flip Content"&Chr(34)&".\r\n\r\nOur software will highlight all words that can be flipped simply right click on a \r\nhighlighted word and choose a synonym.")) $FlipContent = GUICtrlCreateButton("Flip Content", 8, 408, 603, 33, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $FlipContent EndSwitch WEnd but my next question is how can I get it to pull each word as a array so do something like this. word 1 can be found from 1st space to 2nd space take that word and make it word[1] word 2 can be found from 2nd space to 3rd space so on..... how do I get it to divide the content like that Share this post Link to post Share on other sites
BrewManNH 1,305 Posted May 28, 2011 You could do a string split and use the space as the delimiter. You'd probably want to add the period and comma if they're in the text as well. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way!I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Share this post Link to post Share on other sites
Malkey 231 Posted May 28, 2011 Press the "Flip Content" button in the example and a 2D array appears showing all the words from the edit control, with each word's start position, and each word's last character position. expandcollapse popup#include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 445, 192, 124) $TitleLabel = GUICtrlCreateLabel("Title", 10, 16, 24, 17) $TitleInput = GUICtrlCreateInput("Insert Title Here", 10, 40, 441, 21) $ContentLabel = GUICtrlCreateLabel("Content", 10, 80, 41, 17) $ContentInput = GUICtrlCreateEdit("", 10, 104, 601, 297) GUICtrlSetData(-1, StringFormat("Insert content here.\r\n\r\nOnce all content has been entered click " & Chr(34) & "Flip Content" & Chr(34) & ".\r\n\r\nOur software will highlight all words that can be flipped simply right click on a \r\nhighlighted word and choose a synonym.")) $FlipContent = GUICtrlCreateButton("Flip Content", 8, 408, 603, 33, $WS_GROUP) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $FlipContent $sContent = GUICtrlRead($ContentInput) $Stext = StringStripWS(StringRegExpReplace($sContent, "([^[:alpha:] '])", " "), 7) $aArr = StringSplit($Stext, " ") ; An array of all the words. Local $aWordPos[UBound($aArr)][3] = [[$aArr[0], "Start", "Last"]] ; New 2D array Local $iPos = 1 For $i = 1 To $aArr[0] $aWordPos[$i][0] = $aArr[$i] ; The word $aWordPos[$i][1] = StringInStr($sContent, $aArr[$i], 0, 1, $iPos) ; Position of 1st character. $iPos = $aWordPos[$i][1] + StringLen($aWordPos[$i][0]) $aWordPos[$i][2] = $iPos - 1 ; Position of last character of the word. Next _ArrayDisplay($aWordPos) EndSwitch WEnd Share this post Link to post Share on other sites