Jump to content

Classes and Objects?


Dae
 Share

Recommended Posts

I'm in need of a way to organize my variables and functions. It's really getting out of control: I don't like passing variables around all the time when it's not necessary. Is there ANY way for me to hack together something resembling a class so I can call variables and methods of an object? I've got these functions which all use the same variables but for 3 different instances: Account1, Account2, Account3. Account 1, 2, and 3, have variable $positioninglabel, but it's value is different for each case.

I'd appreciate any help here,

Thanks

Edited by Dae
Link to comment
Share on other sites

I'm in need of a way to organize my variables and functions. It's really getting out of control: I don't like passing variables around all the time when it's not necessary. Is there ANY way for me to hack together something resembling a class so I can call variables and methods of an object? I've got these functions which all use the same variables but for 3 different instances: Account1, Account2, Account3. Account 1, 2, and 3, have variable $positioninglabel, but it's value is different for each case.

I'd appreciate any help here,

Thanks

You can't have variables and methods like you want (I don't think), but you could organise things another way. As afr as the variables are concerned, you could have a 3-dimensional array of variables, and design your functions so that they fill one of the dimensions, or part of one of the dimensions depending on how they are called. Then you can refer the the array rather than referring to the object variable, and you could pass this array to the functions for the methods.

So whereas with an object you might have $ans = _Account1.width (or _Account->width depending on the language), you could have $ans = $Account[1][$width].

Or is that not what you mean?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

You can't have variables and methods like you want (I don't think), but you could organise things another way. As afr as the variables are concerned, you could have a 3-dimensional array of variables, and design your functions so that they fill one of the dimensions, or part of one of the dimensions depending on how they are called. Then you can refer the the array rather than referring to the object variable, and you could pass this array to the functions for the methods.

So whereas with an object you might have $ans = _Account1.width (or _Account->width depending on the language), you could have $ans = $Account[1][$width].

Or is that not what you mean?

Hmm, I had thought of that and it would work. The only problem is there won't have methods. So I'll still have to pass something to the functions. In this case I'd have to pass the ID (1, 2, or 3) then. Hmm, doesn't seem like such a bad idea the way you put it. I still wish there were user created objects, that's all I need to complete my script!
Link to comment
Share on other sites

Actually there is a way of creating your own COM objects without the need of an DLL.

The technique is called Windows Script Components or .WSC files.

Propably you are havin some on your current system.

Right click them and select REGISTER. Like you would register any COM object.

This is a old technique but it still works.

I will try to make an example in the EXAMPLE SCRIPT section of this forum.

regards

ptrex

Link to comment
Share on other sites

Actually there is a way of creating your own COM objects without the need of an DLL.

The technique is called Windows Script Components or .WSC files.

Propably you are havin some on your current system.

Right click them and select REGISTER. Like you would register any COM object.

This is a old technique but it still works.

I will try to make an example in the EXAMPLE SCRIPT section of this forum.

regards

ptrex

Do you mean write the functions in VB and then handle them as objects in the Autoit script? It seems a bit against the idea of using Autoit.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Do you mean write the functions in VB and then handle them as objects in the Autoit script? It seems a bit against the idea of using Autoit.

@martin

I should be possible to wrap AU3 functions in .WSC as COM objects.

Since WSC functions as a container, when googling you will find different languages wrapped up.

Jscript, Perl, REXX, Ruby script etc.

regards

ptrex

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...