[fpc-pascal]building a command string

DONALD PEDDER jims_son at jedi.apana.org.au
Wed Sep 24 05:33:27 CEST 2003


> Exec(GetEnv('COMSPEC'), '/c copy '+ParamStr(1)+' '+ParamStr(1)+'.bak /v');

   Now THIS is what I needed to know! Thank you. :-) I originally tried a
writeln kind of syntax - '/c copy ',paramstr(1),' ',paramstr(1),'.bak /v'
- but that didn't work, hence my other attempts to build the string. I
didn't know about the syntax you've told me - all I have to do is use a
plus instead of a comma.
   What other circumstances would I use this syntax? Is it like a
back-apostrophe in Unix - evaluate this part before the rest?


> There's no need to even use Pascal for this kind of thing. You could use
> a .bat file:
> copy %1 %1.bak /v

   Right, and with my old programs - which had hard-coded filenames -
that's what I had to do. I had to use a batch file to rename the
appropriate files to the names the program was expecting, and then rename
them again at the end. What I'm fiddling with now is moving that
functionality into the program, so that I have JUST an exe, instead of an
exe and a bat (this is one of the cool things about FPC).
   As I said, I know the functionality is there in the compiler for me to
PROGRAM that stuff in, but it's much easier if I can just directly
transfer what's in my bat file into the program and substitute paramstr as
appropriate - that way I'm not re-inventing the wheel.

thanks,
   DONALD.

E-mail               - donaldp at au.mensa.org
BIG DON's Home-page  - http://jedi.apana.org.au/~jims_son
Pedder Passer Rating - http://jedi.apana.org.au/~jims_son/PPR
AusNFL mailing-list  - http://jedi.apana.org.au/mailman/listinfo/ausnfl

"What I always wanted is to be accepted, not understood" - MAN RAY




More information about the fpc-pascal mailing list