Jump to content

Recommended Posts

Posted

I did the same on my JSONgen lol :lmao:

Although using AutoItObject classes is a nice deal, creating classes is not so intuitive (I ever did it). Of course I don't blame AutoItObjects for it, even because they were limited to what AutoIt supports. I wouldn't blame AutoIt language developers too, since it was originally made just as a replacement for Microsoft ScriptIt, nothing more than a tool to automate tasks, and not creating fully-functional softwares. But AutoIt is, today, much more than what it was once. Although there are many things I dislike (like the arrays approach), I've adopted AutoIt as my main work language due to its productivity (let's just say that what I can do with 1 month in Java or C, I can do in 1 week or less in AutoIt...). I hope the AU3 coders can see soon more improvements in the languages. For starting, a native OOP support would be nice :)

My stuff

  Reveal hidden contents

 

Posted

I have been coding like this for a couple of years. So when I saw your Json script, I was pleasantly surprised.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

What should we call this as? "Array-oriented programming"? lol

Despite the jokes, I really think it could be considered some kind of "standard". At least until we have native AutoIt OOP support...

My stuff

  Reveal hidden contents

 

Posted

AutoIt is based on BASIC, so it's out of scope for Jon to make it OOP.

How about AAOP - AutoIt Array Oriented Programming? By the way did you come up with the idea on your own or see a post by me or Valik?

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted
  On 7/10/2015 at 1:21 PM, jaberwacky said:

One of FreeBasic's paradigms is object orientation.

I am talking about the procedural era

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Can or can't?

It's about the approach of encapsulating data with methods, not the execution. 

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted
  On 7/10/2015 at 1:18 PM, guinness said:

AutoIt is based on BASIC, so it's out of scope for Jon to make it OOP.

Well, that's not so good to know it :(

 
  Quote
How about AAOP - AutoIt Array Oriented Programming? By the way did you come up with the idea on your own or see a post by me or Valik?
Truly, I would write that using AutoItObject, but I thought that putting an additional DLL just for generating JSONs would sound strange. So I started coding it so on my own...

My stuff

  Reveal hidden contents

 

Posted
  On 7/10/2015 at 1:34 PM, Jefrey said:
 

Truly, I would write that using AutoItObject, but I thought that putting an additional DLL just for generating JSONs would sound strange. So I started coding it so on my own...

Cool

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

For several years I develop my skills intensively.
Since I took a lot of programming style of @guinness (by the way of working together on a project),.

You can find this ie. in my PDFCreator.au3

  Reveal hidden contents

 

 

And in most of my new or refreshed projects.

 

I also received a lot of concepts based on the mode of action different libraries (Debenu, Chillkat), ie. The way the declaration of variables, parameter, or a return results ie in SmtpMailer.au3

  Reveal hidden contents

 

 

 

 

 

How well I remember and as far as I understand, it's all about being here right now talking, we derive in part from the concept that @Valik, liked to call "API"

EDIT: Am I right on this?

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 7/10/2015 at 2:56 PM, mLipok said:

Since I took a lot of programming style of @guinness

Just sharing the knowledge

  On 7/10/2015 at 2:56 PM, mLipok said:

How well I remember and as far as I understand, it's all about being here right now talking, we derive in part from the concept that @Valik, liked to call "API"

EDIT: Am I right on this?

Yes, but his version is slightly different in that it only works with a single "data store", whereas this can be created with many by calling the "constructor"

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Here is my take on simple OOps in Autoit.

Func ObjErrFunc()
    Msgbox(0,"*COM ERROR*",$ObjErr.description&@LF&$ObjErr.windescription&"Line "&$ObjErr.scriptline)
Endfunc



Func Person($sName, $iAge)
    $sd.Add($sd.Count,$sName)     ;Property
    $sd.Add($sd.Count,$iAge)      ;Property
    Return $sd.Items              ;Array Properties
EndFunc



