styles3000 Posted December 13, 2009 Posted December 13, 2009 I want to extract from one one place and place it in another. Here's the function(s) that extract for me....... For $i = 1 to 1 $Title = _GetTitle("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\000"&$i&".txt") ;MsgBox(0,'',$Title) sleep(3000) FileMove("D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\christmas greetings\index"&$i&".htm", "D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\christmas greetings\"&$title&".htm",1) ;ConsoleWrite ( "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\000"&$i&".txt") sleep(3000) next Func _GetTitle($File) $text = FileRead($File) $posStart = StringInStr($text,'<title>') $posEnd = StringInStr($text,'</title>') If $posStart = 0 or $posEnd = 0 Then MsgBox(0,'ERROR','This File doesnt Contain a Title') $result = '' ; This File doesnt Contain a Title Else $result = StringMid($text,$posStart+7,$posEnd-($posStart+7)) EndIf $result= StringLower($result) Return $result EndFunc Func _SendTitle($Title) Sleep(250) ControlSend("Notepad",'','', String($Title)) ControlSend('[Class:Notepad]', '', 'Edit1', $Title) Sleep(250) EndFunc Once extracted, I want to use this script below to send the string, but I'm unsure where to place the $Title variable ...... expandcollapse popupGlobal $hFile Global $SomeTxt Global $StartPos, $EndPos Global $Find_This, $Find_This_Too Global $MyResult $Find_This = "<title>" $Find_This_Too = "</title>" $hFile = FileOpen("D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\christmas greetings\index.htm",0) ;Open file in read mode If @error Then MsgBox(0,"Warning", "Unable to open file") Exit EndIf $SomeTxt = FileRead($hFile) ;reads the complete file FileClose($hFile) $StartPos = StringInStr($SomeTxt,$Find_This) + StringLen($Find_This) ;finds the first string and puts the pos direct behind the found string If $StartPos = 0 Then ;means $Find_This not found, no need to continue MsgBox(0,"Warning", "Unable to find: " & $StartPos) Exit Else ConsoleWrite("$StartPos= " & $StartPos & @CRLF) ;not needed just added to check if code works EndIf $EndPos = StringInStr($SomeTxt,$Find_This_Too,0,1,$StartPos) ;finds the first occurence of $Find_This_Too after $Start_pos If $EndPos = 0 Then ;means $Find_This_Too was not found, no need to continue MsgBox(0,"Warning", "Unable to find: " & $EndPos) Exit Else ConsoleWrite("$EndPos= " & $EndPos & @CRLF) ;not needed just added to check if code works EndIf $MyResult = (StringMid($SomeTxt,$StartPos,$EndPos-$StartPos)) $MyResult = StringStripWS($MyResult,3) [code]If StringLen($MyResult) <> 0 Then MsgBox(0,"Finished", "You were looking for: " & $MyResult ) $text_from_clip = ClipGet() ;Takes the result off the clipboard $result = StringReplace($SomeTxt, $MyResult, $text_from_clip) Clipput($Result) ;Put the result on the clipboard Else MsgBox(0,"Warning", "Unable to find the wanted string") EndIf I know I have to somehow re-write this part of the code, but I just don't know which part.... If StringLen($MyResult) <> 0 Then MsgBox(0,"Finished", "You were looking for: " & $MyResult ) $text_from_clip = ClipGet() ;Takes the result off the clipboard $result = StringReplace($SomeTxt, $MyResult, $text_from_clip) Clipput($Result) ;Put the result on the clipboard Else MsgBox(0,"Warning", "Unable to find the wanted string") EndIf
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now