Terenz Posted July 4, 2014 Share Posted July 4, 2014 (edited) Damn i have a lapse of memory, i need to add the dot for a number string, like: 1213 = 1.213 12345 = 12.345 745221 = 745.221 I have see into StringFormat example but i don't have find it, i'd like to search but i don't know how is called lol Thanks and sorry Edited July 4, 2014 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
water Posted July 4, 2014 Share Posted July 4, 2014 StringFormat? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Terenz Posted July 4, 2014 Author Share Posted July 4, 2014 I have see into StringFormat example but i don't have find it, i'd like to search but i don't know how is called lol Yes i have understood but there isn't an example in StringFormat help for my case, or not? Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 4, 2014 Moderators Share Posted July 4, 2014 Terenz,How do you decide where the decimal point is to be entered into the string of digits? If you always want 3 digits after the decimal point then you can do this: ConsoleWrite(_AddPoint(1213) & @CRLF) ConsoleWrite(_AddPoint(12345) & @CRLF) ConsoleWrite(_AddPoint(745221) & @CRLF) Func _AddPoint($iNumber) $iLen = StringLen($iNumber) Return StringMid($iNumber, 1, $iLen - 3) & "." & StringMid($iNumber, $iLen - 2) EndFuncM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
UEZ Posted July 4, 2014 Share Posted July 4, 2014 I wrote this some years ago: #include <String.au3> $i = 123456789 ConsoleWrite("$" & Display1000Seperator($i, ",", 1) & @LF) $i = 9876543210.99 ConsoleWrite(Display1000Seperator($i) & @LF) $i = 100 ConsoleWrite(Display1000Seperator($i) & @LF) $i = "55555" ConsoleWrite(Display1000Seperator($i) & @LF) $i = "99999.123" ConsoleWrite(Display1000Seperator($i) & @LF) Func Display1000Seperator($iNumber, $sSeperator = ",", $bFloat = False) ;coded by UEZ 2012 If $iNumber = "" Then SetError(1, 0, 0) Local $1000 If IsInt(Number($iNumber)) Then $1000 = StringReverse(StringRegExpReplace(StringReverse($iNumber), ".{3}", "$0" & $sSeperator)) If StringLeft($1000, 1) = $sSeperator Then $1000 = StringTrimLeft($1000, 1) If $bFloat Then Return $1000 & ".00" Return $1000 ElseIf IsFloat(Number($iNumber)) Then Local $1000 = StringReverse(StringRegExpReplace(StringReverse(StringRegExpReplace($iNumber, "(\d+)\..*", "$1")), ".{3}", "$0" & $sSeperator)) If StringLeft($1000, 1) = $sSeperator Then $1000 = StringTrimLeft($1000, 1) Return $1000 & StringRegExpReplace($iNumber, "\d+(\..*)", "$1") EndIf Return SetError(2, 0, 0) EndFunc Might be useful for you. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Terenz Posted July 4, 2014 Author Share Posted July 4, 2014 I have found what i need: expandcollapse popupConsoleWrite(_TabNum0(1000) & @CRLF) ConsoleWrite(_TabNum0(10000) & @CRLF) ConsoleWrite(_TabNum0(100000) & @CRLF) ConsoleWrite(_TabNum0(10000000) & @CRLF & @CRLF) ConsoleWrite(_StringAddThousandsSep(1000) & @CRLF) ConsoleWrite(_StringAddThousandsSep(10000) & @CRLF) ConsoleWrite(_StringAddThousandsSep(100000) & @CRLF) ConsoleWrite(_StringAddThousandsSep(10000000) & @CRLF) Func _TabNum0($tn) ; Author: dwerf Return StringRegExpReplace($tn, '(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))', '\1.') EndFunc Func _StringAddThousandsSep($s_string, $i_convert_lcid = -1, $i_current_lcid = -1) ; $LOCALE_USER_DEFAULT = 0x0400 If $i_current_lcid = -1 Or $i_current_lcid = Default Then $i_current_lcid = 0x0400 If $i_convert_lcid = -1 Or $i_convert_lcid = Default Then $i_convert_lcid = 0x0400 ; Get lcid decimal and thousands separators Local $t_buff_tmp = DllStructCreate("char[4]") DllCall("kernel32.dll", "int", "GetLocaleInfo", "int", $i_current_lcid, _ "int", 0x0E, "ptr", DllStructGetPtr($t_buff_tmp), "int", 4) If @error Then Return SetError(1, 0, "") Local $s_cur_dec = DllStructGetData($t_buff_tmp, 1) DllCall("kernel32.dll", "int", "GetLocaleInfo", "int", $i_convert_lcid, _ "int", 0x0E, "ptr", DllStructGetPtr($t_buff_tmp), "int", 4) If @error Then Return SetError(1, 0, "") Local $s_con_dec = DllStructGetData($t_buff_tmp, 1) DllCall("kernel32.dll", "int", "GetLocaleInfo", "int", $i_convert_lcid, _ "int", 0x0F, "ptr", DllStructGetPtr($t_buff_tmp), "int", 4) If @error Then Return SetError(1, 0, "") Local $s_con_tho = DllStructGetData($t_buff_tmp, 1) ; For later formatting Local $i_number = StringRegExpReplace($s_string, "(\" & $s_cur_dec & "\d+\z)|(^-|\d+)|(\D)", "$2") Local $i_dec = StringRegExpReplace($s_string, "(.+?\" & $s_cur_dec & ")(\d+\z)", "$2") If @extended = 0 Then $i_dec = "" Local $i_str_len = StringLen($s_string) * 4 Local $t_numberfmt = DllStructCreate("uint;uint;uint;ptr;ptr;uint") Local $t_thousands = DllStructCreate("wchar[2]") Local $t_decimal = DllStructCreate("wchar[2]") Local $t_buffer = DllStructCreate("wchar[" & $i_str_len & "]") DllStructSetData($t_thousands, 1, $s_con_tho) DllStructSetData($t_decimal, 1, $s_con_dec) DllStructSetData($t_numberfmt, 3, 3) DllStructSetData($t_numberfmt, 4, DllStructGetPtr($t_decimal)) DllStructSetData($t_numberfmt, 5, DllStructGetPtr($t_thousands)) DllStructSetData($t_numberfmt, 6, 1) DllCall("kernel32.dll", "int", "GetNumberFormatW", _ "int", $i_convert_lcid, "int", 0, _ "wstr", $i_number, "ptr", DllStructGetPtr($t_numberfmt), _ "ptr", DllStructGetPtr($t_buffer), "int", $i_str_len) If $i_dec = "" Then $s_con_dec = "" Return DllStructGetData($t_buffer, 1) & $s_con_dec & $i_dec EndFunc ;<==> _StringAddThousandsSep() Probably i'll use the first function ( TabNum0 ) but other suggestion are welcome Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 4, 2014 Moderators Share Posted July 4, 2014 (edited) Terenz,Ah, the continental "thousand separator" dot and not a "decimal point" - it always helps if you are clear about what you are trying to do. M23Edit: I feel I should point out that the thread title has since been altered. Edited July 4, 2014 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Terenz Posted July 4, 2014 Author Share Posted July 4, 2014 Well if the title was "how to add the thousand separator" i think was better but the fault is my memory lapse Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now