|
|
That might be better as a Tip.
|
|
|
|
|
Thanks - but how do I post it?
Mike - typical Euro-American (white guy).
onagerware.com
tarkingtontower.org
Thomas Mann - "Tolerance becomes a crime when applied to evil."
As American as: hot dogs, apple and Sarah Palin.
|
|
|
|
|
Go through this and then, Menu - articles - Submit an Article or Tip.
Programmer : A machine that converts coffee into code !
|
|
|
|
|
|
Sounds like you need to swop the positions of the keyboard and touchpad.
There are a few laptops that do this. One I found was the Acer Aspire R7. Good luck in your search.
|
|
|
|
|
I terminated the touch pad on my laptop (with extreme prejudice) via the BIOS.
Software Zen: delete this;
|
|
|
|
|
I spent over an hour yesterday trying to figure out why reading in an encrypted configuration file created in another program produced the wrong results. First try looked like this:
Using sr As New IO.StreamReader(strPath)
which didn't work, so I tried the next overload that takes an encoding parameter. I tried all of them with no joy until I tried this one:
Using sr As New IO.StreamReader(strPath, System.Text.Encoding.Default)
which worked perfectly.
"Go forth into the source" - Neal Morse
|
|
|
|
|
The default behaviour is to attempt to detect the encoding based on the Byte Order Mark[^] within the stream's content. If no BOM is found, it falls back to UTF8.
It's mentioned in the remarks on the class:
StreamReader defaults to UTF-8 encoding unless specified otherwise, instead of defaulting to the ANSI code page for the current system. UTF-8 handles Unicode characters correctly and provides consistent results on localized versions of the operating system. If you get the current character encoding using the CurrentEncoding property, the value is not reliable until after the first Read method, since encoding auto detection is not done until the first call to a Read method.
And on the constructor:
This constructor initializes the encoding to UTF8Encoding and the buffer size to 1024 bytes.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You probably shouldn't use my initials in your code like that
|
|
|
|
|
Today i come across this two lines of code (i changed the naming of the functions):
if(GetA() && GetB())
*GetA() = *GetB();
took me nearly two hours of figuring out WHY DOES THIS CODE WORK, since i realised thatGetA() returns a Pointer and Pointers are IValue...
Looked deeper inside the code, i found a SetA(int) -Method...
Why to use something like
*GetA() = *GetB() if you could use
SetA(*GetB())
|
|
|
|
|
A possibly better (and much clearer) implementation would be to have GetA() and GetB() return references. You could then write the code without the idirection.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
That's even worse:
GetA() = GetB();
And due to if statement we must assume that A and B can be nulls. GetA and GetB should return const pointers.
|
|
|
|
|
My bad; I missed the if statement.
IMO, if code needs such a test, it probably has a poor architecture to begin with. It is much better to have a special dummy instance of a type to represent 'not present', and reserve the null pointer for truly bad situations that crash the program.
Reasonable people may differ on this.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Sorry, that's not my code, an i cant change it. I just saw it in some code and where surprised what's that
Returning references would make it much harder to read:
GetA() = GetB()
looks like What the hell? Assignment to a Function?
|
|
|
|
|
C3D1 wrote: Returning references would make it much harder to read
We'll just have to agree to disagree on that. IMO, this is a quite useful C++ paradigm.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Daniel Pfeffer wrote: IMO, this is a quite useful C++ paradigm. ...and that makes me even happier to barely being able to read C++
|
|
|
|
|
De gustibus non est disputandum
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
That's what I like about this forum. You go in thinking programming and you get a bit of Latin training. Hope I remember what the phrase means next time I see it.
|
|
|
|
|
Me too. There are plenty of sites around that merely answer programming questions, but only a few with the range of highly intelligent, humorous, and opinionated contributors that you find here. Amazingly, the amount of sniping and backbiting is kept to a minimum!
Long may it last!
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Beautifully expressed and I agree totally.
"Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980
|
|
|
|
|
Daniel Pfeffer wrote: Amazingly, the amount of sniping and backbiting is kept to a minimum! Hear Hear (Or is that Here Here? ) Sometimes I find myself biting my tongue, but not on this thread. (Yet, and this thread is starting to grow a beard)
|
|
|
|
|
Daniel Pfeffer wrote: De gustibus non est disputandum I.e. C++ is the Durian (stinkfruit) in Software Development.
|
|
|
|
|
I agree, but I definitely would not name such a function "GetA".
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Learn to read code.
Assignment to a function would be
GetA = GetB() which would mean GetB() returns a function pointer rather than an int* and GetA is function pointer rather than a function.
Learn to read code.
#SupportHeForShe If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
Only 2 things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|