Unexpected DIR Results for Numbered Files

If you have ever used the DIR command to list numbered files in a command prompt and been confused by the output, it may have been due to SFNs.

Here is an example to demonstrate the problem. In a directory with files with long names and numbered filenames, you might type dir *1.txt to list all files that end in a 1. However you may end up getting a bunch of files that do not end in a 1 mixed in with the results.

What happened? Remember that each file that has a long filename has a DOS compatible (8.3) SFN associated with it. These are usually six characters from the filename followed by a swung-dash and a numerical counter. In other words, “Long Filename.txt” would not only have that as it’s name, but also “LONGFI~1.TXT”. And there’s the 1!

If there are multiple LFN files (that are too long or have spaces) that begin with LONGFI—eg “Long File.txt”, “Long Fi.txt”, etc.—then they will be saved as LONGFI~2.txt, LONGFI~3.txt, and so on. Therefore you may get weird results for dir *2.txt, dir *8.txt, dir *516.txt

There does not seem to be a way around this, but using the /X switch can at least reveal the source of the unexpected results.

Windows Explorer Freezes on Folder Access

If Windows Explorer seems to freeze for a few seconds (or a few minutes) whenever a folder, especially top-level folders, are selected, then it could be XP’s auto-sensing feature that is to blame.

Windows XP introduced a feature that peeks inside a folder to determine what the predominate filetype is and provide file-specific tasks for it. For example, if it finds that there more picture files in the folder than anything else, then it will place tasks such as “Print pictures” and “Order prints online” in the Common Tasks pane to the left. It will also place a graphic watermark indicating the “folder type” in the bottom-right of the folder.

This feature is debatable because it has limited use since most people have other ways and programs to do these common tasks. Worse still, if a root folder somehow becomes tagged as a special folder, then all of its subfolders are scanned every time that it is selected, which is what causes the freezing.

Fortunately it is easy to fix. Open a folder that is not “special”, that is, open any folder whose common tasks pane displays “File and Folder Tasks” and has no watermark. Now click the Tools menu and select Folder Options. Click the View tab and then the Apply to All Folders button (then OK). This sets all folders to be the same as the current folder (non-special).

You should now be able to click any folder without it freezing for a while.

As a furtherance to this task, you could also set up other aspects of the folder to be exactly like you wish before clicking Apply to All Folders. This way, all folders will have the same columns, view setting, common task layout, and other attributes that you desire since they will anyway.

(As a side note, it seems that the delay is compounded by the presence of LNK files (Windows shortcuts) and URL files (IE bookmarks)—and possibly PIF files (DOS shortcuts)—in the subfolders as removing them eliminates, for the most part, the freezing. Broken shortcuts increase the delay as do bookmarks to FTP sites. No explanation as to why they affect common tasks has been found.)

Reverse-engineering the Equation for Windows’ Translucent Selection Rectangle Color

Part I

It took over two years but I finally figured out how Microsoft calculates the color of the selection marquee in Windows.

Windows XP implemented a fancy new feature whereby dragging a selection box (aka, “rubber-band”) around files and folders in Explorer windows will draw a transparent rectangle instead of a gray-dotted box.

This is a feature of the Common Controls 6 and can be added to list controls by setting the preprocessor _WIN32_WINNT to 0x0501 or higher and setting the LVS_EX_DOUBLEBUFFER extended style of the list control.

It’s no secret that the color of the outline of the selection rectangle is set to COLOR_HIGHLIGHT which is the color set for selected items. But, what about the rest of the rectangle? Where does the color for the inside of the rectangle come from?

Obviously it’s calculated dynamically from the selected color and the color of the window background (COLOR_WINDOW) since it’s “translucent”. A little testing confirms this. But, what is the equation? What formula is used to blend these two colors?

