far manager internal viewer used as external viewer

You have encountered a problem using Far Manager? Here you can get help.
Post Reply
freethread
Posts: 3
Joined: Fri 18 Mar, 2011 11:29
Been thanked: 1 time

far manager internal viewer used as external viewer

Post by freethread »

First, hi to all.
I have two batch files to use far manager internal editor and viewer in stand-alone mode. The two batch files are similar, the following is for the viewer

view.cmd

Code: Select all

@echo off
"%ProgramFiles%\Far2\Far.exe" /v "%1"
This works as expected... but... I have another batch file for the program less, an file viewer I used before far, I guess you all know what is 'less'.

less.cmd

Code: Select all

@echo off
"%ProgramFiles%\less\less.exe" "%1"
With less.cmd I can view files in two ways: direcly, specifying file name and in a pipe

Code: Select all

less textfile.txt
or

Code: Select all

type textfile.txt | less
I wish the same behaviour with far internal viewer and stop using less. In the far command line options the -v option specify that it can be used with stdin if the file name is a dash '-'. I used directly on command line and it works in a pipe

Code: Select all

type textfile.txt | "%ProgramFiles%\Far2\far.exe" -v "-"
it does not work if I put it in the batch file

Code: Select all

@echo off
if "%*" == "" goto :RunPipe
"%ProgramFiles%\less\less.exe" "%1"
goto :End
:RunPipe
"%ProgramFiles%\Far2\far.exe" -v "-"
:End
It works in the same way with -v or /v.

Is there a way to use it like less?
Thanks in advance for your replies.

Far Manager version 2.0 version 1807 x86
Windows XP pro 32bits SP3

P.S. When far exit the console is in overwrite mode and cursor is hidden. Only with edit the cursor is visible, but in overwrite mode. I solved the overwrite with the command (in the batch files)

Code: Select all

doskey /INSERT
Hidden cursor not easily solved (made an exe file that show cursor with console APIs).
freethread
Posts: 3
Joined: Fri 18 Mar, 2011 11:29
Been thanked: 1 time

Re: far manager internal viewer used as external viewer

Post by freethread »

hem...updated info.
In DOS it works (cmd.exe). In one nested batch file call it does not work. In powershell it works if called directly (with no batch file, alias or function).
freethread
Posts: 3
Joined: Fri 18 Mar, 2011 11:29
Been thanked: 1 time

Re: far manager internal viewer used as external viewer

Post by freethread »

I made some changes in my batch scripts (DOS) where I was not able to use viewer in pipes, now it works (removed the dbl quotes around variables to pass them as parameters in nested batch files). In powershell I havn't found a solution yet.
Post Reply

Return to “Support and Troubleshooting”