Sign in to follow this  
Followers 0
Shevilie

Objects ? (Not COM)

9 posts in this topic

#1 ·  Posted (edited)

Well the problem is that i often use some kind of objects in my programs..

I've used arrays until now, but they are not very usefull (hard to use and not very handy in naming)

Example (As i do now very basic)

Dim Appointment[3]

Appointment[0] = "2007/01/17 12:00:00" ;Starttime
Appointment[1] = "2007/01/17 13:00:00" ;Endtime
Appointment[2] = "I need to go to the doctor" ;TiteloÝ÷ Ùg¥Øb²+j̲Z'«"¶Ê'*'yئz{"¢{a¢è!²Ø¥z-½êòºÇºY[yÆ®±ì¨º¯zÚ+zg¦mêíí"²ËZ®Ö§vØ^Ö+×­q8^¦ºé¬µªí³^ zÙ¨­é^½él!ø°j{^u©b²Ú  )¦§¶g§¶Æ®¶­sdFÒöçFÖVçDÆ7E³%Õ³5Ð ¤öçFÖVçDÆ7E³Õ³ÒÒgV÷C³#róór#££gV÷C²µ7F'GFÖP¤öçFÖVçDÆ7E³Õ³ÒÒgV÷C³#róór3££gV÷C²´VæGFÖP¤öçFÖVçDÆ7E³Õ³%ÒÒgV÷C´æVVBFòvòFòFRFö7F÷"gV÷C²µFFVoÝ÷ ØÚ0ø¡j÷~éܶ*'¶­­ën®{)íéí¶§Æ§¶­Ø§¶¥ËZ²X¤zØb±ëÞØhºméî·«²f­r趫yªëk+(p)¦§¶g§´¸¬·

And then you can use it like Appoinment.Start etc I dont need the objects to handle methods, though that would rule :P

Well any got any comment on this or any Ideas / UDF / Or just something i overlooked that might help me :)

(Suggestion to make the array thingy work better is also welcome :D)

Edit: To all the remember what has wich number i sometimes use

Global Const $Start = 0

Global Const $End = 1

Global Const $Titel = 2

etc

Though as you might guess this is not a good way to do it, and it make further developent very hard because other objects might also have a start and that object might be larer or smaller, well you get the picture i hope :D

Edited by Shevilie

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I do not believe that is possible as AutoIt is not an object oriented programming language. To simplify what you are doing now, take a look at the enum function. You won't have to remember which index corresponds with which attribute.

Edited by ame1011

[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]

Share this post


Link to post
Share on other sites

nope, definitely not possible in autoit.


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

I cant really see how Enum (http://www.autoitscript.com/autoit3/docs/keywords/Enum.htm) would help me.. Just another way to do the variable stuff im doing now (though a little easier :D) but i still get in to trouble when i use different kind of object with simmialary (cant spell it :D) variables, because you have to remember which is which..

I might have 4 different objects all with some kind of start variable.

Local Ob1[2]

Ob1[0] = 11:00:00 ;Start

Local Ob2[5]

Ob2[3] = 12:00:00 ;Start

As you see i cant make a variable like this $start= 0.. I need to make two and then you have to remember which "start" is for which object.. hope you can follow me :)


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

nope, definitely not possible in autoit.

Well thx for the straight answer :) Well got any UDF to arrays (except for the one in the udf docs, since its not very usefull to multidimensional arrays)


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

I don't see anything with your array issue that ReDim and a For/Next loop like your suggesting for your COM wouldn't solve. Maybe a custom array sort may be all you are looking for.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Well then I'll have to begin making my own Array UDF :D Well if I come up with something good I'll send it back :)


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Well then I'll have to begin making my own Array UDF :D Well if I come up with something good I'll send it back :)

Thinking about this more, if I were using a GUI, I would just use IniReadSection() to give me my results, and split the categories up like:

Date Start:

Date End:

Time Start:

Time End:

Importance:

Appointment:

Note:

Then in my ini, have iniwrite do something like:

