You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Svein Arne Ackenhausen edited this page May 10, 2014
·
2 revisions
Often we want to run other OpenIDE commands from a script. In this script we will run the editor goto command to open a file in the editor. In this script we wait for the command to finish while it's ok to not to wait if you are with it running asynchronously.
This sample is in python as I enjoy using python. You can use any language you want
#!/usr/bin/env pythonimportsysdefprint_definitions():
print("Opens the running scrip in the editor")
defwrite(msg):
sys.stdout.write(msg+"\n")
sys.stdout.flush()
defwait_for_command():
whileTrue:
line=sys.stdin.readline().strip("\n")
ifline=="end-of-command":
breakdefrun_command(run_location, global_profile, local_profile, args):
# Runs editor goto command to open current file on line 1 column 1# Waiting for the command to finish is not required it is just# here to show you how to do it.write("command|editor goto \""+sys.argv[0]+"|1|1\"")
wait_for_command()
if__name__=="__main__":
args=sys.argviflen(args) >1andargs[2] =='get-command-definitions':
print_definitions()
else:
run_command(args[1], args[2], args[3], args[4:])