[fpc-pascal] readonly variables

Howard Page-Clark hdpc at talktalk.net
Sat Nov 28 15:30:01 CET 2009

On Sat, 28 Nov 2009 15:07:42 +0100
Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:

> On Sat, 28 Nov 2009 14:58:26 +0100
> J├╝rgen Hestermann <juergen.hestermann at gmx.de> wrote:
> > > is it possible to set a variable in a programm as a readonly variable?

> Use the following:
> property MyVar: integer read FMyVar write SetMyVar;
> And in SetMyVar you can set flag and raise an exception if set for the
> second time.

If the value is known in advance and if no runtime alteration of the
variable is allowed you would of course declare the value as const
rather than var. But this may not fit your case?


More information about the fpc-pascal mailing list