what is a method

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
joefiesta
Posts: 494
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

what is a method

Post by joefiesta » 02 Jul 2022, 09:35

what is a method?

specifically, I would like to be pointed to WHERE IN THE DOCUMENTATION this question is answered, because if it is there, I can't find it.

Descolada
Posts: 1077
Joined: 23 Dec 2021, 02:30

Re: what is a method

Post by Descolada » 02 Jul 2022, 09:49

You mean this?
https://www.autohotkey.com/docs/Objects.htm
An object in AutoHotkey is an abstract datatype which provides three basic functions:

GET a value.
SET a value.
CALL a method (that is, a function which does something with the target object).


User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: what is a method

Post by mikeyww » 02 Jul 2022, 09:54

Additional approaches & answers to
WHERE IN THE DOCUMENTATION
image220702-1054-001.png
AutoHotkey documentation
image220702-1054-001.png (217.61 KiB) Viewed 2329 times

joefiesta
Posts: 494
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: what is a method

Post by joefiesta » 02 Jul 2022, 10:14

thanks for the answers!! (And, yes, I was reading the OBJECTS section.) My biggest problem was that METHOD is not explicitly defined. It's only definition is found at OBJECTS here:
An object in AutoHotkey is an abstract datatype which provides three basic functions:
•GET a value.
•SET a value.
• CALL a method (that is, a function which does something with the target object).
I think
"CALL a method (that is, a function which does something with the target object)"
is poorly worded. I think it should read:

"CALL a method (a function which does something with the target object)."

Additionally, you would think that METHOD should have it's own entry in the INDEX for the doc. (but, I'm tired of trying to have the doc changed for such small things.)

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: what is a method

Post by Lepes » 02 Jul 2022, 19:18

I am learning Arduino and most things I need to google for C or C++ reference, because those concepts I search for, is from C and C++ instead of Arduino. In my opinion, you are in the same case: you should search for "Object Oriented Programming" (OOP) concepts/techniques. On the other hand, nobody says that AutoHotkey was a manual to learn neither OOP nor learning how to create a class. Object Pascal was a programming language used on schools to teach programming.

Code: Select all


f = FileOpen(....);
f.Read(....);
f.Write(....);

A method is a function that belongs to an instance object (There are exceptions... but forget to understand this first)
FileOpen is a function
f.Read "is a function that need to be preceded by the object to wich it belongs" ( I mean "f." prefix) and then, you change the word "function" for "method".

So whenever you say "I'm calling a method" "I'm creating a method" you are in a "class enviroment" (you are creating a class with properties and so on). If you say "I'm creating a function" you are not using "class" keyword. It is just Semantics.

function HelloWorld!

Code: Select all


HelloWorld(){
   msgbox, Hello World
}
Method HelloWorld:

Code: Select all

class World
{
  ... 
  
  HelloWorld   {
   msgbox, Hello World
   }
}

myWorld = World()
myWorld.HelloWorld()

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: what is a method

Post by BoBo » 02 Jul 2022, 23:59

@Lepes :thumbup:

lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: what is a method

Post by lexikos » 03 Jul 2022, 00:30