Func Person_SetName(ByRef $hPerson, $sName)
    $hPerson[uBound($hPerson) - 2] = $sName

EndFunc



Func Person_GetName(ByRef $hPerson)
    Return $hPerson[uBound($hPerson) - 2]
EndFunc



Func Person_SetAge(ByRef $hPerson, $iAge)
    $hPerson[uBound($hPerson) - 1] = $iAge

EndFunc



Func Person_ToString(ByRef $hPerson)
    Return StringFormat('Name: %s, Age: %i', $hPerson[uBound($hPerson) - 2], $hPerson[uBound($hPerson) - 1])
Endfunc



    global $ObjErr = ObjEvent("AutoIt.Error","ObjErrFunc")
    global $sd     = ObjCreate("Scripting.Dictionary")

    local $hP1 = Person('John', 30)
    MsgBox(64, 'Person 1', Person_ToString($hP1))

    Local $hP2 = Person('James', 36)
    MsgBox(64, 'Person 2', Person_ToString($hP2))

    Person_SetAge($hP2, 45)
    MsgBox(64,'Person 2 - Revised',Person_ToString($hP2))

    Person_SetName($hP1, 'Michael')
    MsgBox(64,'Person 1 - Revised',Person_ToString($hP1))

    MsgBox(64,'Get Name Person 1',Person_GetName($hP1))

    Local $hP3 = Person('Amanda', 35)
    MsgBox(64, 'Person 3', Person_ToString($hP3))

This way I can add any number of Name's and Age's.

Posted
  On 7/10/2015 at 4:52 PM, xroot said:

This way I can add any number of Name's and Age's 

I think you misunderstood the purpose. Why would a Person for example have multiple ages? They wouldn't. How does your example translate from something like this?

// Java - Person example
class Person {
    // The underscore is to denote they're member variables, as I hate writing this all the time
    private int _age;
    private String _name;
    
    public Person(String name, int age) {
        _age = age;
        _name = name;
    }
    
    public int getAge() {
        return _age;
    }
    
    public String getName() {
        return _name;
    }
    
    public void setAge(int age) {
        _age = age;
    }
    
    public void setName(String name) {
        _name = name;
    }
    
    @Override
    public String toString() {
        return String.format("Name: %s, Age: %d", _name, _age);
    }
}

 

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Or in C#

// C# - Person example
class Person 
{
    // Properties. How lovely these are! =)
    public int Age = { get; set; }
    public string Name = { get; set; }
    
    public Person(string name, int age)
    {
        Age = age;
        Name = name;
    }
        
    public override string ToString()
    {
        return String.Format("Name: %s, Age: %d", Name, Age);
    }
}

 

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)
  On 7/10/2015 at 4:09 PM, guinness said:

Just sharing the knowledge

Thanks for the correction (as usual language barrier took its toll)

  On 7/10/2015 at 4:09 PM, guinness said:

Yes, but his version is slightly different in that it only works with a single "data store", whereas this can be created with many by calling the "constructor"

You mean that @Valik example can open only single SciTE and work only with this single instance ?

btw.

I like the concenct concept of using $PERSON_GUID in your example 

 

Edited by mLipok
wording

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Lets assume that his example can only spawn one SciTE. In that case if I wanted a second process of SciTE it wouldn't be possible. My approach you can have that.

I use the GUID as a means to ensure that if a user passes an array with the exact dimensions, that it shouldn't fail as I have a check of whether one element contains the GUID. It's not full-proof, but better than nothing.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)
  On 7/10/2015 at 1:34 PM, Jefrey said:
Truly, I would write that using AutoItObject, but I thought that putting an additional DLL just for generating JSONs would sound strange. So I started coding it so on my own...

If you are talking about the autoitobject.dll file, then that's for debugs or something, you don't need that file. Just skip it.

Edited by AdmiralAlkex
  • 1 year later...
Posted

Even after nearly 2 years, I still like this approach to writing AutoIt code

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
×
×
  • Create New...