AlmarM Posted January 30, 2010 Share Posted January 30, 2010 (edited) Where did _AddThousandStep go? I tried making my own, but im on the wrong way, currently returns from: 1000000, "1,0,0,". Help? Edited January 30, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 30, 2010 Moderators Share Posted January 30, 2010 AlmarM,From the Change Log for 3.3.2.0:"Removed: _StringAddThousandsSep() has been removed. Too many opinions on how the function should work means nobody is happy with it"M23 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...
AlmarM Posted January 30, 2010 Author Share Posted January 30, 2010 (edited) Ahaww... I realy need the function. Just adding a "," is enough for me. Edited January 30, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Bowmore Posted January 30, 2010 Share Posted January 30, 2010 Ahaww... I realy need the function. Just adding a "," is enough for me. Here is a RegEx that achieves the same result. $number = 1.123456789012 $DisplayNumber = StringRegExpReplace($number, "(?!\.)(\d)(?=(?:\d{3})+(?!\d))(?<!\.\d{1}|\.\d{2}|\.\d{3}|\.\d{4}|\.\d{5}|\.\d{6}|\.\d{7}|\.\d{8}|\.\d{9})", "\1,") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $DisplayNumber = ' & $DisplayNumber & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $number = 123456789.123456789012 $DisplayNumber = StringRegExpReplace($number, "(?!\.)(\d)(?=(?:\d{3})+(?!\d))(?<!\.\d{1}|\.\d{2}|\.\d{3}|\.\d{4}|\.\d{5}|\.\d{6}|\.\d{7}|\.\d{8}|\.\d{9})", "\1,") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $DisplayNumber = ' & $DisplayNumber & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $number = "This is some text 123456789.123456789012 This is some more text" $DisplayNumber = StringRegExpReplace($number, "(?!\.)(\d)(?=(?:\d{3})+(?!\d))(?<!\.\d{1}|\.\d{2}|\.\d{3}|\.\d{4}|\.\d{5}|\.\d{6}|\.\d{7}|\.\d{8}|\.\d{9})", "\1,") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $DisplayNumber = ' & $DisplayNumber & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
AlmarM Posted January 30, 2010 Author Share Posted January 30, 2010 (edited) Here is a RegEx that achieves the same result. $number = 1.123456789012 $DisplayNumber = StringRegExpReplace($number, "(?!\.)(\d)(?=(?:\d{3})+(?!\d))(?<!\.\d{1}|\.\d{2}|\.\d{3}|\.\d{4}|\.\d{5}|\.\d{6}|\.\d{7}|\.\d{8}|\.\d{9})", "\1,") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $DisplayNumber = ' & $DisplayNumber & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $number = 123456789.123456789012 $DisplayNumber = StringRegExpReplace($number, "(?!\.)(\d)(?=(?:\d{3})+(?!\d))(?<!\.\d{1}|\.\d{2}|\.\d{3}|\.\d{4}|\.\d{5}|\.\d{6}|\.\d{7}|\.\d{8}|\.\d{9})", "\1,") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $DisplayNumber = ' & $DisplayNumber & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $number = "This is some text 123456789.123456789012 This is some more text" $DisplayNumber = StringRegExpReplace($number, "(?!\.)(\d)(?=(?:\d{3})+(?!\d))(?<!\.\d{1}|\.\d{2}|\.\d{3}|\.\d{4}|\.\d{5}|\.\d{6}|\.\d{7}|\.\d{8}|\.\d{9})", "\1,") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $DisplayNumber = ' & $DisplayNumber & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console And thank you. Edited January 30, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Mison Posted February 2, 2010 Share Posted February 2, 2010 (edited) less regex..no regex.. pure autoit expandcollapse popup;~ $number = ".234" ;~ $number = "1.234" ;~ $number = "123.123" ;~ $number = "1234.1234" ;~ $number = "12345678.123456789" ;~ $number = "123" $number = "1234" ;~ $number = "12345" ;~ $number = "123456" ;~ $number = "1234567" ;~ $number = "12345678" ;~ $number = "123456789" ;~ $number = "123456789123456789123456789" ;~ $number = "aaa" ;~ $number = "123aaa" ;~ $number = "123.456.789" ;~ $number = "123+456-789" ;~ $number = "-123" ;~ $number = "-1234" ;~ $number = "-1234.1234" MsgBox(0,"","Original number : "&$number) MsgBox(0,"","New number : "&_AddThauSep($number)) Func _AddThauSep($num, $sep = ",") If Not StringIsDigit(StringReplace(StringReplace(StringStripWS($num,8),"-",""),".","")) Then Return $num If StringInStr($num,".",Default,2) Or StringInStr($num,"-",Default,2) Or (StringInStr($num,"-",Default,1) And StringLeft($num,1) <> "-") Then Return $num $num = StringStripWS($num,8) Local $neg = "", $temp = "", $after_dot = "" If StringLeft($num,1) = "-" Then $neg = "-" $num = StringTrimLeft($num,1) EndIf If StringInStr($num,".") Then $temp = StringSplit($num,".") $num = $temp[1] $after_dot = "."&$temp[2] EndIf If StringLen($num) < 4 Then Return $neg&$num&$after_dot While 1 $temp = StringRight($num,3)&$temp $num = StringTrimRight($num,3) If Not StringLen($num) Then ExitLoop $temp = $sep&$temp WEnd Return $neg&$temp&$after_dot EndFunc Edited February 3, 2010 by Mison Hi ;) Link to comment Share on other sites More sharing options...
GEOSoft Posted February 2, 2010 Share Posted February 2, 2010 The last version of the function is still available here http://dundats.mvps.org/autoit/udf_code.aspx?udf=stringx I thnk it's the 3rd function and be sure to read the header. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
AlmarM Posted February 2, 2010 Author Share Posted February 2, 2010 Great! Thanks for all the 'left over' functions! Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
GEOSoft Posted February 2, 2010 Share Posted February 2, 2010 One of these days I have to update that file, my copy has several more functions in it. In fact several of those files are outdated. The only reason that function was in there was simply because I knew it was being removed and didn't want it to become lost to those who might need it such as yourself. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GillesMaisonneuve Posted May 9, 2010 Share Posted May 9, 2010 (edited) Good afternoon,Using regex I think it might be possible to do it in a shorter way but I am not sure (I mean it AutoIt) : in Perl I would do something like this (assuming that the thousand sparator is <space> or <dot> like it is for my language, while the decimal point is <comma>) : {$_=reverse shift; while (s/(\d{3})(\d{1,})/$1 $2/g){};$_=reverse; while (s/(,\d+) /$1/g){};print}(of course the last print is to be replaced by return if you make it a function, this is just a command line perl instruction).This works well with a string like abcdef1234567890,2356ghijk and returns abcdef1 234 567 890,2356ghijkThe Perl reverse instruction saves a lot of algorithm trouble in that case. I must confess that I -- being a newbie in AutoIt -- I do not know how to implement the previous line from Perl to AutoIt.I guess in English/US-English you might replace <space> with <comma> in the instruction /$1 $2/ to make it /$1,$2/ and the <comma> decimal point with <dot> in s/(,\d+) /$1/g to make it s/(\.\d+) /$1/g.This make non international thousand separator handling of course. To make it international, one could replace all the separators with variables inside the regex (using the /x in Perl) but then again I confess I do not know how to do it in AutoIt.If someone has the knowledge to translate it in a short way in AutoIt this might produce a simpler way (even if less smart) to implement it.Hoping it can help and that I did not bother you with this little non pure AutoIt digression.GillesPS : what does mean in English "bumping your thread" as I can read it in the signature of some of you ? (I found translations "giving a knock on" / raising / inflating ... how do they apply to a thread ?). TIA./edited on Sunday 09 May at 19:40 to add the post scriptum/ Edited May 9, 2010 by GillesMaisonneuve Link to comment Share on other sites More sharing options...
jchd Posted May 9, 2010 Share Posted May 9, 2010 Reversing the string (twice) sure makes the pattern shorter, but the overall time is likely to suffer! _StringReverse would do the same (a higher cost than in Perl). AutoIt implements PCRE flavor for which you find a basic documentation in the help file, plus a link to a more complete reference. Only Perl callouts are unsopported as yet, but might be in some future. This flavor add few metacharacters to Perl but ignores none (at least none I know of). There are minor differences \Q..\E wrt $ and @, "use locale;" wrt VT, long Unicode codepoint names, \G semantics, distinct syntax for recursive patterns. The implementation is kept current, modulo release asynchronicity. To bump a thread is to post again in the same thread adding no new information but merely aiming at making the thread appear again on top of list. Clearly if this is tolerated without limit, every script kiddie will bump their thread every 10 minutes, attempting at getting more attention. This forum promotes the no non-sense rule of not bumping a thread within a 24-hour delay, which is reasonable. Also multiple posting on the same subject is frown upon, for the same reason. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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