Bug with Until?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Jon12345
Newbie
Posts: 8
Joined: Fri May 26, 2006 2:33 pm
Contact:

Bug with Until?

Post by Jon12345 » Sat May 27, 2006 3:19 pm

I have am having a problem with the script just crashing when I get to the Until statement at the end. Is this a bug or something wrong with my code?

Code: Select all

Let>k=560
Repeat>k
Let>ArticleID=k
VBEval>GetCustomerName("%ArticleID%"),ArticleIDNumber
StringReplace>ArticleIDNumber, ,%20,ArticleIDNumber

HTTPRequest>http://mysite.com/cgi-bin/script/script.cgi/?skin=jonclean1&length=10&keywords=%ArticleIDNumber%,,GET,,BodyText

VBRun>ChangeName,%ArticleID%,%BodyText%
Wait>3
Let>k=k+1
MessageModal>k
Until>k=566
MessageModal>Finished

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat May 27, 2006 11:31 pm

To use VBEval you must first run
VBStart>
VBEnd>

That will allow you to run internal VB functions.

If you are making your own VB function, then it needs to be defiined those two commands.

Then you can run
VBEval
and/or
VBRun
---------------------------
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Jon12345
Newbie
Posts: 8
Joined: Fri May 26, 2006 2:33 pm
Contact:

Post by Jon12345 » Sun May 28, 2006 8:57 pm

I did run vbstart and vbend - I just didn't post all the code. The whole lot is below:

Code: Select all

VBSTART

Function GetCustomerName(ArticleID)

    Dim SQLString

    set MyDB = CreateObject("ADODB.Connection")
    MyDB.Open "free_MyArticles"

    SQLString = "select * from Articles where id = " & ArticleID
	'	msgbox sqlstring
    
	set rsCustomers = MyDB.Execute(SQLString)

    If Not rsCustomers.EOF then
        GetCustomerName = rsCustomers.Fields("TopicName")
    Else
        GetCustomerName = "Not Found"
    End if

    MyDB.Close

End Function


Sub ChangeName(ArticleID,NewName)

    Dim SQLString

    set MyDB = CreateObject("ADODB.Connection")
    MyDB.Open "free_MyArticles"

	NewName=Replace(NewName, "'", "''")
	msgbox NewName

    SQLString = "Update Articles Set MSNFatBody = '" & NewName & "' Where (id = " & ArticleID & ")"
	'	msgbox SQLString

	set rsCustomers = MyDB.Execute(SQLString)

    MyDB.Close

End Sub

VBEND

/*
Input>ArticleID,Enter ArticleID:
*/

Let>k=560
Repeat>k
Let>ArticleID=k
VBEval>GetCustomerName("%ArticleID%"),ArticleIDNumber
StringReplace>ArticleIDNumber, ,%20,ArticleIDNumber

HTTPRequest>http://mysite.com/cgi-bin/script/script.cgi/?skin=jonclean1&length=10&keywords=%ArticleIDNumber%,,GET,,BodyText
/*
MessageModal>BodyText
*/
VBRun>ChangeName,%ArticleID%,%BodyText%
Wait>3
Let>k=k+1
MessageModal>k
Until>k>566
MessageModal>Finished
Jon

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun May 28, 2006 9:57 pm

If all VB code is commented out, script runs OK.
So trouble would seem to be in the BVScript.

With VB code not commented out, when doing Single Step through the script, bothVBEval and VBRun indicate a Visual Basic problem in defining the database:
At the VBEval line we get:
VBScript runtime error:429
ActiveX component can't create object 'ADODB.Connection'
Line 7, Column 4.
At the VBRun line we get:
VBScript runtime error:429
ActiveX component can't create object 'ADODB.Connection'
Line 30, Column 4.
So it does sound like syntax error......
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Jon12345
Newbie
Posts: 8
Joined: Fri May 26, 2006 2:33 pm
Contact:

Post by Jon12345 » Sun May 28, 2006 11:24 pm

I changed the code to protect my privacy on some stuff. I don't have a site at mysite.com for example. It is a different URL. Was this taken into consideration? And MyDB.Open "free_MyArticles" ...free_MyArticles is a MySQL connection using ODBC.
Jon

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sun May 28, 2006 11:54 pm

I also tested the until loop with a message instead of the VB and can confirm that it runs correctly. I would have to agree with Bob that the cause is in the VB which we can't test.

Jon12345
Newbie
Posts: 8
Joined: Fri May 26, 2006 2:33 pm
Contact:

Post by Jon12345 » Mon May 29, 2006 11:55 am

I hear what you say about the VBScript. But all the script does is retrieve a name from the database. It does this successfully. The next thing the VBScript does is to store a value in the database. It also does that successfully too.

Then, Macro Scheduler increments the counter k ready to loop around again. But it crashes at the statement Until. If I comment out the Until statement the script continues and displays Finished.

So, since the VBScript actually does what it is intended (i.e. retrieves the value and submits a value), together with the fact that it is only the Until statement that does not work, does this not imply a bug in the non-VBScript program as opposed to the VBScript being faulty?
Jon

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon May 29, 2006 8:31 pm

I don't see any problem with the Repeat/Until code here.

You don't mention which version of Macro Scheduler are you running ... please check under Help/About.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jon12345
Newbie
Posts: 8
Joined: Fri May 26, 2006 2:33 pm
Contact:

Post by Jon12345 » Tue May 30, 2006 9:48 am

I am using Version 8.0.3e with Microsoft Visual Basic Scripting Edition.
Jon

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue May 30, 2006 7:40 pm

Just had a chance to do some testing and I agree with Jon. It appears the problem is related to having the /* to */ remark embedded in the repeat statement.

Tried this on WinXP and on Win 2000 it was the same on both computers, Both running Macro Scheduler 8.0.3.

This works:

Code: Select all

Let>k=0
Repeat>k
add>k,1
//wait>1
Until>k>10
This fails:

Code: Select all

Let>k=0
Repeat>k
add>k,1
/*
wait>1
*/
Until>k>10
Hope this helps,
Dick

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue May 30, 2006 11:47 pm

Good catch Dick, I certainly didn't test it that way :oops:

Aha, I see this is pretty much bug # 72 that you submitted last year.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jun 05, 2006 9:54 pm

Sorry, not doing a very good job of keeping up.

I put this into bug tracker last week. Got a response the next day.
----- Posted by [email protected] at 3:23 PM on 06-01-2006 -----
+ Reproduced. Will fix in next release.
Later,
Dick

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts