Re: [OT] Accepting files (question)



MikeC escribió:
Good Folk,

I have written a parser program that operates on one or more files to produce an output file. It takes an input file, parses it (with the help of other files if they are given) and produces an output file.
The way I operate the program under Windows XP is to make a shortcut icon to my program on the task bar, then I select the input file(s) with Wndows Explorer, drag it (or them symoltaneously) onto the shortcut icon, and drop them. The filenames are passed exactly as if I had typed them all on the command line...

myparser d:\path_1\file_1 d:\path_2\file_2

... and the filenames are placed in argv[n]. No problems there - it works fine.

I have used the same technique on several other programs too. It's a nice way of operating a DOS program from Windows.

I want to write a simple file encryption program that uses a one-time pad. This technique is very secure, as long as nobody gets hold of the key - and therein lies the snag. I want to use another file on the PC as a key, but I don't want to say "Input key ... Browse", as that makes it obvious that it is on the PC somewhere. What I want to do is drop the document to be encrypted on the program's shortcut icon to fire it up, then have it wait till a second file (the key) is dropped on it, and have it detect and use that second file. I have played around with it a bit, but dropping a second file on the icon just starts a second image of my program, and while dropping the file into the DOS screen gives the right Windows indications (a '+' copy icon), I can't detect the file name. Can anybody shed some light on this please?

The following solution is probably off-topic here (not related to DJGPP). A shell script (dropargs.bat) can solve the problem. Create a shortcut for it and drop the file arguments on it one after the other.

The first time it creates a temporary driver script to later call your program with the dropped file as the first argument. The second time it actually calls your program with both arguments.

Edit the script to call your specific program instead of the generic "myprog". The directory where the script resides must be writeable. Executing the script without arguments clears the temporary driver (in case you change your mind after the first drop).

--- dropargs.bat------------------------------
@echo off

rem --- no args, clear temporary driver
if .%1.==.. (
if exist %~dp0dropargs~.bat del %~dp0dropargs~.bat
exit /B
)

rem --- first arg, create a temporary driver
if not exist %~dp0dropargs~.bat (
echo myprog %1 %%1 > %~dp0dropargs~.bat
exit /B
)

rem -- second arg, execute via the temporary driver
call %~dp0dropargs~.bat %1
del %~dp0dropargs~.bat
----------------------------------------------


I have recently downloaded Notepad++, and I can't sing its praises highly enough. It's a terrific piece of work - and the comparison plugin has saved me a lot of time already and made me look impressive in the eyes of my colleagues - but what I wanted to say is that it operates in the way I said. Drop a text file on it, and it starts up and displays the text. Drop a second one on it while it is running, and it opens a new tab and displays the second file. Admittedly, it is compiled by a compiler that is made for Windows, not one that is made for DOS, but I'm sure DJGPP has a way, if somebody can tell me.

--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
.



Relevant Pages

  • Re: [OT] Accepting files (question)
    ... The way I operate the program under Windows XP is to make a shortcut icon ... it detect and use that second file. ... A shell script can solve the problem. ... The first time it creates a temporary driver script to later call your ...
    (comp.os.msdos.djgpp)
  • Accepting files (question)
    ... other files if they are given) and produces an output file. ... The way I operate the program under Windows XP is to make a shortcut icon to ... till a second file is dropped on it, and have it detect and use ...
    (comp.os.msdos.djgpp)
  • RE: Compare two files and output results to third
    ... The script actually works - another part of the script was performing a test ... second field from the second file and then output the ... contents of the first file and then second field from the second file. ... field is a list of values that will equal strFourth from First file ...
    (microsoft.public.scripting.vbscript)
  • Re: array values not visible outside while loop? scope issue?
    ... Can you please explain your script a bit so that I can ... The program will read the first file and then the second file ... awk is really great for processing files. ...
    (comp.lang.awk)
  • Re: Need a script to compare two files
    ... "Tom Lavedas" wrote: ... I am looking for a script to compare two files. ... Scan second file using the words from first file. ... strOut = strOut & data & vbCrLf ...
    (microsoft.public.scripting.vbscript)