function formatThousand(number) local str = string.format("%d", math.floor(number)) local pos = string.len(number) % 3 if pos == 0 then pos = 3 end local res = string.sub(str, 1, pos) .. string.gsub(string.sub(str, pos + 1), "(...)",",%1") .. string.sub(string.format("%d", number - math.floor(number)), 2) return res end function formatValues() local al = getAddressList() local count = al.getCount() if count > 0 then for i = 0, count -1 do local mr = al.getMemoryRecordByID(i) if mr.VarType == "vtDword" then print('Table Entry #' .. tostring(i) .. '\n' .. '—————————————————\n' .. 'Value\t: ' .. formatThousand(mr.value) .. '\n—————————————————') end end else error(ShowMessage('You must have at least one entry in the table.')) beep() end end function addFormatMenu() local parent = getMainForm().Menu.Items local fm = createMenuItem(parent) parent.add(fm) fm.Caption = "[Thousandify Values]" fm.OnClick = formatValues end addFormatMenu()