/* -------------------------------- ** FUNCTION: ** fnGetNameFromNameValueString ** DESCRIPTION: ** This function extracts the text of the name ** item in a name=value format string. ** for example: ** if the name, value string is ** employee=joseph ** Then the function should return 'employee' as ** a text string ** 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: ** fnStripLeadingSpaceFromString ** fnStripTrailingSpaceFromString ** SEE ALSO: ** DATE: ** -------------------------------- */ function fnGetNameFromNameValueString(sString, sDelimiter) { if (sDelimiter == null) { sDelimiter = "="; } if (sString == null) { //-->-->-->-->-->-->-->-->-->-->-->--> //-- write out some nasty error message //-- somewhere, mortally insulting the programmer //-- for such a ridiculous error return -1; } var sReturn = sString; var iIndexOfDelimiter = -1; sReturn = fnStripLeadingSpaceFromString(sReturn); iIndexOfDelimiter = sReturn.indexOf(sDelimiter); //-->-->-->-->-->-->-->-->-->-->-->--> //-- Case: //-- The delimiter is not found in the //-- 'name/value' string. if (iIndexOfDelimiter == -1) { sReturn = ""; return sReturn; } sReturn = sReturn.substring(0, iIndexOfDelimiter); sReturn = fnStripTrailingSpaceFromString(sReturn); return sReturn; } //-- fnGetNameFromNameValueString()