UCMDs: using fields in a cmd-class
4 posts
• Page 1 of 1
UCMDs: using fields in a cmd-class
I tried to define a field in a class which is used to implement a ucmd:
I also tried making the field private, but both variants cause the err-msg: "Cannot access instance field from within a class"
What's wrong?
:Field Public ReadOnly FCHomeDir←'c:\temp\'
I also tried making the field private, but both variants cause the err-msg: "Cannot access instance field from within a class"
What's wrong?
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
Re: UCMDs: using fields in a cmd-class
I was going to suggest the word "Shared" as opposed to the word "Instance" that's implied by default 'til I remembered that I don't actually do this stuff so I deleted it.
But you could give it a try.
But you could give it a try.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: UCMDs: using fields in a cmd-class
Thanks, that's it! :-)
-
MBaas - Posts: 156
- Joined: Thu Oct 16, 2008 1:17 am
- Location: Gründau / Germany
Re: UCMDs: using fields in a cmd-class
Yes, Phil is right as you found out.
Scripts can contain a class or a namespace.
Since no instance is taken from the class and that the code is hidden, there is no benefit in using a class.
In fact it is rather the opposite: since classes hide everything you are restricted when looking at objects within it.
For example, the command ]display cannot be used to show you the contents of expressions involving fields in your command (or your command has stopped and you wish to see their contents manually). Same with ]umonitor that cannot be used on fns in classes, even if public.
In general I recommend to use namespaces instead of classes.
In 13.1 command ]UNEW has been modified to generate a namespace.
Scripts can contain a class or a namespace.
Since no instance is taken from the class and that the code is hidden, there is no benefit in using a class.
In fact it is rather the opposite: since classes hide everything you are restricted when looking at objects within it.
For example, the command ]display cannot be used to show you the contents of expressions involving fields in your command (or your command has stopped and you wish to see their contents manually). Same with ]umonitor that cannot be used on fns in classes, even if public.
In general I recommend to use namespaces instead of classes.
In 13.1 command ]UNEW has been modified to generate a namespace.
- DanB|Dyalog
4 posts
• Page 1 of 1
Return to Source Code Management
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group