Better way to issue shell command programmatically?

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

Better way to issue shell command programmatically?

Post by rattle »

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: 6815
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 526 times

Better way to issue shell command programmatically?

Post by Shmuel »

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: 23
Joined: Sat 02 Sep, 2017 18:58
Been thanked: 8 times

Better way to issue shell command programmatically?

Post by rattle »

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.
User avatar
Xerox
Posts: 395
Joined: Sun 20 Oct, 2019 15:50
Has thanked: 354 times
Been thanked: 9 times

Better way to issue shell command programmatically?

Post by Xerox »

Have you seen other "Panel functions" in supplied standard manual, it has "getItem", "selectItem"?
In general, i think, FAR gives you visual representation. with abstractions of all kinds of "panel/panleItem", representing all possible objects
If you want to work with that obkjects directly - no problem,you have all API to do that, and you have ability to extend that as well
Probably i misunderstood you however, becaucse i am not totally clear about what you mean
Again, if you need visual representation - you may work with it, if you need real underlying objects - you handle it as well.
Post Reply

Return to “Macro Commands Discussions”