Search found 480 matches

by john_c
Yesterday, 09:02
Forum: AutoHotkey v2 Development
Topic: About traditional assignments
Replies: 5
Views: 249

Re: About traditional assignments

Well, I'm fine with this. However, just a quick idea, "we" (I'm not an AHK dev) can introduce literal assignments instead, so there will be no need to escape quotation marks or any other characters where it doesn't make sense. And on the other hand, it won't be possible to include a variable referen...
by john_c
25 Feb 2021, 04:35
Forum: Scripts and Functions
Topic: JS and CSS minifier
Replies: 0
Views: 139

JS and CSS minifier

JS and CSS minifier. 1. Removes // and /**/ comments 2. Optionally, converts a file to a one-liner Usage example: minifier(["minifier-tests.js"], false, "min") Tested (see the tests below), but if you need a bulletproof reliable solution, you should use something different, probably https://github.c...
by john_c
24 Feb 2021, 11:07
Forum: AutoHotkey v2 Development
Topic: About traditional assignments
Replies: 5
Views: 249

About traditional assignments

As far as I know, traditional assignments won't work in AHK2. My thread is just a small friendly remark that in some cases these assignments are very useful. Here is a regex to remove C-style comments. regex = (["'][^"']?\/\*.*?\*\/[^"']*["'])|\/\*(?:.|\R)*?\*\/ There are quotation marks there, and ...
by john_c
22 Feb 2021, 09:00
Forum: Ask For Help
Topic: Is a comma after the #Include directive correct?
Replies: 5
Views: 151

Re: Is a comma after the #Include directive correct?

