passing variables from VB to MACRO Language

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
pinkpanther
Newbie
Posts: 9
Joined: Tue Aug 09, 2005 3:39 pm

passing variables from VB to MACRO Language

Post by pinkpanther » Wed Aug 10, 2005 2:06 pm

I have VB Code and MACRO Looper
Will this work? How to I send the value of phone to a screen field .. like the send>%phone% ???

VBSTART
set ShipDB = CreateObject("ADODB.Connection")
On Error Resume Next
ShipDB.Open "maketickets"
SQLString = "select * from FLINLAND"
set rsPickList = ShipDB.Execute(SQLString)
rsPickList.MoveFirst
Function GetNextRecord
If Not rsPickList.EOF then
clearing = rsPickList.Fields("Clearing#")
phone = rsPickList.Fields("tel#")
office = rsPickList.Fields("office")
msgBox phone
rsPicklist.movenext
else
GetNextRecord = 0
end if
end Function
VBEND
Label>looper
VBEval>GetNextRecord,phone,clearing,office
Message>phone
Message>clearing
Message>office
goto>looper
Pinkpanther

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Aug 10, 2005 2:18 pm

One way to do it: Have your VBScript function set global VBScript variables. Run the function and then use VBEval to transfer the variables to MacroScript variables:

VBSTART
set ShipDB = CreateObject("ADODB.Connection")
On Error Resume Next
ShipDB.Open "maketickets"
SQLString = "select * from FLINLAND"
set rsPickList = ShipDB.Execute(SQLString)
rsPickList.MoveFirst

Dim clearing
Dim phone
Dim office

Function GetNextRecord
If Not rsPickList.EOF then
clearing = rsPickList.Fields("Clearing#")
phone = rsPickList.Fields("tel#")
office = rsPickList.Fields("office")
msgBox phone
rsPicklist.movenext
else
GetNextRecord = 0
end if
end Function
VBEND
Label>looper
VBEval>GetNextRecord,result
if>result=0,exit
VBEVal>phone,my_phone
VBEval>clearing,my_clearing
VBEval>office,my_office
MessageModal>my_phone
MessageModal>my_clearing
MessageModal>my_office
goto>looper
Label>exit

Another way is to have the VBScript function return a delimited list of strings and separate them afterwards:

VBSTART
set ShipDB = CreateObject("ADODB.Connection")
On Error Resume Next
ShipDB.Open "maketickets"
SQLString = "select * from FLINLAND"
set rsPickList = ShipDB.Execute(SQLString)
rsPickList.MoveFirst

Function GetNextRecord
If Not rsPickList.EOF then
clearing = rsPickList.Fields("Clearing#")
phone = rsPickList.Fields("tel#")
office = rsPickList.Fields("office")
msgBox phone
GetNextRecord = clearing & ";" & phone & ";" & office
rsPicklist.movenext
else
GetNextRecord = 0
end if
end Function
VBEND
Label>looper
VBEval>GetNextRecord,returnedstring
If>returnedstring=0,exit
Separate>returnedstring,;,fields
MessageModal>fields_1
MessageModal>fields_2
MessageModal>fields_3
goto>looper
Label>exit

I've also added the code necessary to avoid your MacroScript loop looping forever.
MJT Net Support
[email protected]

pinkpanther
Newbie
Posts: 9
Joined: Tue Aug 09, 2005 3:39 pm

almost :) so far...

Post by pinkpanther » Wed Aug 10, 2005 2:38 pm

Ok, I think I am getting it. What is the actual syntax to then send it to the screen program? The recorder shows this and I want where it shows Send>M to really Send>valueofphone .....from the loop
Is it just send>phone or send>%phone%


Wait>0.94
MouseMove>217,338
Wait>1.87
LClick
Wait>2.26
Send>m
Wait>2.63
MouseMove>423,368
Wait>2.41
LClick
Pinkpanther

pinkpanther
Newbie
Posts: 9
Joined: Tue Aug 09, 2005 3:39 pm

messagemodal

Post by pinkpanther » Wed Aug 10, 2005 2:50 pm

This is what I have so far..but nothing is prompting on the screen.. I want to see the values of phone, office and clearing as it loops but I can't tell. Is that what Messagemodule does? is there a printscreen or debug.print?

VBSTART
set ShipDB = CreateObject("ADODB.Connection")
On Error Resume Next
ShipDB.Open "maketickets"
SQLString = "select * from FLINLAND"
set rsPickList = ShipDB.Execute(SQLString)
rsPickList.MoveFirst
Function GetData
If Not rsPickList.EOF then
phone = rsPickList.Fields("tel#")
clearing = rsPickList.Fields("clearing#")
office = rsPickList.Fields("office")
else
GetNextRecord = 0
end if
rsPickList.movenext
end function
VBEND
Label>looper
VBEval>GetData,result
if>result=0,exit
VBEVal>phone,my_phone
VBEval>clearing,my_clearing
VBEval>office,my_office
MessageModal>my_phone
MessageModal>my_clearing
MessageModal>my_office
goto>looper
label>exit
Pinkpanther

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