joefiesta wrote:
02 Jul 2022, 10:14
My biggest problem was that METHOD is not explicitly defined.
I disagree...
Methods
Methods are functions which operate on a particular object. While there can only be one function named Send (for example), there can be as many methods named Send as there are objects, as each object (or class of objects) can respond in a different way. For this reason, the target object (which may be a variable or sub-expression) is specified to left of the method name instead of inside the parameter list. For details, see Object Protocol.
Source: Concepts and Conventions | AutoHotkey
Additionally, you would think that METHOD should have it's own entry in the INDEX for the doc.
Sure.
(but, I'm tired of trying to have the doc changed for such small things.)
Thank you for tirelessly suggesting improvements to the documentation. Might I point out, that every time you complain that it is so difficult, you are sabotaging your efforts? Your negativity is contagious and not productive. Making such a small change as adding something to the index and submitting a pull request should be easier than writing and complaining about it. If you make a suggestion that seems worthless, it is easy to ignore. If you make a pull request that seems worthless but is still acceptable, it is easier to merge then respond in the negative. (I'm speaking generally, not about this suggestion.)

joefiesta
Posts: 494
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: what is a method

Post by joefiesta » 03 Jul 2022, 10:50

@Lexicos
thanks for point out exactly WHERE method is defined. I could not find that, although I will admit I did not look at every entry where the word METHOD is found.

And, thank you for agreeing an INDEX entry would be appropriate.

Sorry about my picayune suggestions. Yes, they are just that. But, please notice, I did not make an entry in the "suggestions for documentation changes" section. I am trying to get over being burdensome. It's not easy. I can't get over having read IBM documentation for 20 years--documentation for mainframes which was virtually flawless and they listened to every suggestion, no matter how tiny.

joefiesta
Posts: 494
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: what is a method

Post by joefiesta » 03 Jul 2022, 10:55

@Lepes
thanks for your post.

I know nothing about C and OOP. I learned fortran, basic, cobol, REXX, APL and assembler--all mainframe oriented and all from the good old days.

I have realized that an extremely large amound of the structure and nature of AHK is related to C and OOP, but at this stage--I'm 71--I'm not ready to learn either. Nevertheless, I will look into to OOP. I have always steered away from Objects, Methods and many of the other more obtuse aspects of AHK.

RussF
Posts: 1229
Joined: 05 Aug 2021, 06:36

Re: what is a method

Post by RussF » 03 Jul 2022, 11:00

IBM has a massive team of engineers/technical writers that all get 6-figure salaries to maintain documentation that IBM charges millions for.

@Lexicos gets paid nothing to maintain AHK - a fantastic product for which you pay $0.00. There IS a difference.

Thank you @Lexicos!

Russ

User avatar
boiler
Posts: 16707
Joined: 21 Dec 2014, 02:44

Re: what is a method

Post by boiler » 03 Jul 2022, 12:24

I am sure @Lexicos appreciates it! Thanks also to @lexikos!

joefiesta
Posts: 494
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: what is a method

Post by joefiesta » 03 Jul 2022, 13:00

Hard to believe. Lexikos seems to do an INCREDIBLE amount for AHK. Hard to believe he does it gratis. Kudos to him. I like and use AHK SO MUCH, I'd contribute. But I guess if it is all maintained voluntarily, there is no entity to which to contribute.

But, then again, if his job--assuming he is not retired--is anything like mine was, he has lots of free time!!!

User avatar
boiler
Posts: 16707
Joined: 21 Dec 2014, 02:44

Re: what is a method

Post by boiler » 03 Jul 2022, 13:05

You can donate to The AutoHotkey Foundation, which covers the costs of maintaining this website, if you wish. Donation link is on that page.

joefiesta
Posts: 494
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: what is a method

Post by joefiesta » 03 Jul 2022, 13:39

thanks. I just contributed. I had no idea about the foundation.

Yes, it's only to maintain the website--something about which I have mixed feelings.
Specifically, I have always felt that there are WAY, WAY too many requests for help.
Yes, part of that is people's inherent laziness. But, I feel a big part of it is that it is very difficult to learn AHK. And, I think that is in part due the diffculty of wading through the documentation. Don't get me wrong. AHK is very, very complicated (and powerful!!!) and documenting it's entirety is a truly MONUMENTAL task.

I once tried to get involved in supporting AHK. I would like to help document. But, I received virtually no support in my effort to stick my foot in the door. That was a number of years ago. Maybe that has changed. Someone please correct me if I am wrong.

I think the documentation needs far, far more examples. And, not just example of the code, but more about what it is trying to accomplish. Let me give one short example. I tried to understand why and to what advantage using TRY, THROW and CATCH would improve my coding. But, the examples provide no explanation of the context in which these commands can be employed to simply coding. I'm an old-fashoned programmer. I just write things like "if Error_level... then this... else this... call a error subprogram.. shows an error message... write to a log file.... etc etc".

AHK would benefit from a User's guide. I believe there should be VERY SHARP distinction between hard-code documentation (facts, facts, facts) and stuff to assist in using those facts. Harping again back to my IBM days, the best command references were almost always accompanied by a completely separate and distinct USER's GUIDE.

I feel a User's guide could also tremendously decrease the number of questions which are asked. It seems there is NO END to some of the same questions being asked an infinitude of times on the forum. So much duplication of effort greatly saddens (and appals) me. I know this is a pipe dream. But, who knows where AHK may go. Personally, I think it's the best thing since sliced bread.

User avatar
boiler
Posts: 16707
Joined: 21 Dec 2014, 02:44

Re: what is a method

Post by boiler » 03 Jul 2022, 16:28

joefiesta wrote: I tried to understand why and to what advantage using TRY, THROW and CATCH would improve my coding. But, the examples provide no explanation of the context in which these commands can be employed to simply coding. I'm an old-fashoned programmer. I just write things like "if Error_level... then this... else this... call a error subprogram.. shows an error message... write to a log file.... etc etc".
I'm not sure you were looking for an answer to this since you were just throwing out an example, but in case it helps: Try is very different than checking the value of ErrorLevel. Try captures errors that otherwise would halt the script execution and display an error dialog box. Instead of the script stopping, using Try allows your script to continue executing even if the error occurred, and Catch allows your script to react specifically in those instances where an error occurred. When ErrorLevel is set indicating that some "error" occurred, it's not the type of error that would halt script execution. If you don't check it and act upon it, your script continues merrily along as if nothing occurred. ErrorLevel is usually just information anyway, not a true error, such as a timeout expiring or an image not being found.

I happen to think that the documentation is very thorough and beyond what I've seen as official documentation for any other language, including this example where it seems pretty clearly differentiated from ErrorLevel to me (as excerpted from the first sentence of its documentation page below), but I understand not everyone is as comfortable absorbing concepts from documentation-style writing as opposed to tutorial-like prose.
"Guards one or more statements (commands or expressions) against runtime errors"

Rohwedder
Posts: 7510
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: what is a method

Post by Rohwedder » 03 Oct 2022, 01:50

Hallo,
methods and classes are pure fantasy!
Therefore their script examples are pseudo code without recognizable function like the above from Lepes or https://www.autohotkey.com/docs/Objects.htm#Custom_Classes.

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: what is a method

Post by Lepes » 04 Oct 2022, 06:12

Rohwedder wrote:
03 Oct 2022, 01:50
methods and classes are pure fantasy!
OMG, I have lived in a fantasy for 20+ years..... I can not deal with it :lol: :lol:

Rohwedder
Posts: 7510
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: what is a method

Post by Rohwedder » 04 Oct 2022, 10:15

René Descartes: Since we cannot even tell for sure whether we are dreaming, then how can we know for certain any truth about the world in which we seem to live?
That methods and classes are pure fantasy was sarcastic, but script examples that have no discernible function other than syntax errors are useless:

Code: Select all

class ClassName extends BaseClassName
{
    InstanceVar := Expression
    static ClassVar := Expression

    class NestedClass
    {
        ...
    }

    Method()
    {
        ...
    }

    Property[]  ; Brackets are optional
    {
        get {
            return ...
        }
        set {
            return ... := value
        }
    }
}

User avatar
boiler
Posts: 16707
Joined: 21 Dec 2014, 02:44

Re: what is a method

Post by boiler » 04 Oct 2022, 11:36

Scientists say that there is a 50-50 chance we are living in a simulation, so it's possible that nothing (in our universe) is real and everything we are doing is just someone's fantasy!

Post Reply

Return to “Ask for Help (v1)”