Page 1 of 1
Alternative way to write a property from enumeration
Posted: Thu Mar 26, 2015 2:14 pm
by PGilbert
If you do the following you get a Window:
⎕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
Re: Alternative way to write a property from enumeration
Posted: Thu Mar 26, 2015 3:15 pm
by norbertjurkiewicz84
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.aspxI've been using case #1 in all my WPF, WinForms and Excel OLE code. I find it to be the most readable.
Norbert
Re: Alternative way to write a property from enumeration
Posted: Tue Mar 31, 2015 11:29 pm
by PGilbert
Could someone help me with this DFN function. If I do the following it does not work:
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.
Re: Alternative way to write a property from enumeration
Posted: Wed Apr 01, 2015 8:04 am
by MikeHughes
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
Re: Alternative way to write a property from enumeration
Posted: Wed Apr 01, 2015 12:26 pm
by PGilbert
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.
Re: Alternative way to write a property from enumeration
Posted: Wed Apr 01, 2015 9:19 pm
by DanB|Dyalog
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
Code: Select all
'win.Visibility'{⍎⍕⍺'←'⍺'.'⍵}'Hidden'