'Number.Comma 'Converts input number to comma format integer string 'Example: the following script will create accounting entries 'input = SELF.Get(0) 'val = input.abs 'val_d = val.floor 'dollars = av.Run("Number.Comma",{val_d}) 'cents = (val - val_d) * 100 'cents.SetFormat("dd.") 'amount = dollars+"."+cents.AsString 'if (input < 0) then ' amount = "("+amount+")" 'end 'return amount 'if the argument is -1010.05 the returned string is "(1,010.05)" '====================================================================== input = SELF.Get(0) int = input.Round.Abs if (int = 0) then return "0" end numdig = int.Log(10).Floor + 1 format_string = String.MakeBuffer(numdig).Translate(" ","d") int.SetFormat(format_string) val = int.AsString formatted = "" len = val.Count triad = (((len - 1) / 3) + 1).Truncate if (triad = 1) then formatted = val else i = triad while (i >= 1) start = len - ( i * 3 ) if (start < 1) then substr = 3 + start start = 0 else substr = 3 end if (i = triad) then formatted = val.Middle(start,substr) else formatted = formatted+","+val.Middle(start,substr) end i = i - 1 end end if (input < 0) then formatted = "-"+formatted end return formatted 'Converts input number to comma format integer string ' input = SELF.Get(0) int = input.Round.Abs if (int = 0) then formatted = "0" return formatted end numdig = int.Log(10).Floor + 1 format_string = String.MakeBuffer(numdig).Translate(" ","d") int.SetFormat(format_string) val = int.AsString formatted = "" len = val.Count triad = (((len - 1) / 3) + 1).truncate if (triad = 1) then formatted = val else i = triad while (i >= 1) start = len - ( i * 3 ) if (start < 1) then substr = 3 + start start = 0 else substr = 3 end if (i = triad) then formatted = val.Middle(start,substr) else formatted = formatted+","+val.Middle(start,substr) end i = i - 1 end end if (input < 0) then formatted = "-"+formatted end return formatted