How to make a script "aware" of its calling context

Ask questions about how to create a script or swap scripts with other users.
Post Reply
jgodfrey
Posts: 471
Joined: 19 Aug 2011 23:02
Location: Missouri, USA

How to make a script "aware" of its calling context

Post by jgodfrey »

Hi Rickard,

I'm wondering if it's possible to make a script somehow aware of the context in which it was called? Consider the following:

Let's say I create a script that's capable of searching the current file either *up* or *down* from the current cursor position. Now, I'd like to wire that script to two separate hot key combinations - one to search up and the other to search down. Can the script somehow be made aware of how it was called, so it can react appropriately?

A few ways I can think of to do this:
  • Make the keystroke(s) that started the script available within the script itself. So, the script could determine its actions based on the keystrokes that started it.
  • Allow command line arguments to be defined along with the hot key assignment itself. So, maybe I'd define "Ctrl+Up" to start my script and pass the string "up" into the script. Again, the script could examine the startup context and react appropriately.
Maybe there's already a way to accomplish this that I'm unaware of?

Thanks for any input you can provide.

Jeff
Post Reply