Search found 315 matches

by SKAN
Yesterday, 15:34
Forum: Scripts and Functions
Topic: FileURL() Converts filepath to file URI scheme
Replies: 5
Views: 110

Re: FileURL() Converts filepath to file URI scheme

Thanks garry :)

@list
To convert a relative path to full path + make sure file exists, I would do as follows:

Code: Select all

uglyPath := A_AhkPath "\..\license.txt"

Loop, Files, %uglypath%
 prettyPath := A_LoopFileLongPath

MsgBox % uglyPath "`n" prettyPath
by SKAN
Yesterday, 15:00
Forum: Scripts and Functions
Topic: FileURL() Converts filepath to file URI scheme
Replies: 5
Views: 110

Re: FileURL() Converts filepath to file URI scheme

Thanks for testing burque505 :) Quickly written/urgent requirement for ActiveX control. When doing document.write(html) and html links to a local javascript file, an error is thrown unless file URI is used. eg: <script src='file:///myJavascript.js'></script> Seemingly, fullpath is not required when ...
by SKAN
Yesterday, 14:26
Forum: Scripts and Functions
Topic: FileURL() Converts filepath to file URI scheme
Replies: 5
Views: 110

FileURL() Converts filepath to file URI scheme

FileURL( File ) { ; By SKAN on D1CA @ goo.gl/UqXL6n Local v, INTERNET_MAX_URL_LENGTH := 2048 VarSetCapacity(v,4200,0) DllCall( "Shlwapi.dll" ( SubStr(File,1,5)="file:" ? "\PathCreateFromUrl" : "\UrlCreateFromPath" ) , "Str",File, "Str",v, "UIntP",INTERNET_MAX_URL_LENGTH, "UInt",0 ) Return v } Usage...
by SKAN
04 Dec 2018, 16:36
Forum: Scripts and Functions
Topic: EXIFX() : Exif tags as object. For JPEG,TIFF and TIFF styled RAW
Replies: 1
Views: 118

EXIFX() : Exif tags as object. For JPEG,TIFF and TIFF styled RAW

