/* -------------------------------- ** FUNCTION: ** fnGetValueFromNameValueString ** DESCRIPTION: ** This function gets the text of the 'value' ** item in a name=value format string. ** For Example: ** ------------ ** If the name/value string is ** employee = "joseph" ** Then the function should return the text string ** joseph (with or without any quotes) ** ** An assumption is made that the name field cannot ** contain any 'escaped' characters, such as the ** delimiter character. Escaping means to place another ** character (such as '\' normally) in front of a ** particular character that would other wise be ** interpreted incorrectly by some program. ** ** DEPENDENCIES: ** fnTrimSpaceFromString ** fnStripLeadingSpaceFromString ** fnStripTrailingSpaceFromString ** fnRemoveNameFromNameValueString ** SEE ALSO: ** DATE: ** -------------------------------- */ function fnGetValueFromNameValueString( sString, sDelimiter, bRemoveQuotes) { if (sDelimiter == null) { sDelimiter = "="; } if (bRemoveQuotes == null) { bRemoveQuotes = true; } if (sString == null) { //-->-->-->-->-->-->-->-->-->-->-->--> //-- write out some nasty error message //-- somewhere, mortally insulting the programmer //-- for incurring such an ridiculous error return -1; } var sReturn = sString; var iIndexOfDelimiter = -1; var cFirstLetter = ""; var cLastLetter = ""; sReturn = fnRemoveNameFromNameValueString(sReturn, sDelimiter); //alert("sReturn = [" + sReturn + "]"); sReturn = fnTrimSpaceFromString(sReturn); //alert("sReturn = [" + sReturn + "]"); cFirstLetter = sReturn.substring(0,1); cLastLetter = sReturn.substring(sReturn.length - 1); //alert("cFirstLetter = " + cFirstLetter); //alert("cLastLetter = " + cLastLetter); //-->-->-->-->-->-->-->-->-->-->-->--> //-- Case: //-- The first letter and the last letter are the //-- same and they are either single quotes or //-- double quotes, and if the bRemoveQuotes parameter //-- is true then remove the quotes. if ( (cFirstLetter == cLastLetter) && ((cFirstLetter == "'") || (cFirstLetter == '"')) ) { if (bRemoveQuotes == true) { sReturn = sReturn.substring(1, sReturn.length - 1); } } //-- if return sReturn; } //-- fnGetValueFromNameValueString()