Better way to issue shell command programmatically?

Here you can discuss any topic concerning Far macro commands.
Post Reply
User avatar
rattle
Posts: 18
Joined: Sat 02 Sep, 2017 18:58

Better way to issue shell command programmatically?

Post by rattle » Fri 16 Mar, 2018 01:33

Let's say I want to use the commandline capabilities of FAR to navigate to a file/folder using the goto: command, but from inside a macro. Currently, I do this:

Code: Select all

panel.SetCmdLine(nil, 'goto:' .. directory)
Keys('Enter')
or alternatively,

Code: Select all

Keys('CtrlG')
print('goto:' .. directory)
Keys('Enter')
I keep wondering whether there is a better way to directly execute a commandline command as if I had entered it in FAR's commandline - not just in this one example, but also generally.
Last edited by rattle on Fri 16 Mar, 2018 01:34, edited 2 times in total.

Shmuel
Posts: 5577
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 21 times
Been thanked: 186 times

Better way to issue shell command programmatically?

Post by Shmuel » Fri 16 Mar, 2018 01:48

panel.SetPanelDirectory (nil, 1, directory) -- 0 for passive panel; 1 for active panel
Whether it's better or not - I don't know.

User avatar
rattle
Posts: 18
Joined: Sat 02 Sep, 2017 18:58

Better way to issue shell command programmatically?

Post by rattle » Fri 16 Mar, 2018 03:27

For this particular case, that is an alright alternative - however, it is not as good as goto: because it will not work as well for files as goto. However, I have asked myself this question with many FAR shell commands that I like to execute programmatically, a generic solution would be best.

Post Reply

Return to “Macro Commands Discussions”