Jump to content
Sign in to follow this  
beginner85

Problem with __StringBetween

Recommended Posts

beginner85

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
Paulie

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.