Variable to shorten code
Variable to shorten code
(OP)
Hello,
My company has switched from Attachmate Extra! to Attachmate Reflection recently and I have been creating new macros with the new Reflection syntax.
All is going well, however I was wondering if there was a way to create a variable to shorten the extremely long Sendkey functions.
For example, to make the system send a "tab" key, you have to add ibm.CurrentScreen.SendControlKey(ControlKeyCode_Tab)
I thought I could do something like:
Set tabKey = ibm.CurrentScreen.SendControlKey(ControlKeyCode_Tab)
... but that did not work.
Any ideas on how to approach this?
Thanks for your help.
My company has switched from Attachmate Extra! to Attachmate Reflection recently and I have been creating new macros with the new Reflection syntax.
All is going well, however I was wondering if there was a way to create a variable to shorten the extremely long Sendkey functions.
For example, to make the system send a "tab" key, you have to add ibm.CurrentScreen.SendControlKey(ControlKeyCode_Tab)
I thought I could do something like:
Set tabKey = ibm.CurrentScreen.SendControlKey(ControlKeyCode_Tab)
... but that did not work.
Any ideas on how to approach this?
Thanks for your help.
RE: Variable to shorten code
CODE
Function sendkey(key)
ibm.CurrentScreen.SendControlKey(key)
End Function
or if you want a Function, just for tab, then
CODE
Function sendtab()
ibm.CurrentScreen.SendControlKey(ControlKeyCode_Tab)
End Function
Then you just need to call it in main with,
CODE
sendkey("Hello World!")
End Sub
Don't know if the declaration of function syntax is the same in Reflection, because i use Extra!, and i'm not sure if this will work perfectly, but that is how i would do it.
Hope it helps
RE: Variable to shorten code
Also, if you want a function to handle more ControlKeys, then you can make a function with an argument for the Controlkey, and then have a Switch (Select case) statement inside the function to use the correct control key.
You also need to Dim your session objects before the functions are described.
RE: Variable to shorten code