tMotor to string

I was wondering if there was any good way of going from a tMotor variable to string. The closest I’ve come so far is the following function:
int portNumber (tMotor motorName)
string intermediaryString;
int intermediaryInteger;
StringFormat(intermediaryString, “%d”, motorName);
intermediaryInteger = atoi(intermediaryString);
return intermediaryInteger;
and then concatenating the result with “port”. Which works to an extent, but ideally I would like the name of the motor. In other words, if the motor in port1 is named driveLeft, my method would give me the string “port1”, whereas ideally I would like to get “driveLeft”. Any suggestions?

Also, its a bit different from the situation in the original post. Rather than:

tMotor driveLeft = port1;

and trying to get “driveLeft” from driveLeft, its more along the lines of:

tMotor driveLeft = port1;
tMotor x = driveLeft;

and trying to get “driveLeft” from x.