I've made programs both for Visual Basic and for Delphi 4. And there are
some functions in
Visual Basic that doesn't exist in Delphi (and vise versa).
The only thing I really long for in Delphi is a possibility to use wildcards
and pattern-matching in
strings.
Remember when you could write "Dir *.exe" in DOS and you'd get all the files
matching that
criteria? Well, this is easy in Visual Basic. You'd just write "IF AnyString
LIKE "*.EXE" THEN ...."
Does anyone have code for this in Delphi, or does it exist but somehow i've
missed it?
I'd apprechiate any help.
Alternatively there is a wildcard routine that comes in the strutils unit in
the RxLib library.
Hans Olav Stjernholm <hans...@hep.no> wrote in message
news:7r03i1$q3...@forums.borland.com...
Well, there isn't a LIKE keyword in Delphi, but you can use the following:
IF Pos(AnyString, '.EXE') > 0 THEN ...
See Delphi Help for the function POS for more details.
Hope it helps.
Delfim
ret:=findfirst('c:\windows\*.exe',searchrec,faany);
Hans Olav Stjernholm <hans...@hep.no> wrote in message
news:7r03i1$q3...@forums.borland.com...
> Hello!
>
> I've made programs both for Visual Basic and for Delphi 4. And there are
> some functions in
> Visual Basic that doesn't exist in Delphi (and vise versa).
>
> The only thing I really long for in Delphi is a possibility to use
wildcards
> and pattern-matching in
> strings.
>
> Remember when you could write "Dir *.exe" in DOS and you'd get all the
files
> matching that
> criteria? Well, this is easy in Visual Basic. You'd just write "IF
AnyString
> LIKE "*.EXE" THEN ...."
>
HyperString - Freeware at http://efd.home.mindspring.com/tools.htm
--
Ernie Deel, EFD Systems
-------------------------------------------------
Any sufficiently advanced bureaucracy
is indistinguishable from molasses.
Figured I would add this since nobody gave u a full example.
Here is something that I wrote to delete any file based on a file mask.
Notice how u must loop through all the files in the directory looking
for
the ones that match your file mask. So if I wanted to delete all EXE
files
in the directory I would do this:
dkyDeleteFiles('c:\temp', '*.EXE');
{*******************************************************************************
* Delete All Files
*
* Note: This will not delete READ ONLY files or directories.
*******************************************************************************}
function dkyDeleteFiles(FilePath, fileMask : String): Boolean;
var
DeleteFilesSearchRec: TSearchRec;
searchResult : integer;
begin
Result := True;
if NOT DirectoryExists(FilePath) then Exit;
searchResult := FindFirst(FilePath + '\' + fileMask, faAnyFile,
DeleteFilesSearchRec);
try
// Loop through all the file and directory names
while (searchResult = 0) do
begin
// Only Delete files .. this avoids directories
if ( (DeleteFilesSearchRec.Attr AND faDirectory) = 0 ) then
begin
if NOT (DeleteFile(PChar(FilePath + '\' +
DeleteFilesSearchRec.Name))) then
Result := FALSE;
end;
searchResult := FindNext(DeleteFilesSearchRec);
end;
finally
FindClose(DeleteFilesSearchRec);
end;
end;
Hope this helps.
Dave
Hans Olav Stjernholm wrote:
>
> Hello!
>
> I've made programs both for Visual Basic and for Delphi 4. And there are
> some functions in
> Visual Basic that doesn't exist in Delphi (and vise versa).
>
> The only thing I really long for in Delphi is a possibility to use wildcards
> and pattern-matching in
> strings.
>