@iceman - that's torture to a room full of geeks! :p
I don't even have delphi, and it would be needed to do any form of testing,
can you at least give me the full syntax that your using, so i can see the quote mark usage on the whole string...
i'll run it through my quote stripper/parser and see what it comes back with.
Escaping the second set of each pair of double quotes with a \ seems to work for me.
Originally Posted by nickbro
/PARAMS:\"" subreportfilter=""True\""> Mark date Date MarkDateBefore 2011-06-09T00:01:00 \"" subreportfilter=""True\""> Mark date Date MarkDateAfter 2010-08-15T23:59:00
ArgsTest.exe can be downloaded from here.
Every second pair! I must admit that was one combination I didn't try.
I'll try that out with the real thing and post back.
The full line I would like to pass to CreateProcess to avoid making a file is below. It refers to a report based on student with a sub report of attendance marks and (following your comments from a much earlier post) with two parameters for the start date and end date with prompt names of MarkDateAfter and MarkDateBefore. I generate these dates using code, change them to a string and, at the moment, embed them into the short bit of xml that gets written to a file. What I have below is preferable though if I can get the format right.
Oh, and the actual file paths will be full UNC paths containing double backslashes and Dollar signs, this example is from my development machine.
"C:\Program Files\sims\sims .net\commandreporter.exe" /USER:"d" /PASSWORD:"x" /REPORT:"SITKA_Attendance" /OUTPUT:"K:\Howards Documents\SITKA\jobs\Attendance\Delphi version\delphi code version 2\init\SITKA_Attendance.csv"
Can I ask why you are avoiding creating a temp file to do the job? It'd save a heck of a lot of faffing with very little drawback that I can see?
I've had no end of hassle with different microsoft office versions / invalid registry values / unregistered components / changed or incorrect folder and user permissions preventing me from doing what I want to do with my programs. Consequently I have re-coded (am in the process of re-coding) all my analysis systems from a mixture of Access and Excel with some VBA thrown in to stand alone, fully compiled programs written in Delphi. As you can see from my earlier post, once again folder permission reared their head when I wrote out the xml file to the same folder from which I was running my program and yet command reporter was unable to then read from that folder due to permissions and the credentials under which CR appeared to be running.
Therefore I am trying to limit as much as possible any reading and writing of files that is not absolutely necessary. If I can get away with one single SIMS export (OK a few exports) and then do everything else via my program then I know I'm in complete control and not at the mercy of network changes and software upgrades performed by sombody else.
I couldn't get it to work.
The whole /PARAMS: value must also be in double quotes as it contains spaces and CreateProcess delimits by spaces.
And got the following passed into commandreporter (actually a dummy version of CR that simply prints out its parameters)
/PARAMS:""Mark date Date MarkDateBefore2011-06-11T00:01:00Mark date Date MarkDateAfter2010-08-15T23:59:00\""'
Did you get your result passing the string to CreateProcess() which then called argstest with the parameter or did you call argstest directly. Obviously there is quite a difference as there is only one layer of parsing with the latter whereas with createprocess() the line gets mangled before argstest even gets to see it.
Paramcount = 15
parameters passed are:
0: C:\Program Files\sims\sims .net\commandreporter.exe
4: /OUTPUT:K:\Howards Documents\SITKA\jobs\Attendance\Delphi version\delphi code version 2\init\SITKA_Attendance.csv
After a lot of trial-and-error, this is the best I can come up with (the PARAMS bit has double double quotes). :(
argstest "\"C:\Program Files\SIMS\Sims .net\CommandReporter.exe"\" /USER:"\"d"\" /PASSWORD:"\"x"\" /REPORT:"\"SITKA_Attendance"\" /OUTPUT:"\"K:\SITKA_Attendance.csv"\" /PARAMS:\"""\""Mark dateDateMarkDateBefore2011-06-09T00:01:00Mark dateDate MarkDateAfter2010-08-15T23:59:00"\""""
Thanks for your efforts Arthur but it still gets mangled when being pre-processed by CreateProcess(), which appears to do escape character conversions all of its own before even CR sees it and still splits on spaces and refuses to send out any quote chars.
Ah well, you have pointed me in the right direction. Another project to put on my laptop for the summer holidays!
Instead of escaping doesn't it work by interchanging single and double quotes depending on what level you are at? So start with double around the lot then the next set use single then after that double again.. either that second double works or closes the first lot and starts the second lot in which case you can start with single again.
Not sure that made sense :s
What about putting the string into a string variable and then passing that in as a parameter is that doable..? either the whole string or just the params part..