Topic: System() call (1 of 9), Read 25 times
Conf: VEDIT Macro Language Support
From: Pauli Lindgren
Date: Friday, April 11, 2008 05:53 AM

I have been trying to call an external Windows program from Vedit using system() command, but it does not work.

My macro builds DOS command in text register pointed by #53. Then it is executed with command
System(@(#53))

The command may be for example as follows (directly pasted from the text register):
"C:\Program Files\Aspell\bin\aspell" pipe <"c:\vedit\USER-MAC\wildfilew.txt" >"C:\DOCUME~1\PAULIL~1\LOCALS~1\Temp\VeditTmp\aspell.out"

If I enter exactly that command in DOS window, it works OK.
Aspell runs, reads the text from wildfilew.txt and outputs the results in aspell.out. However, when called from Vedit macro with System command, it ignores the input/output redirection and instead expects input from console and outputs to console.

I then tried with System(@(#53),DOS). But that gives error
CANNOT SHELL OUT. ERROR #87

I have tested this both on Windows XP Home (SP1) and Windows XP Pro (SP1). Vedit 6.15.2.

--
Pauli

 


Topic: System() call (2 of 9), Read 24 times
Conf: VEDIT Macro Language Support
From: Ian Binnie
Date: Friday, April 11, 2008 08:47 AM

On 4/11/2008 5:53:52 AM, Pauli Lindgren wrote:
>I have been trying to call an
>external Windows program from
>Vedit using system() command,
>but it does not work.
>
>My macro builds DOS command in
>text register pointed by #53.
>Then it is executed with
>command
>System(@(#53))
>
>The command may be for example
>as follows (directly pasted
>from the text register):
>"C:\Program
>Files\Aspell\bin\aspell" pipe
><"c:\vedit\USER-MAC\wildfilew.
>txt"
>>>"C:\DOCUME~1\PAULIL~1\LOCALS~
>1\Temp\VeditTmp\aspell.out"
>
>If I enter exactly that
>command in DOS window, it
>works OK.
>Aspell runs, reads the text
>from wildfilew.txt and outputs
>the results in aspell.out.
>However, when called from
>Vedit macro with System
>command, it ignores the
>input/output redirection and
>instead expects input from
>console and outputs to
>console.
>
>I then tried with
>System(@(#53),DOS). But that
>gives error
>CANNOT SHELL OUT. ERROR #87
>
>I have tested this both on
>Windows XP Home (SP1) and
>Windows XP Pro (SP1). Vedit
>6.15.2.
>
>--

Pauli

I don't understand your fixation with trying to run command programs from Vedit, or even what you are trying to achieve.
It is far better to call vedit to do the task you want.

I usually use cmd files to call vedit e.g.:-
D:\vedit\vpw.exe -e -s2 -c'rinp("#ZTTemp\~ZTTag.inp") call_file(100,"wildfile.vdm")'

or

REM Call vedit to run DateConvert.vdm on the file, then append date to ~ChangeDate.cmd
Echo D:\vedit\vpw -q -w -g -s2 -ixxx -c"CALLF(39,'DateConvert.vdm') BS(BX) GP(EOL_Pos) RI(33)" %%1 -b D:\Temp\~ChangeDate.cmd 1>> D:\Temp\~ChangeDateBat.cmd

I often use vedit to build cmd files which are then executed

It can be a little challenging to stop the command processor converting reserved characters.

Have you tried using the Windows command escape character '^' in front of '>'

You may also try 1> for stdio or 2> for stderr.

 


Topic: Re: System() call (3 of 9), Read 22 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Friday, April 11, 2008 12:10 PM

At 05:55 AM 4/11/2008, you wrote:
>From: "Pauli Lindgren"
>
>I have been trying to call an external Windows program from Vedit using system() command, but it does not work.
>
>My macro builds DOS command in text register pointed by #53. Then it is executed with command
>System(@(#53))
>
>The command may be for example as follows (directly pasted from the text register):
>"C:\Program Files\Aspell\bin\aspell" pipe <"c:\vedit\USER-MAC\wildfilew.txt" >"C:\DOCUME~1\PAULIL~1\LOCALS~1\Temp\VeditTmp\aspell.out"

You need to use the "DOS" option since you need a "shell". However the DOS option limits the length of the entire command to less than about 120 chars.
I have not tested this, but perhaps preceding the command with "cmd" (and some cmd options) would work without the "DOS" option.

Ted.

 


Topic: Re: System() call (5 of 9), Read 24 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Friday, April 11, 2008 04:40 PM

On 11.04.2008 18:41 Ted Green wrote:

> However the DOS option limits the length of the entire command to
>less than about 120 chars.

As workaround for that limitation I did this in my version of COMPDIR.VDM:

//if (Is_WinNT) {
// Sys('"|@(15)"',DOS+SIMPLE+OK+SUPPRESS)
//} else {
// Sys('|@(15)',DOS+SIMPLE+OK+SUPPRESS)
//}
//
// Unfortunately the above syntax with Sys("|@(15)...) fails on long
strings (~100 characters).
// This is an old DOS limitation.
//
// Fortunately the DOS box itself seems to have no such limit (tested with Win2000 so far).
//
// So the following commands will work even with long paths:
//
Reg_Save(15, "|(VEDIT_TEMP)\COMPDIR$.BAT", OK)
Sys("|(VEDIT_TEMP)\COMPDIR$.BAT",DOS+SIMPLE+OK+SUPPRESS)
File_Delete("|(VEDIT_TEMP)\COMPDIR$.BAT", OK+NOERR)


Christian

 


Topic: Re: System() call (6 of 9), Read 24 times
Conf: VEDIT Macro Language Support
From: Pauli Lindgren
Date: Saturday, April 12, 2008 10:24 AM

On 4/11/2008 4:40:18 PM, Christian Ziemski wrote:
>
>Reg_Save(15,"|(VEDIT_TEMP)\COMPDIR$.BAT", OK)
>Sys("|(VEDIT_TEMP)\COMPDIR$.BAT",DOS+SIMPLE+OK+SUPPRESS)
>File_Delete("|(VEDIT_TEMP)\COMPDIR$.BAT", OK+NOERR)

Thanks, this seems to do the trick.

Of course, using a BAT file makes the calling of external programs even more slow and clumsy. Perhaps the max length of command line in Vedit could be increased?

However, it would be nice to be able to call functions from external DLL's from macro language. Or at least to use pipe interface as in vi.

--
Pauli

 


Topic: Re: System() call (7 of 9), Read 24 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Saturday, April 12, 2008 10:41 AM

on 12.04.2008 16:28 vedit-macro-language Listmanager wrote:
> From: "Pauli Lindgren"
>
> Perhaps the max length of command line in Vedit could be increased?

As far as I know that's not a limitation of VEDIT but of the DOS/Windows
interface called internally.

Christian

 


Topic: Re: System() call (8 of 9), Read 24 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Saturday, April 12, 2008 11:05 AM

At 10:47 AM 4/12/2008, you wrote:
>From: "Christian Ziemski"
>
>on 12.04.2008 16:28 vedit-macro-language Listmanager wrote:
>> From: "Pauli Lindgren"
> >
> > Perhaps the max length of command line in Vedit could be increased?
>
>As far as I know that's not a limitation of VEDIT but of the DOS/Windows
>interface called internally.

That is correct. Ask Bill Gates to increase it; I'm sure he will. ;-))

Ted.

 


Topic: Re: System() call (9 of 9), Read 21 times
Conf: VEDIT Macro Language Support
From: Pauli Lindgren
Date: Sunday, April 13, 2008 04:34 PM

On 4/12/2008 11:05:10 AM, Ted Green wrote:
>At 10:47 AM 4/12/2008, you wrote:
>>From: "Christian Ziemski"
>>
>>As far as I know that's not a limitation of VEDIT but of the DOS/Windows
>>interface called internally.
>
>That is correct. Ask Bill Gates to
>increase it; I'm sure he will. ;-))

I don't get it. There is no 120 character limit in command line in DOS window. Only when called from Vedit.
As I said, the command works fine when entered in DOS window directly, and it works when called from BAT.

--
Pauli

 


Topic: Re: System() call (4 of 9), Read 21 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Friday, April 11, 2008 03:46 PM

On 11.04.2008 11:55 Pauli Lindgren wrote:
>
> I have been trying to call an external Windows program from Vedit using system() command, but it does not work.
>
> My macro builds DOS command in text register pointed by #53. Then it is executed with command
> System(@(#53))
>
> The command may be for example as follows (directly pasted from the text register):
> "C:\Program Files\Aspell\bin\aspell" pipe <"c:\vedit\USER-MAC\wildfilew.txt" >"C:\DOCUME~1\PAULIL~1\LOCALS~1\Temp\VeditTmp\aspell.out"

Pauli:

you may have a look at the VEDIT macro COMPDIR.VDM for example.
It uses the Sys() command too. With redirections.

E.g. in line 745: Sys('"|(15)"', DOS+SIMPLE+OK+SUPPRESS)
Text register 15 contains the command to be executed, with long
filenames in double quotes!

The strange syntax with double and single quotes above is intended and
seems to be necessary!


Christian