Thanks, this is a good example. This is a different topic, but I think it would be much better to have Microsoft Language Server support for AutoHotkey instead of maintaining regex-based highlighting schemes for every particular editor. Easier so maintain, more reliable, provides more options (for e...
by john_c
22 Feb 2021, 07:10
Forum: Ask For Help
Topic: Is a comma after the #Include directive correct?
Replies: 5
Views: 151

Re: Is a comma after the #Include directive correct?

Since commas for statements are often optional, and only necessary in certain cases with multiple parameters (if optional parameter in the front get left out), #include is probably exempt from using a comma as it always has only one parameter - and thus there can be no ambiguities. A comma would se...
by john_c
22 Feb 2021, 05:35
Forum: Ask For Help
Topic: Is a comma after the #Include directive correct?
Replies: 5
Views: 151

Is a comma after the #Include directive correct?

If you look into the AutoHotkey.tmLanguage file of the AutHotkey package for Sublime Text, you will see that regular expressions to match #Include and #IncludeAgain directives are different from the regular expressions to match other directives. (https://github.com/ahkscript/SublimeAutoHotkey/blob/m...
by john_c
16 Oct 2020, 05:43
Forum: Ask For Help
Topic: The reason to use "Return (%Var%)" Topic is solved
Replies: 3
Views: 450

Re: The reason to use "Return (%Var%)" Topic is solved

To compare the example by Gregster with cases with no return:

Code: Select all

Var := "Foo"
Foo := "Bar"
msgbox % %Var%    ; => "Bar"
msgbox % (%Var%)  ; => "Bar"

Code: Select all

Var := "Foo"
Foo := "Bar"
; Abc := %Var%
; Abc := (%Var%)
msgbox % Abc  ; => "Bar"
by john_c
10 Oct 2020, 06:41
Forum: Ask For Help
Topic: Need a good example of a use of a guard statement Topic is solved
Replies: 4
Views: 197

Re: Need a good example of a use of a guard statement Topic is solved

Just in case and to mark this thread as solved, here is the function I searched for: Capital(Country, CompleteSentence) { Country := GetCountry(Country) If (Country == "") Return "Information about the country is missing" Capital := GetCapital(Country) If (Capital == "") Return "Information about th...
by john_c
08 Oct 2020, 18:13
Forum: Ask For Help
Topic: Two numbers are different but treated as equal. What the heck?
Replies: 9
Views: 142

Re: Two numbers are different but treated as equal. What the heck?

@boiler Yes, now both errors are obvious to me, thanks.

But it's not clear why - if I change the return statement to return Customer - the function sometimes returns the empty string. This is probably related to your last post, though I'm not sure.
by john_c
08 Oct 2020, 16:48
Forum: Ask For Help
Topic: Two numbers are different but treated as equal. What the heck?
Replies: 9
Views: 142

Re: Two numbers are different but treated as equal. What the heck?

@Xtra Could you show where exactly? I really don't see. I don't think you mean return.

Code: Select all

            return "Lucky:" A_Tab IsLucky(Customer) "`n"
                 . "Index:" A_Tab Index "`n"
                 .  Customer
@mikeyww Yes, exactly. A small typo.
by john_c
08 Oct 2020, 15:48
Forum: Ask For Help
Topic: Two numbers are different but treated as equal. What the heck?
Replies: 9
Views: 142

Two numbers are different but treated as equal. What the heck?

I generally avoid to create 2 thread per day, but it is too interesting why the following code doesn't work as I expect it. (And yes, we don't need two separate functions here, it could be done much simpler. It is just an example.) Customers := ["Bill", "Karl", "Tom"] FindLuckyCustomer(Customers) { ...
by john_c
08 Oct 2020, 15:42
Forum: Ask For Help
Topic: Update cloned array Topic is solved
Replies: 7
Views: 136

Re: Update cloned array Topic is solved

Thanks!
by john_c
08 Oct 2020, 13:57
Forum: Ask For Help
Topic: Update cloned array Topic is solved
Replies: 7
Views: 136

Re: Update cloned array Topic is solved

I suppose your function is trying to handle cases where the particular customer hasn’t been added,
Yes, this is correct.
but I’m not seeing why.
You mean, what is the reason? Just curiosity.
by john_c
08 Oct 2020, 13:39
Forum: Ask For Help
Topic: Update cloned array Topic is solved
Replies: 7
Views: 136

Update cloned array Topic is solved

Bill := {} Bill["Country"] := "Canada" Bill["City"] := "Toronto" Bill["Profession"] := "Designer" Karl := {} Karl["Country"] := "UK" Karl["City"] := "London" Karl["Profession"] := "Manager" Jane := {} Jane["Country"] := "UK" Jane["City"] := "London" Jane["Profession"] := "Artist" Customers := {} Cu...
by john_c
06 Oct 2020, 15:47
Forum: General Discussion
Topic: "Say thanks" feature or something similar
Replies: 3
Views: 348

"Say thanks" feature or something similar

I think that it would be useful to have an option to mark some answer as useful so that the poster (the who posted the answer) will receive a notification but the thread won't be "bumped" (= "upped"). The first reason is that messages like "Thanks!" or "Amazing!!!" don't add anything valuable to oth...
by john_c
04 Oct 2020, 16:12
Forum: Ask For Help
Topic: Throw an error about a wrong parameter of a function - with the name of this parameter Topic is solved
Replies: 4
Views: 145

Throw an error about a wrong parameter of a function - with the name of this parameter Topic is solved

If you run the following Hotstring() example, Hotstring(":*:btw", "by the way", "WrongArg") there will be thrown an error: Error: Parameter #3 invalid. Specifically: WrongArg How to achieve the same effect (that is, to report the name of the wrong argument) with a custom function? I know there is A_...
by john_c
04 Oct 2020, 08:14
Forum: Ask For Help
Topic: How does AHK handle wrong function arguments?
Replies: 9
Views: 340

Re: How does AHK handle wrong function arguments?

boiler wrote:
04 Oct 2020, 07:21
You are just pointing out that they are both working exactly as documented.
Yes, but why FileOpen() doesn't check whether its 2nd argument is a valid string (that is, either "r", "w", "a", "rw", "h", and some others) the same way as Hotstring() do?
by john_c
04 Oct 2020, 06:18
Forum: Ask For Help
Topic: How does AHK handle wrong function arguments?
Replies: 9
Views: 340

Re: How does AHK handle wrong function arguments?

lexikos , but what about the situations where a function expects a string? Here is a comparison of how FileOpen() and HotString() work. If we use "WrongArg" , the former function returns 0 instead of an object, but the latter throws an error. ; If the 2nd argument is wrong, the function returns 0 M...

Go to advanced search