A few years ago I determined to find out. I began by collecting data. This meant using the Display Properties dialog to set the selected and the window background colors, then drawing a selection rectangle and examining what the resulting color is. After doing this for dozens of pairs of colors, I had a data set and decided to figure out what they have in common. This turned out to be trickier than expected and I put it aside and occasionally looked at it briefly over the next two or three years.

This month when I learned of the LVS_EX_DOUBLEBUFFER style, I became more determined than ever to figure it out. Luckily I could not find the original data set (which would have surely side-tracked me for a while), so I decided to compile a new one with a controlled set of values instead of the random ones I had previously used. I used the following values: 0,64,128,192,255 in (almost) all the permutations of R/G/B and selected/background. I created a macro to automate the process of:

  • Selecting the selected and window background colors
  • Applying the theme
  • Switching to an Explorer window and drawing a rectangle
  • Taking a screenshot of the window and rectangle
  • Pasting the screenshot in MSPaint
  • Using a colorpicker app to determine the three colors and copy them to the clipboard
  • Pasting the colors in Notepad(2) in the proper format
  • Saving the file (to avoid losing all that work)

This automation allowed me to complete all 289 (17×17) permutations in just a couple of hours instead of a couple of months, since the only thing I needed to do manually was to click the correct boxes in the color picker.

Now I had a fresh, new set of data points that ranged from the min to the max in all directions. It was time to figure out the equation once and for all.

A good place to start was to plot the data points as a 3D graph where X=selected color, Y=background color, Z=blended color to see if there is any kind of visible relationship. A few minutes later and BAM! The plot was clearly a slanted plane:

Plot forms a slanted plane in 3D space.
Plot forms a slanted plane in 3D space.

Now I needed to figure out what the equation of the plane was. This was also easier said than done.

I decided that the most obvious next step was to use Cramer’s rule to determine the planar coefficients A, B, C, and D, then plug them into the equation of a plane and rearrange for Z. This meant taking three points (I had 289 to choose from) and calculating the planar coefficients. Plugging those into the plane equation would result in this z=-(Ax+By+D)/C where ABCD are replaced by numbers. This leaves an equation with two unknowns (two input variables). That would be the solution.

Unfortunately, this did not work. I was using COLORREFs (DWORDs) which combine all three color components in the following manner: C=R+256*G+256*256*B. The problem with doing it this way is that any math will cause carry errors between the components (eg: C*2 would cause the R component to wrap and the carry would overflow into the G component). The solution was to determine three separate equations, one for each of R, G, and B.

Luckily this did not mean triple the work because they were all the same equation as the data shows. Ignoring the G and B components, I took the 289 data points for the R component and recalculated everything. Again, it didn’t work. Even though the points clearly lay on a plane, the numbers (even the surface normals!) varied depending on which three points I used. I was stumped again (and still am; I don’t know why it works in theory but not in practice).

Then I got a stroke of “genius”. By examining the limiting factors, I could reduce the system to its base. Since f(0,0)=41, the mystery formula obviously adds 41 to whatever the rest of the results are. Also, since f(255,255)=255, I know what the limits are. Finally, I knew the other extents: f(0,255)=227 and f(255,0)=69. That turned out to be all I needed (I donated the other 285 data points to charity). I had the following system of equations:

f(000,000)=41
f(000,255)=227
f(255,000)=69
f(255,255)=255

 

Using Cramer’s rule again, this time with much smaller numbers for a single color component, and then reducing, I got the the nice and simple formula z = 41 + (28*x + 186*y) / 255. A quick test showed that the results were correct (actually a few were a bit off, but almost all of those were fixed by rounding instead of truncating, and the last few off-by-ones are due to using different data sizes and order of calculation).

So there you have it. After two-and-a-half years, the solution presented itself: c=(28s+186w)/255+41 (s=selected, w=window background—or texture).

Here is a function for calculating the marquee color (selection rectangle), printed here with separate component variables for clarity’s sake.

