About the errors: the post is old, and when the forum changed, some texts got reformated. Your errors are probably because most quotes are different.
About the expression not working.
You probably have a paragraph text, and not a point text. In order to ignore the empty parts of the paragraph text, you should use sourceRectAtTime with the second argument as false.
// right edge
gap = 10;
L = thisComp.layer("some text");
r = L.sourceRectAtTime(0,false);
x = L.position[0] + (r.left + r.width - L.anchorPoint[0])*L.scale[0]/100 + scale[0]*width/200 + gap;
[x, value[1]]