/* -------------------------------- ** FUNCTION: ** fnStripLeadingSpaceFromString ** DESCRIPTION: ** This function strips 'whitespace' from the beginning ** of a specified string. In this case whitespace is ** defined as space and tab characters, and newlines ** DEPENDENCIES: ** SEE ALSO: ** fnStripEndingSpaceFromString ** DATE: ** -------------------------------- */ function fnStripLeadingSpaceFromString(sString, sWhiteSpaceIndicator) { //-->-->-->-->-->-->-->-->-->-->-->--> //-- The sWhiteSpaceIndicator variable is a way //-- of indicating what sort of white space should be //-- removed from the beginning of the specified //-- string. If this variable contains 'n' then //-- newline characters will be removed //-- (\n escape characters) if 't' then tabs (\t) //-- etc if (sWhiteSpaceIndicator == null) { sWhiteSpaceIndicator = "snt"; } if (sString == null) { //-->-->-->-->-->-->-->-->-->-->-->--> //-- write out some nasty error message //-- somewhere, mortally insulting the programmer //-- for such a ridiculous error return -1; } var sRemoveWhiteSpace = new String(""); var iLength = sString.length; var cCurrentCharacter = new String(""); var sReturn = new String(""); if (sWhiteSpaceIndicator.indexOf("n") > -1) { sRemoveWhiteSpace += "\n"; } if (sWhiteSpaceIndicator.indexOf("t") > -1) { sRemoveWhiteSpace += "\t"; } if (sWhiteSpaceIndicator.indexOf("s") > -1) { sRemoveWhiteSpace += " "; } /* -->-->-->-->-->-->-->-->-->-->-->--> OLD CODE for (var ii = 0; ii < iLength; ii++) { cCurrentCharacter = sString.substring(ii, ii + 1); if ( (cCurrentCharacter != " ") && (cCurrentCharacter != "\t") && (cCurrentCharacter != "\n") ) { sReturn = sString.substring(ii, iLength); return sReturn; } //-- if } //--for */ for (var ii = 0; ii < iLength; ii++) { cCurrentCharacter = sString.substring(ii, ii + 1); if (sRemoveWhiteSpace.indexOf(cCurrentCharacter) == -1) { sReturn = sString.substring(ii, iLength); return sReturn; } //-- if } //--for } //-- fnStripLeadingSpaceFromString()