TIP: Click on subject to list as thread! ANSI
echo: delphi
to: ERIC SCHREIBER
from: MARTIN MAAT
date: 1997-06-25 18:43:00
subject: Loading files with spaces in names

Hallo Eric
 ES> Anyone know how to handle accepting long file names on the command line? 
 ES> Problem is, a *lot* of people have answered this, but I must have
 ES> not been clear with my original question, since they've all 
 ES> provided pretty much the same answer that's not relevant to my
 ES> problem.
 ES> What I'm trying to discover is how to accept a long file name on
 ES> the command line of MY program:
 ES> [...] when I double click "Read Me Now.txt" in explorer, I get 
 ES> error "File not found: Read". My program is parsing paramstr(1) 
 ES> ('Read') as unrelated to paramstr(2) ('Me') etc.
 ES> I guess what I'm looking for is someone to hand me code on a silver
 ES> platter.
Now chance!
 ES>  I hate the 'original thinking' part of programming :-)
Eh, are we real programmers or what? I'll give you some pointers.
First, reconstruct the entire set of parameters by concatenating all 
ParamStr's seperated with spaces. This should not be that hard to do. Then 
re-create your own TStringList with parameters, this time taking into account 
the quoted parameters. Somehow I feel there must be some sort of support for 
this already in either Delphi or the operating system, but we'll do it 
ourselves this time. That is, YOU will do it ourselves, I will give 
directions .
Take the string with parameters. Walk over it's characters, starting with the 
first... In retrospect, it might be easier after all to write some (untested) 
code:
procedure ParseParams;
var
  i, First :integer;
  procedure AddQuotedParam;
  begin
  
  end;
  procedure AddNormalParam;
  begin
  
  end;
begin
  First := 0;  i := 0;
  repeat 
    if PS[i] = '"' then AddQuotedParam;
    if PS[i] = ' ' then AddNormalParam;  inc(i);
  until PS[i] = chr(0);
end;
You fill in the blanks.
Groeten, Martin.
--- FMail/386 1.02
---------------
* Origin: -=[ E-mail: m_maat@knoware.nl .......... ]=- (2:286/420.1)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.