Jump to content
Sign in to follow this  
ffiso

StringInStr... Little problem...

Recommended Posts

ffiso

Hi!!!

I have a little problem, maybe you can help me out :D

I have already used the search.. but no luck...

the problem is that i'm unable to find the position of a substring using StringInStr, below is the code I'm Using, so here a little explanation

I'm looking for the text 'equiv="C', but StringInStr always returns a 0 instead of a 104...

if I look for 'equiv=' Success! (but I also need the part after the equal sign)

if I look for '="' Success! (but not the position I'm looking for)

if I look for '="C' it fails.... (but I also need the part before the equal sign)

It seems that the function doesn't like the Equal + Quote sign and a letter before or after...

This is all an example, the actual code is trying to look for some specific tags, but that's the main problem, can't use it loading the source code into a String... but if I write the source code directly into the autoit code everything works fine... but of course that's impossible if I want to look into a page that updates constantly...

Thanks for your help!!!

This code doesn't work

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()

$GUI = GUICreate("Titulo", 800, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 815, 465)
GUISetState()

_IENavigate($oIE, "http://www.autoitscript.com/")
$codigoFuente = _IEDocReadHTML($oIE)
$pos = StringInStr($codigoFuente, 'equiv="C')

MsgBox(0, "", $pos)

----------------------------------------------

this code works..., but as you can see, the String where the function looks is within the code....

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()
$origen = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'

$GUI = GUICreate("Titulo", 800, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 815, 465)
GUISetState()

_IENavigate($oIE, "http://www.autoitscript.com/")
$pos = StringInStr($origen, 'equiv="C')

MsgBox(0, "", $pos)

Share this post


Link to post
Share on other sites
Jos

Have you looked at the source?

<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type><LINK rel=stylesheet type=text/css href="css/default.css"><LINK rel=stylesheet type=text/css href="css/default_ie.css"></HEAD>

I don't see the doubleQuote.


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
SmOke_N

The "simple" answer is, there is no equiv=C in the source code.

Edit:

Seems Jos beat me, but I copied to clipboard, and I don't have equiv= anything.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Exit

This works for me:

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()

$GUI = GUICreate("Titulo", 800, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 815, 465)
GUISetState()

_IENavigate($oIE, "http://www.autoitscript.com/")
$codigoFuente = _IEDocReadHTML($oIE)
$pos = StringInStr($codigoFuente, 'equiv=C')
ConsoleWrite($codigoFuente)
MsgBox(0+262144, "", $pos)

Result is 64. :D


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
ffiso

Have you looked at the source?

I don't see the doubleQuote.

OOOOK... Then there's something weird.... How you did that???, because I DO see the double quote in the source code (from firefox and from IExplorer).... maybe I should have looked in the String xD

Sorry :o never thought of analyzing the String instead of the "View Source Code" option in the explorers....

Yep, I just did... they're different :D (The string and the view source code option)

This works for me:

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()

$GUI = GUICreate("Titulo", 800, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 815, 465)
GUISetState()

_IENavigate($oIE, "http://www.autoitscript.com/")
$codigoFuente = _IEDocReadHTML($oIE)
$pos = StringInStr($codigoFuente, 'equiv=C')
ConsoleWrite($codigoFuente)
MsgBox(0+262144, "", $pos)

Result is 64. :D

Thanks to all of you :P though the result for me is 104, not 64 :|.....

Thanks!!!

Share this post


Link to post
Share on other sites
Jos

OOOOK... Then there's something weird.... How you did that???, because I DO see the double quote in the source code (from firefox and from IExplorer).... maybe I should have looked in the String xD

What I always do in these cases is an Alt+D on the variable I want to know the exact value (assuming you have the full SciTE4AutoIT3) which will add a Debug line for you. Then hit F5 and look in the Outputpane of SciTE. :D

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×