[Appointments]

1=2007/01/22|2007/01/22|12:00|13:00|High|Doctors Appointment|VD Test

StringSplit the above with "|" as the delimiter, and sort the date, time or priority settings in the custom array sort I made.

This way I wouldn't have to customize my arrays specifically, I could have variant sizes, and IniReadSection() would always return my UBound() for on the keys for me.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Here is a function I wrote to help manage two-dimensional arrays ($array[][]) which may be of use to you. It is called like this

_AlterArray($MyArray,$Vector1,[$Vector2,[$InsOpt]])

where $MyArray is the array which you want to manipulate, $Vector1 is the first index passed, $Vector2 is the optional second index passed, and $InsOpt can change the operation of the function.

Both $Vector1 and $Vector2 refer to indexes of the first dimension ($array[][])

Here is how it works. If you specify $Vector1, but not $Vector2, all data at index [$Vector1] is deleted, and all subsequent data is moved up one position. (the that was at $array[$Vector1+1][0] is now located at $array[$Vector1][0], as is all data that was at $array[$vector1+1][1], etc., and all subsequent data in subsequent index locations are moved up as well)

If $Vector2 is specified, the all of the data in all indexes of the second dimension at both which correspond to $array[$Vector1] and $array[$Vector2] are swapped. For instance, what was at $array[$Vector1[0] is now at $array[$Vector2][0], and so on and so forth

If $Vector2=0 (not blank, actually set to zero) then one of two things will occur. If $InsOpt does not equal -1 (can be anything else, including unspecified) the data in $array[0] is INSERTED into index $Vector1. The data which previously occupied $Vector1 will be moved down one position, as will all subsequent data. If $InsOpt=-1, then the data in $Vector1 is overwritten by the data in $array[0] and is lost.

Because of this last feature, index 0 (of the first dimension) is assumed to be a placeholder... and so I wouldn't recommend using it to store any important info, unless you plan on "inserting" that info into another vector using the previousely explained feature.

Func _AlterArray(ByRef $aArray, $APos1, $Apos2=-1, $AInsert=0)
    Switch $Apos2
        Case -1
            for $AACount=$APos1 to UBound($aArray, 1)-2
                for $AACount2=0 to UBound($aArray, 2)-1
                    $aArray[$AACount][$AACount2]=$aArray[$AACount+1][$AACount2]
                Next
            Next
            for $AACount2=0 to UBound($aArray, 2)-1
                $aArray[$AACount][$AACount2]=""
            Next
        Case 0
            Switch $AInsert
                Case -1
                    for $AACount=0 to UBound($aArray,2)-1
                        $aArray[$APos1][$AACount]=$aArray[0][$AACount]
                    next
                Case Else
                    for $AACount=UBound($aArray, 1)-1 to $APos1+1 Step -1
                        for $AACount2=0 to UBound($aArray, 2)-1
                            $aArray[$AACount][$AACount2]=$aArray[$AACount-1][$AACount2]
                        Next
                    Next
                    for $AACount2=0 to UBound($aArray, 2)-1
                        $aArray[$APos1][$AACount2]=$aArray[0][$AACount2]
                    Next
            EndSwitch
        Case Else
            for $AACount=0 to UBound($aArray, 2)-1
                $aArray[0][$AACount]=$aArray[$APos1][$AACount]
                $aArray[$APos1][$AACount]=$aArray[$Apos2][$AACount]
                $aArray[$Apos2][$AACount]=$aArray[0][$AACount]
            Next
    EndSwitch
    
    Return
EndFunc

This function was created based on several assumptions which are specific to the script in which I used it. (Specifically, that all entries in index 0 of the first dimension are used exclusively as a placeholder. This means $array[][0], $array[][1], etc.) Anyway, I hope you can adapt it to your needs and make use of it.

Note! This version of the function is untested, as I just edited it in order to remove references which are irrelevant when not used in my script.

Edited by improbability_paradox

Share this post


Link to post
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
Sign in to follow this  
Followers 0