PDA

View Full Version : Extending String Functions



simpleSoft
April 15th, 2004, 12:28 AM
More OOP woes...
Here is what I want to do...extend the String class

class example extends String {}
and then I want to take things that are already strings and add a function to them which goes through and removes & and turns it back to & am things got some test code for that here

function htmlToString():Void {
var args:Array = new Array();
args = this.split("&");
this = args.join("&");
args = this.split("'");
this = args.join("'");
args = this.split(""");
this = args.join('"');
args = this.split("<");
this = args.join('<');
args = this.split("&gt;");
this = args.join('>');
}

But when I go and compile it I get error msg's like this
Line 13: Type mismatch in assignment statement: found String where htmlString is required.
this = args.join('>');

Harpreet
April 15th, 2004, 03:25 AM
try '/>' instead of '>'

or '%3e' instead of '>' also look into unexcape (i think) function to convert URL incode into their meaning for this if it doesnt work directly.


cheers