Sign in to follow this  
Followers 0
AlmarM

Add Thousand Step

11 posts in this topic

#1 ·  Posted (edited)

Where did _AddThousandStep go? :huggles:

I tried making my own, but im on the wrong way, currently returns from: 1000000, "1,0,0,".

Help? :D

Edited 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.

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

:huggles:

Ahaww... I realy need the function. Just adding a "," is enough for me. :D

Edited 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.

Share this post


Link to post
Share on other sites

:huggles:

Ahaww... I realy need the function. Just adding a "," is enough for me. :D

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (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. :D Edited 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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

less regex..no regex.. pure autoit

;~ $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 by Mison

Hi ;)

Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

Great! Thanks for all the 'left over' functions! :D


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.

Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

#10 ·  Posted (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,2356ghijk

The 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.

Gilles

PS : 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 by GillesMaisonneuve

Share this post


Link to post
Share on other sites

#11 ·  Posted

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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0