Alternative way to write a property from enumeration
6 posts
• Page 1 of 1
Alternative way to write a property from enumeration
If you do the following you get a Window:
if you want to change the visibility property of the window, one way of doing it is like this:
An alternative way is:
My question is: Is there another way even shorter that is possible ?
Thanks,
Pierre Gilbert
⎕USING ← 'System.Windows,WPF/PresentationFramework.dll'
win ← ⎕NEW Window
if you want to change the visibility property of the window, one way of doing it is like this:
win.Visibility ← win.Visibility.Hidden ⍝ case 1
An alternative way is:
win.(Visibility ← Visibility.Hidden) ⍝ case 2
My question is: Is there another way even shorter that is possible ?
win.Visibility.( ← .Hidden) ⍝ Does not work but in this style
Thanks,
Pierre Gilbert
-
PGilbert - Posts: 440
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: Alternative way to write a property from enumeration
I'm sure you can assign the Visibility enumeration values directly. I'd probably stay away from this in case MS. ever decided to change them...
https://msdn.microsoft.com/en-us/librar ... 10%29.aspx
I've been using case #1 in all my WPF, WinForms and Excel OLE code. I find it to be the most readable.
Norbert
https://msdn.microsoft.com/en-us/librar ... 10%29.aspx
I've been using case #1 in all my WPF, WinForms and Excel OLE code. I find it to be the most readable.
Norbert
(It's the little things that make the difference :-)
-
norbertjurkiewicz84 - Posts: 62
- Joined: Mon Nov 01, 2010 7:26 pm
Re: Alternative way to write a property from enumeration
Could someone help me with this DFN function. If I do the following it does not work:
which should be the same as the following that is working:
Thanks in advance.
win.Visibility←win.Visibility.Collapsed
win.Visibility{⍺←⍺.⍎⍵}'Hidden'
win.Visibility
Collapsed
which should be the same as the following that is working:
win.Visibility←win.Visibility.⍎'Hidden'
Thanks in advance.
-
PGilbert - Posts: 440
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: Alternative way to write a property from enumeration
Hi Pierre
the ⍺ is evaluated so you would have had something like
Win.visibility←Collapsed.⍎'Hidden'
I haven't tried it but I think it will involve
'Win.Visibility'{⍺,'.',⍺,'←',⍵}'Hidden'
Morten and I were talking this week about how nice
win.Visibility.←Hidden
to work like var+←1
would be BUT he went a little white and decided using . like this was a step a too far
the ⍺ is evaluated so you would have had something like
Win.visibility←Collapsed.⍎'Hidden'
I haven't tried it but I think it will involve
'Win.Visibility'{⍺,'.',⍺,'←',⍵}'Hidden'
Morten and I were talking this week about how nice
win.Visibility.←Hidden
to work like var+←1
would be BUT he went a little white and decided using . like this was a step a too far
-
MikeHughes - Posts: 86
- Joined: Thu Nov 26, 2009 9:03 am
- Location: Market Harborough, Leicestershire, UK
Re: Alternative way to write a property from enumeration
Hello Mike, you are answering my question. I wanted to make sure that I was not missing a contraction like you said win.Visibility.←Hidden or win.Visibility.(←Hidden) that could have made sense in the dot notation of Dyalog somehow. Using a DFN is not simplifying the code, so I will forget about that also.
Thanks again.
Thanks again.
-
PGilbert - Posts: 440
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: Alternative way to write a property from enumeration
One of the problems here is that the construct "{⍺←..." will never be executed because ⍺ already has a value.
Then only way I can see this work is by doing
Then only way I can see this work is by doing
- Code: Select all
'win.Visibility'{⍎⍕⍺'←'⍺'.'⍵}'Hidden'
- DanB|Dyalog
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group