So, some of this code may look odd, but that is because I am using this script in conjunction with a program called iMacros. Here is the jist of what the following code is supposed to do: The script logs me into a certain website (hence the "Login" script). Then, it searches the page for a link entitled "mine" (hence the "Search" script). If the link "mine" is not found, the following code is supposed to loop the "Search" script again until the link "mine" is found (the "mine" link is dynamic and only appears every so often, completely randomly). However, if the "mine" link is found, the following code is supposed to run the "Mine" script which will then in turn click the link.
The following code is working about 75%. My problem is that it continuously loops the "Search" script whether or not the "mine" link is in fact on the page, so it never is clicked. I am new to VBScripting, so I am quite sure that I am doing something wrong when I typed "Do Until instr...."
If iplay = 1 Then if instr (extracted_text, "#EANF#") > 0 then Do Until instr (extracted_text, "#EANF#") < 0 iplay = iim1.iimPlay("Search") Loop else iplay = iim1.iimPlay("Mine") End If End if
I was about to answer your question, because I liked the way you presented your problem: giving a fair amount of context and a short piece of code showing where you have difficulties. It would have been better if this code could be executed 'as is', but on the other hand side, too much details/code of your InternetMacros classes would distract from your problem.
But yesterday I accidentially entered "www.microsoft.com/bills/private/parts/download" in my browser and found this "Digital Rights Enforcement Suite". The module to check for bathtub singing isn't ready yet (will be part of service pack 12 (2010)) but I can scan the immediate nighbourhood of any Windows computer (if it was online at least once) thru the monitor power LED.
You'll understand that this is much more fun than VBScript programming!
Just now I'm looking at this NeutralisTheEye, who is disappointed, because nobody answered his question. (I can see his thoughts written on his forehead by means of this marvellous "quantum blueteeth" module.) Now he thinks:
"I will solve my problem by breaking it into smaller parts and writing little pieces of test code to tackle these subproblems. Obviously there is something fishy with my use of the Instr function and the logical/sequential arrangement of my 'get the new version of the site' and 'search for #EANF#' actions."
Asking the "ray bending wizard" to look at his monitor, I now can see NeutralisTheEye created a new file "solutions.vbs". (Looks like NeutralisTheEye is no better at inventing names than me.) What's the code?
Why does NeutralisTheEye call up the VBScript Docs? Ah - thats the Instr() page. The code changes:
and the output:
What is NeutralisTheEye doing now?
Ah, concentrating on the current problem but marking what should be looked into. I bet, NeutralisTheEye will code some IF/ELSE/END IF statements next.
Why does NeutralisTheEye glare at the output:
Ah, I see: a little bit of editing:
Reordering the function calls:
Now I surely will have to wait - but no - here it comes:
Some ray bending and I can read on NeutralisTheEye's forehead: "First get the invariant part of the loop right, then add fancy if/then/else." And "Let's keep this code and do the difficult part in a new function."
But this run breaks:
... Laufzeitfehler in Microsoft VBScript: Ungültige Zuweisung: 'loadSearchLoad'
Nice surprise: The "Digital Rights Enforcement Suite" is fully localized! Even translating Legalese into German! NeutralisTheEye forgot to change the assignment to the function name (happens to me all the time). New version:
and output:
Hey, there is a popup on my screen:
"You have no Digital Rights to use this software meant for serious money making just for fun! 'Digital Rights Enforcement Suite' will be uninstalled now."
Looks like I'll have to write my own code from now on again.
ehvbs
< Message edited by ehvbs -- 5/20/2006 9:14:59 PM >
Oh, that's just ehvbs. Sometimes he gets into the paint thinner, and everybody just has to ignore him. Eventually, he'll come down and sober up in a dumpster somewhere wearing nothing but a lamp shade and smelling like a 2 week old bowl of tunafish salad. Until then, we all just have to kind of go along with his posts, as he tends to meander a bit.
Cheers!
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers)
"It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
it is embarrassing to have to explain a joke and even more embarrassing to have to say that some piece of text was meant as joke, but having failed miserably at an attempt to be funny, I must do just that.
Hi NeutralisTheEye,
I owe you an apology because I answered to your question in an inappropriate way that perhaps even distracted other members of this forum from giving it the attention it deserves. I still think that the code in my posting could give you some hints how to search different versions of a website for specified content. If you are still willing to consider a contribution of me:
' load the string to search in extracted_text = iim1.iimGetLastExtract() ... ' will be true if Instr() returns a valid position of "#EANF#" in extracted_text if instr (extracted_text, "#EANF#") > 0 then ' will be reached only if instr (extracted_text, "#EANF#") > 0 ' as extracted_text isn't changed, the loop won't be entered Do Until instr (extracted_text, "#EANF#") < 0 ' will loop forever, if reached, because extracted_text isn't changed iplay = iim1.iimPlay("Search") Loop else ' will be reached only if *Not* instr (extracted_text, "#EANF#") > 0 iplay = iim1.iimPlay("Mine") End If ...
As to digital screams and comic strips: I have analog ears and prefer "Calvin & Hobbes".
I was checking the syntax to use the file scripting object and stumbled upon this thread...
I have a complete collection of calvin and hobbes books. I knew I liked this forum.
Then the... "I can see that he did..." and quantum blueteeth!
Laughing is important when you stare at the screen all day!
I'm still construting the access manipulation part of my code. Then I have to add it to the geoprocessing stuff and then I can try to run it... I have a funny feeling I'll be back with an error or two!