Procedural Program Flow
-
As you know from his previous posts, Bernie's team terribly struggles with Object-Oriented Programming. Well, they received their Master degrees around 1990 when OOP just had crept into main stream (C++ was developed in 1979, and so it might have been to novel for learning it). So at least, they ought to know the older procedural style. Ehm, ...
Bernie found a batch file which calls one of their programs with a parameter -k. Now he was curious to find out where that was handled and what it meant. After all, anyone can immediately see what -k means. With a text search through all the source code, he found it:
public MainView() { string[] args = Environment.GetCommandLineArgs(); bool noBorder = false; foreach (string arg in args) { if (arg == "-k") { noBorder = true; } } if (noBorder) { WindowStyle = WindowStyle.None; } InitializeComponent(); }
Of course, it is not handled in static Main or in OnStartup - that's for whimps. Even with C#, command line arguments are global, and you can read them from anywhere by calling string[] args = Environment.GetCommandLineArgs();. So they do in the constructor of the main window of a WPF application.
Next, set a boolean variable to flase, iterate over all arguments, and if such an argument exactly is -k, set that boolean to true. Afterwards, check the boolean and set the WindowStyle of that window accordingly. And what about -K (uppercase K)? Bernie's colleagues won't care about such users.
You can shorten the code (and correct it at the same time) to
if (args.Contains("-k", StringComparer.OrdinalIgnoreCase)) { WindowStyle = WindowStyle.None; }
At least, Bernie learned the meaning of -k.
-
@BernieTheBernie said in Procedural Program Flow:
flase
-
@pie_flavor You are the frist to detect that.
-
But what if -K is used elsewhere for selecting bananas out of a list of fruits? You'll be setting the window style when all they wanted was bananas! Or more seriously, what if someone sets many flags at once, such as -rk?
-
@BernieTheBernie said in Procedural Program Flow:
@pie_flavor You are the frist to detect that.
Well, I saw it as well, but my activity response rate is low so just saw it now.
-
@pie_flavor said in Procedural Program Flow:
flavor
-
@cvi no u
-
@cvi are you saying @pie_flavour can't spell his own name?
-
@Jaloopa No, it's just Brit-proof.
-
@Kian said in Procedural Program Flow:
what if someone sets many flags at once, such as -rk?
Found the Linux user.
-
What if someone sets flags using forward slash: /k ?
(found the MS-DOS user)
-
@BernieTheBernie said in Procedural Program Flow:
And what about -K (uppercase K)? Bernie's colleagues won't care about such users.
I expect arguments that start with a "-" to be case sensitive. If it starts with a "/" I expect it to be case insensitive.
-
-
@Kian You could be right. After all, when they create such a mess, they could also add some Unix flavour to a Windows application.
-
@BernieTheBernie it's already using dashes instead of slashes. Why not go all the way then?
-
-
@Gąska Because they prefer a mess. Do not add some kind of unnecessary order to our applications.
-
@boomzilla Those numbers in the edges, what do they mean? Is it the line number for GOTO?
-
@BernieTheBernie probably.
-
@BernieTheBernie said in Procedural Program Flow:
And what about -K (uppercase K)?
He obviously comes from the Unix-style command line args! Case Matters!
-
@dcon said in Procedural Program Flow:
@BernieTheBernie said in Procedural Program Flow:
And what about -K (uppercase K)?
He obviously comes from the Unix-style command line args! Case Matters!
-K
should do the opposite of-k
if both are supported.
-
@ben_lubar
What about-ʞ
?
-
@Applied-Mediocrity said in Procedural Program Flow:
@ben_lubar
What about-ʞ
?....
....
.... The fuck?
-
@Tsaukpaetra Whatever passes for
font-family: monospace
in your phone (because of <code>) doesn't have the glyph for ʞ.
-
@Tsaukpaetra said in Procedural Program Flow:
The fuck?
Is the automatic reply anytime that keyboard passes
-
@Luhmann said in Procedural Program Flow:
@Tsaukpaetra said in Procedural Program Flow:
The fuck?
Is the automatic reply anytime that keyboard passes
🎹 🎡😂
-
-
@Luhmann said in Procedural Program Flow:
Is the automatic reply anytime that keyboard passes
I tried. It's okay. I missed the swiping.
-
-
@PleegWat I just realized many modern linux utilities also have more descriptive long options, whose names would likely be
--borderless
and--no-borderless
or slimilar.
-
@Applied-Mediocrity said in Procedural Program Flow:
@ben_lubar
What about-ʞ
?Struck out looking (not swinging).
-
-
@PleegWat said in Procedural Program Flow:
@Applied-Mediocrity said in Procedural Program Flow:
@ben_lubar
What about-ʞ
?Nah,
+k
The most insane thing about Bash.
Edit: except for all the other insane things about Bash.
-
@Gąska said in Procedural Program Flow:
@PleegWat said in Procedural Program Flow:
@Applied-Mediocrity said in Procedural Program Flow:
@ben_lubar
What about-ʞ
?Nah,
+k
The most insane thing about Bash.
Edit: except for all the other insane things about Bash.
I put on my robe and wizard hat.
Wait, wrong bash.
-
@boomzilla but it's still appropriate. Shell scripts are some of the deepest fucking magic I've seen in my life.
Inb4
-
@boomzilla said in Procedural Program Flow:
@Gąska said in Procedural Program Flow:
@PleegWat said in Procedural Program Flow:
@Applied-Mediocrity said in Procedural Program Flow:
@ben_lubar
What about-ʞ
?Nah,
+k
The most insane thing about Bash.
Edit: except for all the other insane things about Bash.
I put on my robe and wizard hat.
Wait, wrong bash.
<mage> what should I give sister for unzipping? <Kevyn> Um. Ten bucks? <mage> no I mean like, WinZip?
*** Now talking in #christian -Word_of_God- Welcome Abstruse to #christian I am a Bible Bot. For more info type: /msg Word_of_God !info <Abstruse> !kjv numbers 22:21 <Word_of_God> Numbers 22:21 -- And Balaam rose up in the morning, and saddled his ass, and went with the princes of Moab. - (KJV) *** SageRider sets mode: +b *!*@c211-30-208-111.rivrw3.nsw.optusnet.com.au *** Word_of_God was kicked from #christian by SageRider (Please dont Swear) <Abstruse> I know I'm never going to be able to come back in this channel again after this, but damn was it worth it to see that...
<Patrician|Away> what does your robot do, sam <bovril> it collects data about the surrounding environment, then discards it and drives into walls
<Sonium> someone speak python here? <lucky> HHHHHSSSSSHSSS <lucky> SSSSS <Sonium> the programming language
-
-
@Applied-Mediocrity said in Procedural Program Flow:
What if someone sets flags using forward slash: /k ?
(found the MS-DOS user)
I did that until relatively recently because 99.9% of all commands I used listed it with
/
in help, and I didn't even know-
is even an option on Windows
-
@Onyx said in Procedural Program Flow:
I did that until relatively recently because 99.9% of all commands I used listed it with
/
in help, and I didn't even know-
is even an option on WindowsCareful. I believe Windows system programs do understand both. CMD commands, however, accept only
/
(with/-
meaning "not to"). And PowerShell and most cross-platform programs accept only-
.
-
@ben_lubar said in Procedural Program Flow:
-K
should do the opposite of-k
if both are supported.GNU gpg lists public keys with -k and private keys with -K