COLORREF BlendMarquee() {
 COLORREF selected=GetSysColor(COLOR_HIGHLIGHT);
 COLORREF windowbg=GetSysColor(COLOR_WINDOW);

 BYTE sr=GetRValue(selected);
 BYTE sg=GetGValue(selected);
 BYTE sb=GetBValue(selected);

 BYTE wr=GetRValue(windowbg);
 BYTE wg=GetGValue(windowbg);
 BYTE wb=GetBValue(windowbg);

 COLORREF c=RGB(
  RoundDouble(41+(sr*28+wr*186)/255, 0),
  RoundDouble(41+(sg*28+wg*186)/255, 0),
  RoundDouble(41+(sb*28+wg*186)/255, 0)
 );

 return c;
}

 

Tada!

 


 

Part II

Brief: Windows Vista (and 7) have changed things a little. For starters, they have made it so that the transparent marquee occurs on the desktop (COLOR_BACKGROUND) naturally when the option is selected without requiring the LVS_EX_DOUBLEBUFFER style to be manually set (the desktop is just a list-view control). In addition, while they still use the selected-item color (COLOR_HIGHLIGHT) for the border of the selection rectangle, they no longer use it in the calculation of the rectangle’s interior color. Instead, they combine the background color with the hyperlink/hot-tracked color (COLOR_HOTLIGHT). In addition, unlike in XP which uses a single formula, Vista and 7 use different formulas for calculating the color of the marquee depending on whether it is being drawn in an Explorer window or on the desktop.

When I decided to check to see if my marquee formula was still valid for Windows 7, a quick test showed that the selected-item color was not being used. For a moment I worried that Microsoft had simply hard-coded a color into the formula, combining a blueish color with the background, but figuring that they couldn’t be that insane, I searched through the Window Color and Appearance dialog for something that was blue. There were a couple, but I was not very surprised to find that the hyperlink entry was the one that changed the marquee color. Another quick test found that the resulting color was not the same as what the old formula would give. I had to extract the new formula.

I had hoped that I could use everything I learned the last time around to make it quick and easy this time. While it did take only a few hours instead of a few years, it was not as quick and easy as I was counting on. I looked through the files (particularly the last few modified) in the folder where I kept everything related to the prior investigation, and especially re-read this article. Unfortunately they were insufficient, particularly since I had not clearly written out one of the steps above (it’s there now), leaving me confused and struggling a bit and wasting some time by once again gathering unnecessary data points (not including the fact that I had to repeat everything twice; once for window backgrounds and once for the desktop because it uses a different formula).

Eventually I just focused on the limits like I did last time. I became a little worried that I was making a mistake because unlike in XP, the new marquee formula allows for pure black in addition to pure white rectangles (in XP, the formula limits the color to the range 41-255; remember the +41?) Worse, using middle-grey (128) for the window and hyperlink colors, gives 128, which seemed too unformulaic. I tried the numbers I had anyway.

I chose three points (0/255, 255/0, and one of the other two, either 255/255 or 0/0). I then plugged them into the formulas, factored, had a snack, watched a movie, reduced, and tested, and was done; well, for the desktop. I still had to repeat for window backgrounds. Fortunately this time I was able to cut eight or nine corners and skip right to the end, plugging in the numbers for the window backgrounds and finally had two formulas for calculating the marquee color in Windows 7 (I’m crossing my fingers that it is the same in Vista).

The function is slightly more complex now.

enum Marquee_Source={Marquee_Window, Marquee_Desktop};

COLORREF Marquee(COLORREF fc, COLORREF bc, BYTE fv, BYTE bv, BYTE hiv, BYTE lov) {
  BYTE fr=GetRValue(fc);
  BYTE fg=GetGValue(fc);
  BYTE fb=GetBValue(fc);

  BYTE br=GetRValue(bc);
  BYTE bg=GetGValue(bc);
  BYTE bb=GetBValue(bc);

  COLORREF c=RGB(
    RoundDouble(lov + (fr*fv + br*bv) / hiv, 0);
    RoundDouble(lov + (fg*fv + bg*bv) / hiv, 0);
    RoundDouble(lov + (fb*fv + bb*bv) / hiv, 0);
  );

  return c;
}

