;------------------------------------------------------------------------------------------------------------------------------------------#DefineFunctionudfItemListCsvReplaceV4(strItem,intIndex,strList,intFlag,strDelimiter)IfstrList==""ThenReturnstrListintCount=ItemCountCSV(strList,intFlag,strDelimiter)If!intCountThenReturnstrListIfintIndex>intCountThenintIndex=intCount; ... or better immediately return strList ???IfintIndex<0ThenintIndex=intCountIf!!StrIndex(strItem,'"',1,@FWDSCAN)ThenstrItem=StrReplace(strItem,'"','""')strListNew=""intLast=intIndex-1ForintI=1TointLaststrListNew=strListNew:strDelimiter:'"':ItemExtractCSV(intI,strList,intFlag,strDelimiter):'"'NextstrListNew=strListNew:strDelimiter:'"':strItem:'"'intFirst=intIndex+1ForintI=intFirstTointCountstrListNew=strListNew:strDelimiter:'"':ItemExtractCSV(intI,strList,intFlag,strDelimiter):'"'NextReturnStrSub(strListNew,StrLen(strDelimiter)+1,-1);..........................................................................................................................................; This UDF "udfItemListCsvReplaceV4" replaces an item in a list with a new item.; It returns a new list, with the specified replacement made; the original list is unchanged.; For example, specifying an index of 1 causes the first item in the list to be replaced with the new item.; Using -1 as the index will replace the last item in the list.;; Note:; A null list ("") is not a valid list.;; (c)Detlev Dalitz.20120115.;..........................................................................................................................................#EndFunction;------------------------------------------------------------------------------------------------------------------------------------------; Test.strCsvLineIn=`1,"lastname,firstname",3,4,,"some other words",7`; Test 1.strCsvLineOut=udfItemListCsvReplaceV4(`"test item 3"`,3,strCsvLineIn,0,","); Change item at position 3.strMsgTitle="udfItemListCsvReplaceV4|Test.1|Replace item 3"strMsgText="strCsvLineIn = ":@LF:strCsvLineIn:@LF:@LF:"strCsvLineOut = ":@LF:strCsvLineOutPause(strMsgTitle,strMsgText); Test 2.strCsvLineOut=udfItemListCsvReplaceV4(`"test last item"`,-1,strCsvLineIn,0,","); Change item at last position.strMsgTitle="udfItemListCsvReplaceV4|Test.2|Replace last item"strMsgText="strCsvLineIn = ":@LF:strCsvLineIn:@LF:@LF:"strCsvLineOut = ":@LF:strCsvLineOutPause(strMsgTitle,strMsgText); Test 3.strCsvLineIn=""strCsvLineOut=udfItemListCsvReplaceV4(`"test last item"`,-1,strCsvLineIn,0,","); Change item at last position.strMsgTitle="udfItemListCsvReplaceV4|Test.3|Null list"strMsgText="strCsvLineIn = ":@LF:strCsvLineIn:@LF:@LF:"strCsvLineOut = ":@LF:strCsvLineOutPause(strMsgTitle,strMsgText):CANCELExit