Sharpe's Opinion

Sunday, 14th Dec, 2008

Comments

Wow. I, sir, salute you.

 

Hmm. Will this descend into a sort of “how many languages can we write this in?” fest? I’ll see your Ruby and raise you a Perl.

#!/usr/bin/perl -w use strict; sub yn { $_ = shift; print; $_ = ; /y/i }; if ((yn "Do you have a problem? (y/n): ") && (!yn "Can anyone else help? (y/n): ") && (yn "Can you find them? (y/n): ")) {print "Maybe you can hire… the A-Team!\n";} else {print "You Cannot Hire the A-Team.\n"};

 

Gick. It got mangled by the formatter! You need a line break after the first line.

And thinking about it, maybe I should have put the (y/n): within the function. And made that regular expression /[yj]/i for compatibility with German-speakers. Or /[yjos]/i for compatibility with German, French and Spanish-speakers.

Nah, s*d it ….. I can always put some of those features into the next release. And if I can’t think of anything to add to the next-plus-one release, then I’ll just hold something back from the next one.

 

Javascript version is slightly fudgy:

if (confirm(“Do You Have A Problem?”) && !confirm(“Can Anyone Else Help?”) && confirm(“Can You Find Them?”)) {
alert(“Maybe You Can Hire… The A-Team”);
}
else alert(“You Cannot Hire The A-Team”);

The issue is that ‘Confirm’ gives you a choice of ‘OK’ or ‘Cancel’ rather than ‘yes’ or ‘no’

 

…And just to demonstrate the inadequacies of AppleScript…