I am getting the error in
class property FilesTypesToSearch: string read get_FilesTypesToSearch;
in the class declaration given below
venkatesh
***************************************************
Site = class
strict private
class var
m_ApplicationPath: string;
public
constructor Create;
class function get_FilesTypesToSearch: string;
class function get_DynamicFilesTypesToSearch: string;
class function get_BarredFolders: string;
class function get_BarredFiles: string;
class function get_EnglishLanguage: Boolean;
class function get_ApplicationPath: string;
procedure set_ApplicationPath(Value: string);
class property FilesTypesToSearch: string read
get_FilesTypesToSearch;
class property DynamicFilesTypesToSearch: string read
get_DynamicFilesTypesToSearch;
class property BarredFolders: string read get_BarredFolders;
class property BarredFiles: string read get_BarredFiles;
class property EnglishLanguage: Boolean read get_EnglishLanguage;
class property ApplicationPath: string read get_ApplicationPath
write set_ApplicationPath;
end;
************************************************************8
That's one of these Win32-lookalike things that is biting you here.
You have to mark a class method as "static" to have a normal CLR static method.
Otherwise D.Net will emit a hidden parameter that takes the metaclass...
> >
>
> That's one of these Win32-lookalike things that is biting you here.
> You have to mark a class method as "static" to have a normal CLR static
> method.
> Otherwise D.Net will emit a hidden parameter that takes the metaclass...
When i try I get the error
[DCC Error] uSite.pas(19): E2376 STATIC can only be used on non-virtual
class methods
Venkatesh
Well, of course. Even though D.Net tries very hard to hide a lot of what makes up .Net from you, in
the end it still has to follow its rules.
.Net has no notion of metaclasses, and the way they are impleemnte in d.Net reuire them to be passed
as a parameter to non-static class methods.
You cannot use "self" inside a static method, you cannot call non-static class methods as well. As I
said, non-static class methods require the meta class to be passed as a hidden parameter.
Static methods are stateless, and therefor they have no metaclass reference to pass to other class
methods. Hence not being able to call them.
I have this problem with Delphi 6 : try getFilesTypesToSearch instead of
get_FilesTypesToSearch
Lionel
"VT Venkatesh" <ve...@vsnl.com> a écrit dans le message de news:
488a...@newsgroups.borland.com...
I don't think that this should be a problem in Delphi6, but it could be one in Delphi.Net.
In .Net, a property XYZ consists of nothing more than the methods get_XYZ and set_XYZ. (both with the
specialname flag)
It could very well be the case, that D.Net can't handle it when the setter/getter have these names.
So you might have to remove the underscores.
I haven't touched D.Net for too many years, so it could be that it can handle this situation now.
> I am getting the following error
> E2355: Class property accessor must be a class field or class static
> method
Hi Venkatesh,
I think you need to add static to the end of all the getters and setters
class function get_FilesTypesToSearch: string;static;
class function get_DynamicFilesTypesToSearch: string;static;
class function get_BarredFolders: string;static;
class function get_BarredFiles: string;static;
class function get_EnglishLanguage: Boolean;static;
class function get_ApplicationPath: string; static;
class procedure set_ApplicationPath(Value: string);static;
Access to the class var in the getter and setter would be like this
result:=Site.m_ApplicationPath;
Cheers,
John
--
Blog: http://blog.moshine.com/
> May be it is because Delphi doesnt like get_ and set_
>
> I have this problem with Delphi 6 : try getFilesTypesToSearch
> instead of get_FilesTypesToSearch
>
Hi Lionel,
If you don't use the get_ and set_ pattern Delphi.Net will generate
them for you
ie
property SomeProperty:string read FSomeProperty write FSomeProperty;
If you open up reflector you will see these methods. You can also call
them yourself
instance.set_SomeProperty('John');
Or you can do it yourself
procedure set_SomeProperty(Value:string);
function get_SomeProperty():string;
published
property SomeProperty:string read get_SomeProperty write
set_SomeProperty;
under Delphi BDS 2006 do not use get_ nor set_ or you will get errors.
so, under Delphi BDS 2006 : write getFilesTypesToSearch instead of
get_FilesTypesToSearch
i guess the same problem will occur on Delphi 2007.
Lionel
"Lionel" <Lionel...@atscan.fr> a écrit dans le message de news:
488b...@newsgroups.borland.com...