Sign in to follow this  
Followers 0
beginner85

Problem with __StringBetween

3 posts in this topic

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)

Posted Image

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites
:) Many thanks to you. Have a good day

Share this post


Link to post
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
Sign in to follow this  
Followers 0