beginner85 Posted October 28, 2009 Posted October 28, 2009 Hello all, i try to do a script return a string between 2 key word :$file = FileOpen("temp.db", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf For $line = 300 To 320 If StringInStr(FileReadLine($file, $line), "IFRAME style='PADDING-TOP: 10px' height=650 src='") Then $code = _StringBetween(FileReadLine($file, $line), "IFRAME style='PADDING-TOP: 10px' height=650 src='", "' frameBorder=0 width='100%' name=") $Online = $line EndIf Next FileClose($file) MsgBox(0, "Details", " On line " & $Online & " value = " & $code)It show the line content string i want to return, but the value is nothing. I don't know where wrong, please help me. Thank you
Paulie Posted October 28, 2009 Posted October 28, 2009 If you read the helpfile entry for _StringBetween, You would see: Success: Returns a 0 based $array[0] contains the first found string. So Try this code below $file = FileOpen("temp.db", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf For $line = 300 To 320 If StringInStr(FileReadLine($file, $line), "IFRAME style='PADDING-TOP: 10px' height=650 src='") Then $code = _StringBetween(FileReadLine($file, $line), "IFRAME style='PADDING-TOP: 10px' height=650 src='", "' frameBorder=0 width='100%' name=") $Online = $line EndIf Next FileClose($file) If IsArray($Code) then MsgBox(0, "Details", " On line " & $Online & " value = " & $code[0]) Else Msgbox(0,"Error", "Error: No String Found.") EndIf
beginner85 Posted October 28, 2009 Author Posted October 28, 2009 Many thanks to you. Have a good day
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