can wildcards be used in pascal? 
Author Message
 can wildcards be used in pascal?

Hi. I need some help with a program I'm writing (it's not a school
project, but may be of use to me in school later). What the program is
is a basic command line interpreter, and when i type eg 'cd \windows' to
change the directtory, i want to be able to use the chdir() proc to
change, but i think i would need to use wildcards to search the string?
(this probably doesn't make much sense, so here's the code so far) :

program cli;
uses crt,dos;
var
 s:string;
 cmd:string[79];
begin
 clrscr;
 getdir(0,s);   { get the current dir and place it in var s  }
 repeat
 write(s+'>');
 readln(cmd);
 if cmd='cd .' then   { this is where the wildcard is needed }
 begin
  {$I-}    { remove Pascal's error checking  }
   delete(cmd,1,3);    { to remove the 'cd ' }
   chdir(cmd);
   if IOResult<>0 then writeln('Dir doesn't exists');
  end;
  getdir(0,s);
  until cmd='exit;
end.

any help greatly appreciated

Thanks
James



Wed, 18 Jun 1902 08:00:00 GMT  
 can wildcards be used in pascal?

Quote:

>  if cmd='cd .' then   { this is where the wildcard is needed }

You can use Copy and Pos for this. Declare another string variable, say
"basecmd", and then:

basecmd := Copy(cmd, 1, Pos(' ', cmd)-1);

will set basecmd to the part of cmd before the first space.

Then you can just check if basecmd = 'cd', and similarly for other
commands.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using wildcards in Delphi SQL (ANSI 92-SQL) ?

2. Using Wildcard w/SQL in Pdox Tbles

3. Q: Using wildcards in Delphi 2.0. SQL queries

4. It's not bad canned meat...

5. IndexDefs - am I using the right property?

6. Losing File Handles - But I am not using Files

7. help for including units in main file (i am using BP7)

8. Am I using SQL right ?

9. which table am I using ?

10. Wildcards with GREP in PASCAL

11. I am looking for DOS based PASCAL

12. I Am Interested in Pascal for Windows

 

 
Powered by phpBB® Forum Software