EXIFX( File, p* ) { ; v0.34 - By SKAN on D1BJ/D1C5 @ goo.gl/JDLQs7 Local Static y := [1,1,2,4,8,1,1,2,4,8,4,8] Static OmitList := {0x02BC:"", 0x927C:"",0xA302:""} Global EXIFX_ErrN := 0, EXIFX_ErrM := "" VarSetCapacity(v,16,0) If ( (f:=FileOpen(File,"r"))=0 or f.Length<4096 ) { f<>0 ? f.Close() : 0...
by SKAN
27 Nov 2018, 08:38
Forum: Scripts and Functions
Topic: Float() : Remove redundant leading/trailing zeroes from a number
Replies: 6
Views: 360

Re: Float() : Remove redundant leading/trailing zeroes from a number

In help doc, SubStr() doesn't have enough examples to show how powerful this function is. The example below shows possibilities with SubStr(), and how Float() is splitting a number to decimal and fraction: #NoEnv #Warn #SingleInstance, Force d := "24September1980" ; Variable length, can be as short ...
by SKAN
24 Nov 2018, 07:43
Forum: Scripts and Functions
Topic: HTML Decoder
Replies: 9
Views: 638

Re: HTML Decoder

Skan, if you update your function, post link here I'll be glad to use it. Sure. It will take a while though. I am writing it using InStr() and SubStr() , but the problem is StringReplace() has to be called between StringCaseSense, On and StringCaseSense, Off I can't use StringCaseSense, On at the t...
by SKAN
22 Nov 2018, 05:59
Forum: Scripts and Functions
Topic: Float() : Remove redundant leading/trailing zeroes from a number
Replies: 6
Views: 360

Re: Float() : Remove redundant leading/trailing zeroes from a number

The following works for me

Code: Select all

#NoEnv
#Warn
#SingleInstance, Force

A := 0.0000001
B := 0.0000001
MsgBox % A+B               ; 0.000000  since default precision 0.6 is not enough
MsgBox % Float( A+B, 7  )  ; 0.0000002
by SKAN
21 Nov 2018, 19:04
Forum: Scripts and Functions
Topic: Float() : Remove redundant leading/trailing zeroes from a number
Replies: 6
Views: 360

Float() : Remove redundant leading/trailing zeroes from a number

SetFormat has been deprecated and to pull out a Double from a var I had to use NumGet() within Format() command with max float precision... and then use ZTrim() to remove redundant trailing zeroes VarSetCapacity(v,8,0) NumPut( -123.0123456789, v, "Double" ) n := Format( "{:0.16f}", NumGet(V,"Double...
by SKAN
20 Nov 2018, 11:45
Forum: Scripts and Functions
Topic: ChrsIn( Var, "==" or "<>", ChrsList )
Replies: 0
Views: 184

ChrsIn( Var, "==" or "<>", ChrsList )

ChrsIn() Validates Chrs in a Var with/against a list of valid/invalid chrs. Function: ChrsIn( Var, C, ChrsList ) { ; by SKAN on D1BK @ goo.gl/3wSZfF Return ( DllCall( "Shlwapi\Str" (C="=="?"":"C") "Spn", "Str",Var,"Str",ChrsList ) = StrLen(Var) ) } Usage Example: MsgBox % ChrsIn( "AABBCCDD", "==", ...
by SKAN
18 Nov 2018, 21:27
Forum: Scripts and Functions
Topic: HTML Decoder
Replies: 9
Views: 638

Re: HTML Decoder

I guess my point was that no one should still be writing HTML 4.
Ah, I see... Point noted. I rarely write HTML... :)
by SKAN
18 Nov 2018, 21:09
Forum: Scripts and Functions
Topic: HTML Decoder
Replies: 9
Views: 638

Re: HTML Decoder

SKAN, I think you mean HTML 5 Why? You need it? :) I did mean HTML 4. Its simply a matter of replacing the HTML 4 lookup table with HTML 5. It only takes 3 lines for me to resolve HTML entities but here follows the 26KB HTML 5 lookup table that won't even init in one Static variable. {HTML5:,Tab:9,...
by SKAN
18 Nov 2018, 08:01
Forum: Scripts and Functions
Topic: HTML Decoder
Replies: 9
Views: 638

Re: HTML Decoder

I've been planning to upgrade my old function to support HTML 4. I wouldn't use associative array(s) to resolve named entities.. Associative array keys aren't case sensitive. In your function (for eg.) both Aacute (193) and aacute (225) resolves to Aacute (193) only. Same problem with StringReplace ...
by SKAN
22 Oct 2018, 11:54
Forum: Scripts and Functions
Topic: DTSUB() : Calculates age from two DateTime stamps and returns yyyy/MM/dd HH:mm:ss
Replies: 1
Views: 198

DTSUB() : Calculates age from two DateTime stamps and returns yyyy/MM/dd HH:mm:ss

DTSUB( T1, T2, F ) The function accepts two DateTime stamps, calculates the difference and returns result formatted as Years,Months,Days,Hours,Minutes,Seconds. The acceptable range for DateTime stamps are from -9990101000000 to 99991231235959 ( 1000 BC + 1s to AD 10000 - 1s ). Please refer anno Dom...
by SKAN
10 Oct 2018, 19:46
Forum: Ask For Help
Topic: Is year a leap year
Replies: 15
Views: 1923

Re: Is year a leap year

Then I prefer this version of the function rather than all the MOD manipulations ! :dance: EnvAdd is much slower.. but enough for simpler needs. I wrote the function only to test if jNizM version is reliable. :) #NoEnv #SingleInstance, Force While ( ( Year := A_Index+1600 ) <= 9999 ) If ( IsLeapYea...
by SKAN
10 Oct 2018, 19:12
Forum: Ask For Help
Topic: Is year a leap year
Replies: 15
Views: 1923

Re: Is year a leap year

Another idea that you might want to try. If you take the first of March of the year and you subtract 1, is it then day 28 or 29 ? If 29 then it’s a leap year. Or take February 28 and add 1. Is it then March or still February? Too much work, IMO. :) Simply concatenate "0229" to Year and add 0 second...
by SKAN
10 Oct 2018, 17:55
Forum: Ask For Help
Topic: Is year a leap year
Replies: 15
Views: 1923

Re: Is year a leap year

can you test this now dmg? IsLeapYear(Year) { return !Mod(Year, 4) && Mod(Year, 100) || !Mod(Year, 400) } MsgBox % "The year 1700 was " (IsLeapYear(1700) ? "" : "not ") "a leap year" Works perfectly.. and at least 10 times faster than EnvAdd command. Thank you jNizM . I will be using this. :)
by SKAN
10 Oct 2018, 05:10
Forum: Scripts and Functions
Topic: Function Calculating Timespan in Years, Months, and Days
Replies: 11
Views: 618

Re: Function Calculating Timespan in Years, Months, and Days

Very nice! :) There is typo ( dot instead of comma ) in following line HowLong(FromDay,ToDay) { Global Years,Months,Days.Past I tried this 11 years ago and wasn't successful in creating something fast enough. I did have a accurate slow version though: Age() Seemingly your current version is off by a...
by SKAN
10 Oct 2018, 04:15
Forum: Scripts and Functions
Topic: StrQ() : String queue of Recent Items + FileQ() : Validates a File queue
Replies: 3
Views: 213

Re: StrQ() : String queue of Recent Items + FileQ() : Validates a File queue

Thank you. :)

StrQ() is a rewrite of InCache() to make use of the newer StrReplace() and Trim().
by SKAN
09 Oct 2018, 08:33
Forum: Scripts and Functions
Topic: StrQ() : String queue of Recent Items + FileQ() : Validates a File queue
Replies: 3
Views: 213

StrQ() : String queue of Recent Items + FileQ() : Validates a File queue

StrQ() + FileQ() combo is helpful to maintain a "Recent files" menu in a GUI. StrQ() maintains a pipe delimited (FIFO) queue of (unique) strings Parameters: List The variable containing queue Item A new (unique) string to be added to the top of list. An existing item will be bumped to the top. Max ...

Go to advanced search