Board index » delphi » CopyFile win32

CopyFile win32


2005-10-02 07:10:26 PM
delphi256
Hi
Can someone give me an exemple for this function.
I use it in that form:
Copyfile('c:\LecSoft\LsiGest\ModelBase.mdb',NomFichier,true);
It does work on one of my programme, butwith another I get the error
[Erreur] U_creation_dossier.pas(121): Instruction attendue, mais expression
de type 'LongBool' trouvée
instruction wanted but longbool expression find.
thanks
claude
 
 

Re:CopyFile win32

On Sun, 2 Oct 2005 13:10:26 +0200, "Claude" <XXXX@XXXXX.COM>
writes:
Quote
Hi

Can someone give me an exemple for this function.

I use it in that form:
Copyfile('c:\LecSoft\LsiGest\ModelBase.mdb',NomFichier,true);
It does work on one of my programme, butwith another I get the error
[Erreur] U_creation_dossier.pas(121): Instruction attendue, mais expression
de type 'LongBool' trouvée
instruction wanted but longbool expression find.
thanks
claude
There is a name clash between the CopyFile in the Windows.pas unit
(i.e. the Win32 API wrapper) and the one in SysUtils (a Delphi
internal version). Thus you should use the qualified name to assure
the needed mapping.
Regards from Germany
Franz-Leo
 

Re:CopyFile win32

What do you mean buy qualified.
I try Windows.Copyfile but it doesn't work
Grüße
claude
"Franz-Leo Chomse" <XXXX@XXXXX.COM>a écrit dans le message de
Quote
On Sun, 2 Oct 2005 13:10:26 +0200, "Claude" <XXXX@XXXXX.COM>
writes:

>Hi
>
>Can someone give me an exemple for this function.
>
>I use it in that form:
>Copyfile('c:\LecSoft\LsiGest\ModelBase.mdb',NomFichier,true);
>It does work on one of my programme, butwith another I get the error
>[Erreur] U_creation_dossier.pas(121): Instruction attendue, mais
expression
>de type 'LongBool' trouvée
>instruction wanted but longbool expression find.
>thanks
>claude

There is a name clash between the CopyFile in the Windows.pas unit
(i.e. the Win32 API wrapper) and the one in SysUtils (a Delphi
internal version). Thus you should use the qualified name to assure
the needed mapping.

Regards from Germany

Franz-Leo
 

Re:CopyFile win32

"Claude" <XXXX@XXXXX.COM>writes
Quote
What do you mean buy qualified.
I try Windows.Copyfile but it doesn't work
The version of CopyFile in the Windows unit is expecting PChar parameters,
not strings.
Try this Windows.CopyFile(PChar(source), PChar(dest), TRUE)
Dave White
 

Re:CopyFile win32

procedure TF_CreationDossier.Button1Click(Sender: TObject);
var NomFichierOrig,NomFichierDest:pchar;
s,v,chemin:string;
i:integer;
f:file;
begin {1}
v:= 'c:\LecSoft\LsiGest\ModelBase.mdb';
NomFichierOrig:=pchar(v);
s:='c:\LecSoft\Lsigest\'+Edit3.text+'.mdb';
NomFichierDest:=pchar(s);
Windows.Copyfile(NomFichierOrig,NomFichierDest,TRUE);
Still doesn't work I have the same message 'awaited instruction but LongBool
fund'
Regards
claude
"Dave White" <daveUNDERSCOREwhite@spectrachromDOTcom>a écrit dans le
message de news:4342a1cd$XXXX@XXXXX.COM...
Quote
"Claude" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...
>What do you mean buy qualified.
>I try Windows.Copyfile but it doesn't work

The version of CopyFile in the Windows unit is expecting PChar parameters,
not strings.

Try this Windows.CopyFile(PChar(source), PChar(dest), TRUE)

Dave White


 

Re:CopyFile win32

"Claude" <XXXX@XXXXX.COM>writes
Quote
procedure TF_CreationDossier.Button1Click(Sender: TObject);
var NomFichierOrig,NomFichierDest:pchar;
s,v,chemin:string;
i:integer;
f:file;

begin {1}

v:= 'c:\LecSoft\LsiGest\ModelBase.mdb';
NomFichierOrig:=pchar(v);
s:='c:\LecSoft\Lsigest\'+Edit3.text+'.mdb';
NomFichierDest:=pchar(s);

Windows.Copyfile(NomFichierOrig,NomFichierDest,TRUE);