COLORREF BlendMarquee(Marquee_Source source=Marquee_Window) {
  DWORD dwWinVer =GetVersion();
  DWORD dwMajVer =(DWORD)(LOBYTE(LOWORD(dwWinVer));
  DWORD dwMinVer =(DWORD)(HIBYTE(LOWORD(dwWinVer));
  DWORD dwBldVer =(dwWinVer<0x80000000)?(DWORD)(HIWORD(dwWinVer):0;

  if (dwMajVer==5 && dwMinVer>0) {  //XP
    return Marquee(GetSysColor(COLOR_HIGHLIGHT),  GetSysColor(COLOR_WINDOW), 0x1C, 0xBA, 0xFF, 0x29);
  }
  else if (dwMajVer==6) {  //Vista, 7
    if (source==Marquee_Desktop)
      return Marquee(GetSysColor(COLOR_HOTLIGHT), GetSysColor(COLOR_WINDOW), 0x46, 0xB9, 0xFF, 0x00);
    else
      return Marquee(GetSysColor(COLOR_HOTLIGHT), GetSysColor(COLOR_WINDOW), 0x85, 0xAA, 0xFF, 0x00);
  }

  return RGB(128,128,128);
}

 

What’s interesting is the use of magic numbers (in this case, seemingly arbitrary in that they are not nice “round numbers” like 0, 10, 16, 64, 100, etc.) One can only assume that some GUI designers in Microsoft came up with formulas (and the corresponding values) that made the nicest, most visually appealing, yet contrasting blend for the transparent rectangle.

Fontographer on Windows XP with 1GB+ Ram

Macromedia Fontographer is one of the still few font editing applications there are. Unfortunately, it has barely been updated since the days of Windows 95; the focus has been on the Mac version, and even that has not been updated much.

Fontographer for Windows is a port of the Mac version and as such, it is less stable than native Windows programs, which is why it has not fared as well with newer hardware and operating systems. Running Fontographer on modern systems does not work well and can simply fail and exit the app or cause a catastrophic crash which can actually bring all of Windows down and require a hard reset.

There are two main problems with Fontographer on modern systems. The minor problem is that when the combined physical+virtual RAM exceeds 1.5GB, Fontographer complains that you do not have enough memory and quits. This is because it uses smaller pointers which overflow and look like there is a minuscule amount of RAM.

The solution to this problem (if practical) is to reduce the amount of virtual RAM so that the total memory is less than 1.5GB. Of course this won’t help if you have more than 1.5GB of physical RAM and you would have to actually pull some out for the one program. This problem has been around for a long time but there do not seem to be any plans to fix it. Another option is to add enough RAM to the system so that the wrapped available RAM meets Fontographer’s requirements (in other words, ACTUAL_RAM_SIZE mod RAM_POINTER_LIMIT_SIZE >= FONTOGRAPHER_MINIMUM_RAM); surely it can’t need too much (depending on the version, it needs 6-16 megabytes).

The other problem that can occur with Fontographer on modern systems is a complete crash. When run, Fontographer can completely freeze Windows in it’s tracks and require pressing the reset button on the case to bring the system back up. This is probably also caused by it’s memory allocation problems but may be caused by something else.

One thing to try with this that has had success is to run Fontographer in “compatibility mode”—this is available in Windows 2000 and up. Select the Fontographer executable (eg: “C:\Program Files\FOG41\FONTOG.EXE”) and bring up it’s properties dialog. Select the Compatibility tab and set it to run as Windows 95.

Fontographer should now work and allow you to create fonts in Windows.

Windows Explorer File Sort

Windows Explorer allows you to sort the files and directories in a folder by various properties by clicking the appropriate column header. Folders always come before files regardless of name, and there is unfortunately no way to change this even though sometimes it is desirable to sort with mixed folders/files.

The algorithm for sorting by name is mostly straightforward but with some bumps. Knowing the sort order allows you to choose characters to use as the first character in a file or folder name to control sorting, for example when creating a filing system.

For the most part, the algorithm sorts files/folders by name according to their ASCII values, expect that case is ignored because on Windows, filenames are case-insensitive, that is “MYFILE”, “MyFile”, and “myfile” are all the same file—iirc NTFS can do case-sensitive but it’s actually a hack (mapping).

You should also be aware that numbers are treated as numbers and not strings. For example “123blah” will come after “2blah” since 123 is bigger than 2, even though “1”-“2”-“3” comes before “2”. This behavior can be changed with the NoStrCmpLogical option of the Explorer policies (set HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoStrCmpLogical to dword:00000001).

Another bump in the algorithm is that the following characters appear out of order: +, <, and > They come after all other characters, in this order. Also, and are ignored altogether when they are the first character.

Here is a list of characters in the order that they will be sorted when used as the first character:

1 – Not (normally) allowed as a filename character
2 – Not in ASCII order
3 – Not used in sort when first character
  (space)
!
1
#
$
%
&
(
)
* 1
,
.
/ 1
: 1
;
? 1
@
[
\ 1
]
^
_
`
{
| 1
}
~
+ 2
< 1,2
= 1
> 1,2
3
3
 

This knowledge will be used in a later article to create a filing system that will allow organization of files and folders since Windows doesn’t really have symbolic links and WinFS has been cancelled until at least Windows Vienna.

The Causes of Crime

Common sense combined with education (biology, chemistry, psychology…) and observation (statistics, history…) points to three root causes of crime. Crime is usually if not always a function of one or more of money, hormones, and mental defect.

Money is an easy one. The vast majority of crimes are due to money. Robberies, theft, muggings, embezzlement, extortion, kidnapping, the list goes on. Nobody is immune to it either. The poor are susceptible to money-crimes because they need it and don’t have it (desperation). The rich are prone to money-crimes because they have a taste of it and want more (greed). It is not generally treatable other than with money. Unfortunately, society is not likely to vanquish hunger, homelessness, and such anytime soon since it is just too pervasive, so until Star Trek replicators are invented, this will continue to be the most common cause of crime. “Money is the root of all evil” indeed.

Hormones are pretty easy too, they are the second leading cause of crimes. Rape, adultery, pedophilia, assault, battery, manslaughter. Again nobody is immune to hormone-crimes since we all have them and frankly there is no defense against them; they affect our brains directly. Usually they are caused when a person has too much of a hormone, although a deficiency can also cause it. There are two kinds of hormone-crime, sex and violence which can even be combined. Hormones are the best candidate for treatment. They are not something that is overwhelmingly widespread like money, nor is it a permanent condition like mental defect. When properly diagnosed in time, the right medications or therapy can help treat or even cure hormonal imbalances and thus prevent hormone related crimes.

Mental defect is rarer than the other two. Mental defect-crimes are popular material for books and movies because they allow for unusual characters and an edgy and uncomfortable scenario. Crimes committed by people with mental defects don’t really have a tangible motivation; they commit them because the act itself gives them satisfaction—the act is the goal not the tool to achieve something else. Serial killers, people who delight in the torture and maiming of people and animals, pyromaniacs, kleptomaniacs, and the like all have some sort of defect in their brains that causes them to behave in an abnormal and destructive way. Mental defects are not usually curable. Like height, gender, skin color, etc. they are just part of who the person is since the brain cannot currently be “re-wired”. Unfortunately those who are “criminally insane” are more or less condemned to being put away in a state hospital for life. “Crimes of passion”, those done for love can be caused by either mental defect or possibly just a hormonal imbalance (ie, temporary insanity). A less movie-worthy cause of crime due to mental defect is when a person simply does not understand what they are doing is wrong because they either do not have the mental capacity in general (a “mentally-handicapped” person) or they have a defect that prevents them from understanding why it is bad (eg a sociopath who cannot relate to their victims).

When To Pull the Cord

Having involuntarily had to ride the bus for many years, I’ve gotten to know the experience very well. One thing I’ve learned is when to pull the cord. While most people probably don’t give much thought to the timing (and I know this to be the case), it is not as simple as you would think.

The ideal time to pull the cord varies depending on several factors, but there are two main things you need to consider. Don’t pull it too early and don’t pull it too late.

Too late is obvious, it means that you shouldn’t pull it when the bus is too close to your stop since it will be difficult or even impossible, and certainly dangerous for the driver to stop in time, particularly if it’s snowy or rainy.

You may wonder what’s wrong with too early; what could be bad about pulling it immediately after you pass the stop before yours? This one’s not a safety issue, it’s a convenience issue. If you pull it too early, then the driver will start slowing down too early and it will take a little longer to get to your stop. Granted it may only be a few seconds more, but that’s still a few seconds you get back which can add up day in and day out, also anyone who’s missed the bus, train, or anything else by just a few seconds can attest to the importance of a few seconds.

There is no simple number such as four seconds before the stop, ¾ of the way between the two stops, etc. that can be used universally. It’s really just up to each person to use good judgment and common sense to figure it out. If you ride the same route often then it will be all the easier to figure out.

Bad RAM? Maybe Not.

It has become more and more popular to blame computer problems on bad RAM—poor RAM. While it’s certainly possible to have a RAM module with a problem, it’s not as common as people would have you believe. In the past few years with the release of various RAM testing apps, there has been a surge of comments to the effect of “test your memory”, “you’ve probably got bad RAM”, “you need to replace your RAM” in response to posts about computer problems. It is just so easy to blame the RAM since it’s one of the only things that can successfully explain intermittent or unexplainable problems. The snafu is that even when the RAM is at fault, it’s not necessarily because the RAM is bad, it could—and usually is—because the connection is bad.

There are three common ways that RAM can be the cause of a problem. The way that everyone is raving about is a defective RAM module, that is a problem in a RAM chip or circuitry. This would render it useless (for all intents and purposes) and require just chucking it and getting a new one. Another problem could be the contacts on the edge of the RAM module could be dirty or have a patina on them, which impedes contact with the socket. In this case, the RAM may or may not be detected and could work partially or not at all. Finally, the RAM socket itself could have a problem. It could be that the contacts are dirty or the pins/pads are bent. Fortunately the contact problems are more common and easily fixed.

If the contacts on the RAM module are dirty, then simply using a little water to dampen a small sponge can be used to clean them. There are fancy patina cleaners, but all you really need to do is to clean those little pins on the edge. Pretty much anything will do, even alcohol or solvents, as long as you don’t let them dissolve the metal, just clean them and wipe it off. The best solution of course is to use some good old soapy water and some toilet paper.

The RAM socket is a little more tricky. If the pins are dirty, an effective solution is to lightly wet a used toothbrush, and gently scrub the socket up and down with it. This will do a good job of cleaning it.

If the pins on the socket are bent, then it may not make proper contact with the RAM module and will be a problem. More often than not, you will have to abandon the socket or even the whole motherboard, but with a little dexterity and the right tools you can fix it. You will need a long, find-tipped object, like a dentist pick, or something. It must be long enough so that your hands don’t obstruct your view, and pointy enough so that you can work with the tiny pins. You will probably need two so that you can grasp them and bend them back. You will also need good lighting and perhaps a magnifying glass. Take a good look at the socket and locate the bent pin. Examine it carefully to determine exactly what the problem is and which way you need to bend it to fix it. Use the tools to carefully bend it back to match the others. Plug in the RAM and give it a test. Be aware however, that they are metal and can only be bent so many times before snapping.

In conclusion, don’t throw away your RAM just because someone told you that it’s the cause of a problem or because a testing app said there’s problem(s). Before heading to the store, clean the RAM edge and run it through the test app. If that doesn’t fix it, clean the socket. If that doesn’t fix it, check for bent pins. If that doesn’t fix it, then go to the store.

Me and I

Your teacher always told you to say “so and so and I” instead of “me and so and so”. This is correct (most of the time), but did they explain why? It is often a point of confusion for most people because while teachers usually remember to teach that, they often do not explain the reason for it, which leaves people not understanding, which in turn can lead to problems such as using it incorrectly or not at all.

Many people think (and some are even taught!) that it is just more polite to put the other person first but that is NOT the reason. There is a legitimate grammatical reason.

In a proper English sentence, the first-person singular pronoun I is used where speaker is the subject of the sentence. That is, when the person is the one doing something. When the person is the object in the sentence, me is used instead. This is when the person is having something done to them. Examples of the former include I went there and I didn’t know what it was. Examples of the latter include He gave it to me, They helped me, and It happened to me too.

That’s great, but there is a much easier and faster way to determine whether a given sentence is grammatically correct. Since “blah and I” or “me and blah” are conjunctions (they combine two objects), you can break it down to its constituent parts to see if it still works. This is a simple method to show the proper usage. When do you use “…and I” and when do you use “…and me / me and…”? It’s simple; just separate the compound sentence by rewriting it with each subject, or object as the case may be, then test the sentences with each individually.

For example: “Bob and I saw the movie” becomes “Bob saw the movie” and “I saw the movie”. Both of those work fine, and so the sentence is fine as is.

What about “Me and Bob saw the movie” (or “Bob and me saw the movie”)? They become “Bob saw the movie” and “Me saw the movie”. Clearly, “Me saw the movie” is incorrect and so should be changed to “Bob and I”.

That is the reason you say “Bob and I”. Technically, you could also say “I and Bob” in a sentence like this, but most people would agree that it sounds and feels pretty awkward: “I and Bob saw the movie”

However, you do not always use “…and I”. For example, “You saw Bob and I” is incorrect because breaking it down becomes “You saw Bob” which is fine and “You saw I” which is wrong. The correct sentence would be “You saw Bob and me” or “You saw me and Bob”. This breaks down to “You saw Bob” and “You saw me” which is correct. At this point, the order of the subjects is up to the writer. Both “You saw Bob and me” and “You saw me and Bob” are valid, and there are no official rules to their order.

One hiccup comes in the form of the possessive personal pronoun, namely “my” or “mine”. This does not really work in the same way, though it is somewhat easy to figure out by simply trying the different forms. It would be “His any my cars were parked” as opposed to “His and mine cars were parked” (alternately, though somewhat awkwardly, “My and his cars were parked” instead of “Mine and his cars were parked”). Similarly, “They liked his and my food” is correct where “The liked his and mine food” is not. Where “mine” is correct, it is rarely combined due to its usage: “it was mine and his” (or “it was his and mine”) is usually just written as “it was ours”. Note, this can also be applied to the other forms as well: “We saw the movie”, “You saw us”, “Our cars were parked”, and “They liked our food”.

i.e.: e.g.

To avoid looking foolish, it is a good idea to learn to properly use the Latin abbreviations eg and ie. Think about what they mean, does the sentence sound right when you replace them with their English meanings?

AbbrLatinEnglish
EGExempli GratiaFor Example
IEId EstThat Is
  

Use a web-browser, eg: IE, FireFox, Opera.
Use a web-browser, for example: IE, FireFox, Opera.
Use a web-browser, that is, IE, FireFox, Opera.

He ruined the project, ie, he couldn’t finish it on time.
He ruined the project, that is, he couldn’t finish it on time.
He ruined the project, for example: he couldn’t finish it on time.

It is not difficult to use them properly when you know what they mean.