Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Variable to shorten code

Variable to shorten code

Variable to shorten code


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

Have never used Attachmate Reflection, but can't you make a function to do the job like,


Declare Function sendkey(key)

Function sendkey(key)
End Function

or if you want a Function, just for tab, then


Declare Function sendtab()

Function sendtab()
End Function

Then you just need to call it in main with,


Sub main
  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

Sorry, just realize the function was called SendControlKey, so the first function should not use SendControlKey, but the Sendkeys function instead.
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

Thanks Lakare, it worked perfectly!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close