I am afraid you mistake a function parameter as a variable declared in a
function.

The QUOTE is talking about the const parameter e.g. procedure myProc(const
par1 : integer);

Your example shows that you are talking about the constant variable defined
in a procedure/function.

Different topic actually.

-----Original Message-----
From: Alistair George [mailto:[EMAIL PROTECTED]
Sent: Friday, 13 June 2003 3:50 p.m.
To: Multiple recipients of list delphi
Subject: [DUG]: Non-global Constants in a function


In the past I have used const in a proc or func to allow re-entering the
routine
later  to use the same variable value. But reading the following help it
seems I
am doing the wrong thing. Should I be using a global variable instead?

QUOTE
A  constant  (const)  parameter  is like a local constant or read-only
variable.
Constant  parameters  are  similar  to  value  parameters, except that you
cant
assign  a  value  to  a  constant  parameter  within  the body of a
procedure or
function,  nor can you pass one as a var parameter to another routine. (But
when
you  pass  an object reference as a constant parameter, you can still modify
the
objects properties.)

eg
function Tmainform.ParseAddFiles(FName: string; Recurse: boolean): string;
const PrevDIR: string = '
';
begin
  result := '';
  if pos('*.*', fname) > 0 then
  begin
    PrevDIR := extractfiledir(fname);  //This remains until redefined??
    result := Fname;
    exit;
  end;
  if extractfiledir(fname) = prevdir then //this file is already in *.* so
omit
  begin
    result := '';
    exit;
  end;
end;

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal
For more information please visit www.marshalsoftware.com
#####################################################################################
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to