How to call a function inside the source code

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
aysha
Newbie
Posts: 7
Joined: Thu Apr 28, 2005 9:19 am

How to call a function inside the source code

Post by aysha » Mon May 02, 2005 6:28 am

Hi,

problem statment: i have an application and now i'ev created a Macro which will fill all specifeid feilds on a Screen

what i have done is that i'ev written a function and now i want to call this function inside the source code but i dont know how i call it there
can some one help me???

my code is looking like

Source Code
// C:\Program Files\MJT Net Ltd\Macro Scheduler\Lims.scp
// Recorded on Friday, April 29, 2005, at 04:21 PM

//Recorded Events
Let>WW_TIMEOUT=5
CapsOff
MouseMove>73,23
Wait>1.34
LClick
Wait>0.4
MouseMove>80,41
Wait>0.52
LClick
WaitWindowOpen>APEX XarrayDB Object
MoveWindow>APEX XarrayDB Object,369,311
ResizeWindow>APEX XarrayDB Object,287,119
Wait>0.58
MouseMove>487,402
Wait>1.04
LClick
WaitWindowOpenALIMS >
MoveWindow>ALIMS ,,121
ResizeWindow>ALIMS ,0,4294967175
Wait>2.8
send>lic No
Wait>0.66
MouseMove>496,93
Wait>0.91
LDown
Wait>0.09
Send>2
Wait>0.02
LClick
WaitWindowOpen>ALIMS
MoveWindow>ALIMS ,,121
ResizeWindow>ALIMS ,0,4294967175
Wait>1.06
Send>121
Wait>0.1
MouseMove>752,698
Wait>1.14
LClick
WaitWindowOpen>LIMSUI
MoveWindow>LIMSUI,344,311
ResizeWindow>LIMSUI,336,119
Wait>0.63
MouseMove>509,405
Wait>1.43
LClick
WaitWindowOpen>ALIMS
MoveWindow>ALIMS ,,121
ResizeWindow>ALIMS ,0,4294967175
Wait>0.01
MouseMove>895,31
Wait>2.18
LClick
WaitWindowOpen>ALIMS
MoveWindow>ALIMS ,,-4
ResizeWindow>ALIMS ,0,4
Wait>0.01
MouseMove>948,763
Wait>4.01
Press CTRL
Wait>0.28
Press ALT
//source code end

Here is function
VBSTART
Dim SQLString
dim rsCustomers
dim MyDB
Function GetCustomerName
set MyDB = CreateObject("ADODB.Connection")
MyDB.Open "DSNCUS"
SQLString = "select FName from Lims"
set rsCustomers = MyDB.Execute(SQLString)
If Not rsCustomers.EOF then
GetCustomerName = rsCustomers.Fields("FName")
Else
GetCustomerName = "Not Found"
End if

MyDB.Close
End Function
VBEND

Function end

now what i want to do is that i want to retriew that table value on Applocation Form and save them.
here is code where i tried to retriev values from table oN FORM Fields.

// C:\Program Files\MJT Net Ltd\Macro Scheduler\Lims.scp
// Recorded on Friday, April 29, 2005, at 04:21 PM

//Recorded Events
Let>WW_TIMEOUT=5
CapsOff
MouseMove>73,23
Wait>1.34
LClick
Wait>0.4
MouseMove>80,41
Wait>0.52
LClick
WaitWindowOpen>APEX XarrayDB Object
MoveWindow>APEX XarrayDB Object,369,311
ResizeWindow>APEX XarrayDB Object,287,119
Wait>0.58
MouseMove>487,402
Wait>1.04
LClick
WaitWindowOpenALIMS >
MoveWindow>ALIMS ,,121
ResizeWindow>ALIMS ,0,4294967175
Wait>2.8
send>lic No
Wait>0.66
MouseMove>496,93
Wait>0.91
VBEval>GetCustomerName,FName
LDown
Wait>0.09
Send>rsCustomers.Fields("FName")
Wait>0.02
LUp
MouseMove>566,93
Wait>0.17

plz have look on this code and tell me it is correct or not
i'll be really thankful to u
regards
aysha
________
iolite vaporizer
Last edited by aysha on Tue Feb 01, 2011 9:32 am, edited 1 time in total.

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 » Mon May 02, 2005 2:57 pm

Try this:

Move the function name to the top, and add (FName) to accept a parameter.

Code: Select all

VBSTART

Function GetCustomerName(FName)

Dim SQLString
dim rsCustomers
dim MyDB

set MyDB = CreateObject("ADODB.Connection")
MyDB.Open "DSNCUS"
SQLString = "select FName from Lims"
set rsCustomers = MyDB.Execute(SQLString)

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

MyDB.Close

End Function

VBEND
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

aysha
Newbie
Posts: 7
Joined: Thu Apr 28, 2005 9:19 am

aysha

Post by aysha » Tue May 03, 2005 11:25 am

hi,

sorry this is not a right answer of my ques
i have this function already in running form
values which had been displayed through message window in this function now i want to display that values on my Application Screen/Form (in a text box).

basically i want to create a Macro for Data Entry on a specific Form

1. i'ev created a table which name is Lims
2.this consist of 5 fields.
3.i want to create a Macro for a data entry on a Screen which consisnt of a lot of fields but i need that some specific fileds should be filled by Table values which i mentioned in Fucntion

now problem is that when how i can call that function in Source code so that when i run Macro that specific value get filled automatically.

i hope now u have got my point and u'd help me

Regards
aysha
________
Yamaha FZ150i specifications

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