@Helgef
Great explantion!!
Thank you very much.
PS:
I use RefCount as follows:
When ( RefCount = 0 )
__New() will load GDIPlus
__Delete() will unload GDIPlus
Search found 35 matches
- 05 Aug 2017, 16:52
- Forum: Ask for Help (v1)
- Topic: Class {} -> How to assign a Static var from __Delete() ? Topic is solved
- Replies: 4
- Views: 1480
- 05 Aug 2017, 16:44
- Forum: Ask for Help (v1)
- Topic: Class {} -> How to assign a Static var from __Delete() ? Topic is solved
- Replies: 4
- Views: 1480
Re: Class {} -> How to assign a Static var from __Delete() ? Topic is solved
Thank you very much.wolf_II wrote:I can't offer any explanation, but this seems to work:
- 05 Aug 2017, 10:53
- Forum: Ask for Help (v1)
- Topic: Class {} -> How to assign a Static var from __Delete() ? Topic is solved
- Replies: 4
- Views: 1480
Class {} -> How to assign a Static var from __Delete() ? Topic is solved
#NoEnv #Warn #SingleInstance, Force Test1 := new ABC() Test2 := new ABC() ExitApp Class ABC { Static RefCount := 0 __New() { ABC.RefCount ++ ; Working MsgBox % "Incrementing: " this.RefCount } __Delete() { ABC.RefCount -- ; Not working MsgBox % "Decrementing: " this.RefCount } } Please help.
- 21 Jul 2017, 16:09
- Forum: Scripts and Functions (v1)
- Topic: ZTrim() : Remove redundant leading/trailing zeroes from a number
- Replies: 24
- Views: 9103
Re: ZTrim() : Remove redundant leading/trailing zeroes from a number
It would seem that a simple Format will handle most of what is needed. I need 0.000001 to be left as it is, but g option converts it to e notation MsgBox % Format("{1:g}", 0.000001 ) ; 1e-006 which is not even valid for AHK math operations. The result should be 1.0e-006 to be a valid number.
- 17 Jul 2017, 08:25
- Forum: Scripts and Functions (v1)
- Topic: FileID() : Compare non-identical filepaths mapping to the same target
- Replies: 4
- Views: 2534
Re: FileID() : Compare non-identical filepaths mapping to the same target
Thank you for the pointers.jNizM wrote:
Just a few hints / tips
I had copy/pasted/edited CreateFile() from very old code.
- 17 Jul 2017, 07:35
- Forum: Scripts and Functions (v1)
- Topic: FileID() : Compare non-identical filepaths mapping to the same target
- Replies: 4
- Views: 2534
FileID() : Compare non-identical filepaths mapping to the same target
FileID() returns the File ID for a valid File /Folder path ( A concatenation of Volume serial and File/Folder ID ) MsgBox % FileID( "D:\AutoHotkey\AutoHotkey.exe" ) returns 5AD009C7-000200000000563F for me which I've confirmed with elevated run of FSUTIL http://i.imgur.com/IogIzLI.jpg I test mapped...
- 17 Jul 2017, 05:56
- Forum: Scripts and Functions (v1)
- Topic: Replicate() : Repeats a string N times
- Replies: 17
- Views: 10551
Re: Replicate() : Repeats a string N times
True. VarSetCapacity() works differently in ANSI and UNICODE.Helgef wrote:It seems to be 3 for ANSI and 6 for unicode
Also, it differs with existing vs new variable
Try this in ANSI and UNICODE:
Code: Select all
Loop 1000
{
Cap := VarSetCapacity( Var, A_Index, 0 )
If ( Cap <> A_Index )
MsgBox % A_Index " = " Cap
}
- 17 Jul 2017, 04:38
- Forum: Scripts and Functions (v1)
- Topic: Replicate() : Repeats a string N times
- Replies: 17
- Views: 10551
Re: Replicate() : Repeats a string N times
Helgef wrote:I also think the old version (see the first post by Suresh) might be sligthly improved by this,
Code: Select all
Replicate( "Hello", 2, Out )
MsgBox % Out
- 17 Jul 2017, 04:25
- Forum: Scripts and Functions (v1)
- Topic: ZTrim() : Remove redundant leading/trailing zeroes from a number
- Replies: 24
- Views: 9103
Re: ZTrim() : Remove redundant leading/trailing zeroes from a number
here's an attempt I made Very nice! Thanks for sharing! Any ideas/comments are welcome. A float like 0.01 is valid in ahk in these forms: +00.01 / +0.01 / .01 / +.01 / .010 ZTrim() calls Abs() to remove the redundant + sign, adds a leading zero for values like .01 ZTrim() will return 0 when param i...
- 17 Jul 2017, 04:10
- Forum: Scripts and Functions (v1)
- Topic: ZTrim() : Remove redundant leading/trailing zeroes from a number
- Replies: 24
- Views: 9103
Re: ZTrim() : Remove redundant leading/trailing zeroes from a number
Not that it matters much but I just use a RegEx to get rid of trailing zeros. ; Remove Trailing Zeros N := "100.0000" MsgBox % RegExReplace(N, "\.0*$|(\.\d*?)0*$", "$1") Very nice!. Removing trailing zeroes should be sufficient most of the times. Thanks for sharing! It does not do leading zeros as ...
- 05 Jul 2017, 06:32
- Forum: Scripts and Functions (v1)
- Topic: ZTrim() : Remove redundant leading/trailing zeroes from a number
- Replies: 24
- Views: 9103
Re: ZTrim() : Remove redundant leading/trailing zeroes from a number
Thanks for the topic. Good ,this has been clarified.Helgef wrote:For circular reference, see Dot interpreted as literal string even when unquoted.
- 05 Jul 2017, 06:23
- Forum: Scripts and Functions (v1)
- Topic: Replicate() : Repeats a string N times
- Replies: 17
- Views: 10551
Re: Replicate() : Repeats a string N times
Interesting. Thanks for sharing!jeeswg wrote:I could do this via RegEx,
- 05 Jul 2017, 06:22
- Forum: Scripts and Functions (v1)
- Topic: Replicate() : Repeats a string N times
- Replies: 17
- Views: 10551
Re: Replicate() : Repeats a string N times
Hi Suresh ( and jNizM :wave: ) Greetings Helgef :) The old version seems slightly faster according to some brief testing. I know, hence I've included it. iirc, it can be faster than the old version under some circumstances; short string + very high count (like >2**16). I wonder under what circumsta...
- 05 Jul 2017, 06:17
- Forum: Scripts and Functions (v1)
- Topic: Replicate() : Repeats a string N times
- Replies: 17
- Views: 10551
Re: Replicate() : Repeats a string N times
I did this before: str:="abcd", n:=0xFF ;---> n=255 MsgBox, % StrReplace(StrGet(VarSetCapacity(@,n,Asc("x"))*0+&@,n,0),"x",str) Nice! :) I think Format() needs to consider the number of times sixteen decimal. str:="abcd", n:=0xFF ;---> n=255 MsgBox, % StrReplace(Format("{:0" . Format("{:d}",n) . "}...
- 03 Jul 2017, 07:47
- Forum: Scripts and Functions (v1)
- Topic: Replicate() : Repeats a string N times
- Replies: 17
- Views: 10551
Replicate() : Repeats a string N times
Replicate( Str, Count ) { ; By SKAN / CD: 01-July-2017 | goo.gl/U84K7J Return StrReplace( Format( "{:0" Count "}", "" ), 0, Str ) } /* ; Older version Replicate( Str, Count ) { ; By SKAN / CD:12-04-2011 ; www.autohotkey.com/community/viewtopic.php?p=435990#435990 VarSetCapacity( S, Count * ( A_IsUn...
- 03 Jul 2017, 04:41
- Forum: Scripts and Functions (v1)
- Topic: ZTrim() : Remove redundant leading/trailing zeroes from a number
- Replies: 24
- Views: 9103
Re: ZTrim() : Remove redundant leading/trailing zeroes from a number
Helgef wrote:I'm literally surprised tooCode: Select all
msgbox, % .
Code: Select all
msgbox, % "A" . "B"
- 03 Jul 2017, 04:36
- Forum: Scripts and Functions (v1)
- Topic: ZTrim() : Remove redundant leading/trailing zeroes from a number
- Replies: 24
- Views: 9103
Re: ZTrim() : Remove redundant leading/trailing zeroes from a number
Nice function but only works for the half of the world :( The intended use for ZTrim() is to counter the effect of using high floating point precision with SetFormat and Format() SetFormat, Float, 0.12 A := 1 / 4 B := 4.1 * 100 C := 22 / 7 MsgBox % ( A := 1 / 4 ) "`t=`t" ZTrim( A ) "`n" . ( B := 4....
- 02 Jul 2017, 16:37
- Forum: Scripts and Functions (v1)
- Topic: ZTrim() : Remove redundant leading/trailing zeroes from a number
- Replies: 24
- Views: 9103
Re: ZTrim() : Remove redundant leading/trailing zeroes from a number
I'm surprised, But only the dot works.. Accidental discovery.wolf_II wrote:It worked though!
- 02 Jul 2017, 16:25
- Forum: Scripts and Functions (v1)
- Topic: ZTrim() : Remove redundant leading/trailing zeroes from a number
- Replies: 24
- Views: 9103
Re: ZTrim() : Remove redundant leading/trailing zeroes from a number
A mistake..wolf_II wrote:Is it a bug or a feature?
Edited.. Thanks for pointing it
- 02 Jul 2017, 15:22
- Forum: Scripts and Functions (v1)
- Topic: ZTrim() : Remove redundant leading/trailing zeroes from a number
- Replies: 24
- Views: 9103
ZTrim() : Remove redundant leading/trailing zeroes from a number
Edited by SKAN: Better version here: RoundT() ZTrim( N := "" ) { ; SKAN / CD:01-Jul-2017 | LM:03-Jul-2017 | Topic: goo.gl/TgWDb5 Local V := StrSplit( N, ".", A_Space ) Local V0 := SubStr( V.1,1,1 ), V1 := Abs( V.1 ), V2 := RTrim( V.2, "0" ) Return ( V0 = "-" ? "-" : "" ) ( V1 = "" ? 0 : V1 ) ( V2 <>...