Still doesn't work I have the same message 'awaited instruction but
LongBool
fund'

I just created a small app, added an edit box and cut and paste your code.
It compiles just fine.
When does the error occur? Your original post says line 121 - which line is
this in your code above?
 

Re:CopyFile win32

procedure TF_CreationDossier.Button1Click(Sender: TObject);
var NomFichierOrig,NomFichierDest:pchar;
s,v,chemin:string;
i:integer;
f:file;
begin {1}
Edit1.Text:='Création de la nouvelle base';
v:= 'c:\LecSoft\LsiGest\ModelBase.mdb';
NomFichierOrig:=pchar(v);
s:='c:\LecSoft\Lsigest\'+Edit3.text+'.mdb';
NomFichierDest:=pchar(s);
Windows.Copyfile(NomFichierOrig,NomFichierDest,TRUE);//////
ADOConnection2.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'+
'Data Source='+NomFichier+';Persist Security Info=False';
AdoConnection2.Connected:=true;
{Transfer des donnees du fichier parametre}
Edit1.Text:='Transfer de la base parametres...';
Edit1.Refresh; etc.etc.
///// the screen cursor stop here with the message expression awaited but
longbool find
The funny is that I get that problem since I updated my delphi 7
I really don't know what do do. I already try to take out one after another
the units but no change.
So if you have an idea where I can look at!
Regards and thanks
claude
"Dave White" <XXXX@XXXXX.COM>a écrit dans le message de
Quote
"Claude" <XXXX@XXXXX.COM>writes
news:4342aebf$XXXX@XXXXX.COM...
>procedure TF_CreationDossier.Button1Click(Sender: TObject);
>var NomFichierOrig,NomFichierDest:pchar;
>s,v,chemin:string;
>i:integer;
>f:file;
>
>begin {1}
>
>v:= 'c:\LecSoft\LsiGest\ModelBase.mdb';
>NomFichierOrig:=pchar(v);
>s:='c:\LecSoft\Lsigest\'+Edit3.text+'.mdb';
>NomFichierDest:=pchar(s);
>
>Windows.Copyfile(NomFichierOrig,NomFichierDest,TRUE);
>
>Still doesn't work I have the same message 'awaited instruction but
LongBool
>fund'
>

I just created a small app, added an edit box and cut and paste your code.
It compiles just fine.

When does the error occur? Your original post says line 121 - which line
is
this in your code above?


 

Re:CopyFile win32

"Claude" <XXXX@XXXXX.COM>writes
Quote

Windows.Copyfile(NomFichierOrig,NomFichierDest,TRUE);//////


///// the screen cursor stop here with the message expression awaited but
longbool find

So if you have an idea where I can look at!
Sorry, no idea at all - I can not see where the problem would be caused here.
Good Luck,
Dave
 

Re:CopyFile win32

"Claude" <XXXX@XXXXX.COM>skrev i en meddelelse
Quote
Edit1.Text:='Création de la nouvelle base';
v:= 'c:\LecSoft\LsiGest\ModelBase.mdb';
NomFichierOrig:=pchar(v);
s:='c:\LecSoft\Lsigest\'+Edit3.text+'.mdb';
NomFichierDest:=pchar(s);
Windows.Copyfile(NomFichierOrig,NomFichierDest,TRUE);//////
Try to change the last line to this:
Windows.Copyfile(PChar(v), PChar(s), TRUE);
Does that make any difference?
--
Finn Tolderlund
 

Re:CopyFile win32

No
I make a lot of error and thanks you all I correct them
I'll try to compile the unit alone and in the case of success may be I have
somethine incompatible with another unit and I 'll try to find out by delete
all the unit one by one. I keep you all inform.
Thank you all anyway. At least the function has now the right syntax
"Finn Tolderlund" <XXXX@XXXXX.COM>a écrit dans le message de
Quote

"Claude" <XXXX@XXXXX.COM>skrev i en meddelelse
news:XXXX@XXXXX.COM...
>Edit1.Text:='Création de la nouvelle base';
>v:= 'c:\LecSoft\LsiGest\ModelBase.mdb';
>NomFichierOrig:=pchar(v);
>s:='c:\LecSoft\Lsigest\'+Edit3.text+'.mdb';
>NomFichierDest:=pchar(s);
>Windows.Copyfile(NomFichierOrig,NomFichierDest,TRUE);//////


Try to change the last line to this:
Windows.Copyfile(PChar(v), PChar(s), TRUE);

Does that make any difference?
--
Finn Tolderlund