function InsertThousandsSeparators string sValue returns string integer iPos boolean lbNegative string sThousandsSeparator move (trim(sValue)) to sValue move (left(sValue,1)="-") to lbNegative if (lbNegative) get StringRightBut sValue 1 to sValue get_attribute DF_DECIMAL_SEPARATOR to iPos character iPos to sThousandsSeparator move (pos(sThousandsSeparator,sValue)) to iPos ifnot iPos move (length(sValue)+1) to iPos get psThousandsSeparator to sThousandsSeparator while iPos gt 4 move (iPos-3) to iPos insert sThousandsSeparator in sValue at iPos loop if lbNegative move ("-"+sValue) to sValue function_return sValue end_function function InsertThousandsSeparators string sValue returns string integer iPos boolean lbNegative string sDecimalSeparator sThousandsSeparator trim sValue to sValue move (left(sValue,1)="-") to lbNegative if (lbNegative) get StringRightBut sValue 1 to sValue get psDecimalSeparator to sDecimalSeparator move (pos(sDecimalSeparator,sValue)) to iPos ifnot iPos move (length(sValue)+1) to iPos get psThousandsSeparator to sThousandsSeparator while (iPos>4) move (iPos-3) to iPos move (insert(sThousandsSeparator,sValue,iPos)) to sValue loop if (lbNegative) move ("-"+sValue) to sValue function_return sValue end_function