Author Topic: Macro to run a python script in command line window.  (Read 6583 times)

lanthanum

  • New Community Member
  • Posts: 1
  • Hero Points: 0
Macro to run a python script in command line window.
« on: August 04, 2009, 06:45:48 pm »
I've just set up slickedit, and want to use for python development.

Is there an example macro somewhere out there that I can use or adapt to run a python script in a command line from slickedit?  I just want to be able to open any python file, and hit F9 or something equivalent to run the script.  I don't neccesarily want to set up a python project/use the debugger.

Absinthe

  • Guest
Re: Macro to run a python script in command line window.
« Reply #1 on: August 09, 2009, 12:03:21 am »
There are a few ways, but easiest is to setup a project. Then you can configure the execute commands to run however you like.

Graeme

  • Senior Community Member
  • Posts: 2359
  • Hero Points: 310
Re: Macro to run a python script in command line window.
« Reply #2 on: August 09, 2009, 01:59:04 am »
If you really don't want a project, here's a couple of ways that appear to work on Windows.  PythonFolder is wherever your python interpreter is.

<quote from my last post>
"To use it, open vusrmac.e from your configuration folder, insert the code and load it using the load module command on the macro menu.  If you don't have a vusrmac.e file, you can create one by recording a trivial macro.  e.g. on the macro menu, select start recording, press end, shift+tab, home  (or whatever you like), then stop recording and save the macro (or edit it).  You can bind whatever key you want to the macros below."


Code: [Select]
_command void xp1() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
   shell("cmd.exe /k \"C:/Program Files/PythonFolder/python\" " :+ maybe_quote_filename(p_buf_name), 'A' );
}


_command void xp2() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
   concur_command('"C:/Program Files/PythonFolder/python" ' :+ maybe_quote_filename(p_buf_name));
}

bremenpl

  • Community Member
  • Posts: 85
  • Hero Points: 0
  • Electrical Engineer
Re: Macro to run a python script in command line window.
« Reply #3 on: June 29, 2013, 01:52:26 pm »
Also, is macro supposed to be compiled somehow?

Graeme

  • Senior Community Member
  • Posts: 2359
  • Hero Points: 310
Re: Macro to run a python script in command line window.
« Reply #4 on: June 30, 2013, 06:26:09 am »
Also, is macro supposed to be compiled somehow?
The load module command on the macro menu will both compile it (into vusrmac.ex) and load it.  "Loading" consists of adding the .ex code to the state file and adding all the function names etc to the names table.  If the source file (vusrmac.e) hasn't changed from when it was last compiled, it won't be re-compiled by the load command.