AutoHotkey Community

It is currently May 26th, 2012, 3:02 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 259 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 18  Next
Author Message
 Post subject:
PostPosted: February 3rd, 2009, 5:09 pm 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
Thank you for the new releases, the Menu class, and the examples on your site :)

This is coming along very nicely, and it's becoming more and more clear how helpful this can be.

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 5th, 2009, 4:04 am 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
I fixed a bug in Class.ahk and uploaded the latest file with this fix. It seems that if the LoadDllFunction (which is used to optimize the DllCalls using the optimization in the DllCall docs) returned a "negative address", it wouldn't work. The address now, correctly, return uints so that problem doesn't arrise. Download Class.zip.

Since I was fixing that bug today I haven't started updating the site. I'm going to start on that now. I'm still thinking about how to implement the search features for the container classes. After I update the site, I'm heading back to the project that I was working on (and why I needed this class library and the menu wrapper), so the updates will be driven by the demands of the project and adding to the class library to accommodate them. Of course, if yal hit any bumps when using the library and you think, "i wish it had..." or "this library needs...", then please share. As stated before, I'm not good with thinking stuff up - I'm a top-down thinker. When I hit a wall I find a way around it, I don't think, in advance, what I might do if I hit a wall - so thinking up functionality isn't really suited to my thinking. Rather, when I realize I need something, I add it. For this reason, I want yal to do the same. If you "hit a wall", tell me, and I'll see if I can't find a way around it. I do ask that once you hit the wall once, please DO NOT ram your head into the wall trying to break it down. I am more than willing to assist in getting you over the wall, so please see me as a resource and call on me.

Update:
Actually, I really want to get back to working on my bookmarks manager again - I miss working on it. If anyone posts I'll get an email, so I'm going to hold off on updating the website. Any questions can be posted and I'll offer my assistance. I'm not ditching the website idea, but it's not where my passion is - I love to code. So, I'm going to get back to my project, get my "prep" back, and update the website after that.

I'm starting an online freelance programming buisness, and the bookmarks manager will be the first product, so I really am anxious to finish it, and excited about starting the next project - a program to assist in portabilizing the configuration files of a program (any program that writes their configuration files to a file). So, to say that my attention is elsewhere would be a gross understatement.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2009, 4:36 am 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
tank informed me of GenDocs written by fincs, which is an AMAZING tool to allow creating AHK style docs by parsing AHK code. I'm going to be converting my code - shortly, which I'll then post on the site. This will make it MUCH easier to give yal the docs yal deserve. I plan to reformat the code, write a batch file, and let it go, then upload the results. I'm still working on Multi-control drag/drop, so I'll have to split my time between reformating the code and working on this latest addition.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2009, 6:18 am 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
Very nice, I hadn't noticed GenDocs either--going to convert my libraries to that format as well. I look forward to seeing the generated OOP library docs :)

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2009, 10:54 am 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
Really minor code bug I think, in the Array class.

Array_replaceObject returns the content of %oldValue%, but the function does not seem to create an %oldValue% variable, or retrieve the old value at all in fact.

I believe the return will always be blank.

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2009, 12:18 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
Thank you for that. I modified the code and uploaded the results. You can download the updated zip, here.


What I changed:

If the type is "obj", the "setter" functions return: true (1) if the value was modified, false (0) is the value is not modified (i.e. you set the previous value), or "" (the empty string) to signify an error.

For the basic types, the "setter" functions return the previous value, see the updated Rectangle Class and Rectangle_test for an example of this.

If the type is "robj", the "setter" functions return the old value (or zero, if none). It will also return zero if the new value and old value are the same (i.e. you stored the value that was previously there). This new structure allows easy movement of data between data structures. You can remove it from the old collection (which returns the previous data), and store it in another collection.

Also, fixed a typo in Vector.ahk - it was still calling the old Class_setSize, it now, correctly, calls Class_setUserDefinedSize.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2009, 10:50 am 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
Why is there a Class_setUserDefinedSize function, but no Class_getUserDefinedSize function? Maybe I'm missing something there.

Some of your example classes seem to create their own setUserDefinedSize function within their class and utilize that in the "new" function if no size is given. Others, however, like the Vector class, seem to use the Class library to handle setUserDefinedSize.

Just curious what the best method is, and what the difference is.

Update: Oh, I figured it out. The function in the Class library simply sets the number for a single instance of an object, whereas the function in the class itself simply saves the value for future objects.

Nevermind :)

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2009, 11:03 am 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
Latest update D'oh! I used setValue and getValue instead of setString and getString. All is working well again. Sorry for the fuss! :)

I do have a problem, though, now that I'm finally trying to use the OOP library to rebuild some of my libraries from the ground up.

Starting with my Mod library. I have a very basic setup, but I'm getting crashes.

First, my class:
Code:
;built-in value's getters/setters
Mod_getId(ModObject) {
    return Class_getValue(ModObject, "b1")
}
Mod_setId(ModObject, id) {
    Class_setValue(ModObject, "b1", id)
}

Mod_getType(ModObject) {
   return Class_getValue(ModObject, "b2")
}
Mod_setType(ModObject, type) {
   Class_setValue(ModObject, "b2", type)
}

Mod_getTitle(ModObject) {
   return Class_getValue(ModObject, "b3")
}
Mod_setTitle(ModObject, title) {
   Class_setValue(ModObject, "b3", title)
}

Mod_getFileName(ModObject) {
   return Class_getValue(ModObject, "b4")
}
Mod_setFileName(ModObject, fileName) {
   Class_setValue(ModObject, "b4", fileName)
}

Mod_getFileDate(ModObject) {
   return Class_getValue(ModObject, "b5")
}
Mod_setFileDate(ModObject, fileDate) {
   Class_setValue(ModObject, "b5", fileDate)
}

;set the default user-defined size to use if none is specified
Mod_setUserDefinedSize(Size = "")
{
    static UserDefinedSize = 0

    if (Size != "")
        UserDefinedSize := Size

    return UserDefinedSize
}

Mod_new(id, type = "", title = "", fileName = "", fileDate = "", UserDefinedSize = "") {
   static BuiltInSize := 5
   
   if (UserDefinedSize = "")
      UserDefinedSize := Mod_setUserDefinedSize()
   
   if (fileName = "")
         fileName := id
   
   if (ModObject := Class_Alloc(4 * UserDefinedSize + BuiltInSize)) {
      
      ; Set class values
      Class_setClass(ModObject, Mod_initClass())
      Class_setBuiltInSize(ModObject, BuiltInSize)
      Class_setUserDefinedSize(ModObject, UserDefinedSize)
      
      ; Built-in values
      Mod_setId(ModObject, id)
      if (type != "")
         Mod_setType(ModObject, type)
      if (title != "")
         Mod_setTitle(ModObject, title)
      Mod_setFileName(ModObject, fileName)
      if (fileDate != "")
         Mod_setFileDate(ModObject, fileDate)
   }
   
   return ModObject
}

Mod_destroy(ModObject) {
   if (!ModObject)
      return
   
   if !Class_readyToDelete(ModObject)
      return false
   
   ; Clear built-in fields
   Mod_setId(ModObject, 0)
   Mod_setType(ModObject, 0)
   Mod_setTitle(ModObject, 0)
   Mod_setFileName(ModObject, 0)
   Mod_setFileDate(ModObject, 0)
   
   ; Clear user-entered fields
   Mod_destroy_private(ModObject)
   
   ; Clear class values
   Class_setBuiltInSize(ModObject, 0)
   Class_setUserDefinedSize(ModObject, 0)
   
   Class_setClass(ModObject, "")
   
   Class_Free(ModObject)
   
   return true
}

Mod_destroy_private(ModObject) {
   
}

Mod_initClass() {
   static ClassName := "Mod"
   
   return &ClassName
}


Next, the test file that's crashing:
Code:
#Include Mod.ahk

Mod1 := Mod_new("Anchorage.esm", "FO3", "Operation Anchorage")

MsgBox,% "Mod Title: " . Mod_getTitle(Mod1)


I've tried wrapping the three parameters with String_New() in case that was required, but it still crashes.

When I remove the MsgBox line, it does not crash. So it seems to be something with getTitle.

I probably made a stupid mistake somewhere.

Update:
And it works fine if I leave everything but the 'id' parameter out of my call to the Mod_new function. I can then retrieve the ID.

If I don't wrap the ID parameter with String_new(), I get 0 returned. If I do wrap the parameter with String_new(), I get an integer returned (presumably a memory location?). I thought that the wrappers were supposed to automatically unwrap to their original values when gotten?

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2009, 6:11 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
I'm checking it out.

In the meantime, I just wanted to let you know the "Class_getUserDefinedSize function" is the setUserDefinedSize function in the class (passing zero parameters) - UserDefinedSize := Mod_setUserDefinedSize() returns the current userDefinedSize (for the current Class).

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2009, 6:36 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
Ok, saw a few things.

1) static BuiltInSize := 5 - BuiltInSize MUST be in bytes - from the current construction, you are using uints (the default) - which take 4 bytes each - so BuiltInSize = 20.

2) You MUST use get/setString for String types, or get/setValue with type = "String". They take up 4 bytes in the object - regardless of the String's size, since only the address is stored in the object. The String is stored elsewhere - you don't have to worry about that though - just remember to use get/setString or get/setValue with type = "String".

You seem to have Id, and the others storing as uints, but passing Strings, THIS WILL NOT WORK AS YOU EXPECT (they store as zeros). Also, when you use Strings, to clear String types, pass "" (the empty string) for the "set value" - passing 0 will create a String whose contents are "0".

3) If you don't need user-defined values, I would suggest not allowing UserDefinedSize as a parameter, and instead making a static value, UserDefinedSize = 0, in the Mod_new function.

You can then comment out Mod_destroy_private - since that is designed to free the memory for any user-defined objects or strings used. Your current design WILL have memory leaks if the UserDefined size is used and String or Object types are stored; numbers are fine, no memory leaks will occur - they just won't get set with zeros when your mod object is destroyed.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Last edited by animeaime on February 21st, 2009, 7:01 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2009, 6:59 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
Oops, sorry, didn't see your question at the end.

bmcclure wrote:
I get an integer returned (presumably a memory location?). I thought that the wrappers were supposed to automatically unwrap to their original values when gotten?

They do unwrap when stored in a member of type "obj. Use "obj" types for Class objects; you can use uint (the default), if you only want it to be a pointer to a Class object - which is, in effect, what you did. See the Cdll Class for an example. Both the <previous> and <next> members are uints - in this case, pointers to a Cdll_Node object (or the Cdll root for the "ends"); where as the <node> member is an object (type "obj").

If you store a Wrapper object as a non-obj type, it won't unwrap, because the "unwrapping" is done by the getValue function. It sees an object type, it realizes it's a wrapper, and then unwraps it. Since you stored the String object in a uint, it acts as a pointer to a String object and returns its memory address (a uint).

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2009, 7:26 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
I'm sure there is a record for longest continous posts, and no I'm not going for it, and so I appologize though for this. I separated the posts because they are separate "topics" - the last post was because I forgot to answer their question.


A progress report. I'm going to add the ability to manipulate single bits - for those that want / need to use bit flags as data members - they will be allowed for both built-in and user-defined size. They will be backward-compatable, so no worries.

The new syntax will be as follows:

[a|b]Word[a-c]-Bit.

The leading "a" is described below (and rarely used)
The leading "b" is for built-in values (only)
Omiting them is for user-defined values (only).

Just a note, these are NOT case-specific - "b" and "B" are the same

Word is the current word (4 byte group) - starts at 1.
Bit is the bit number - starts at 1.
[a-c] allows manipulating individual bytes.

The "b" type automatically adjusts for the 8 byte "class values".
Likewise, the user-defined values adjust for both the "class values" and any built-in values - provided you set the built-in size correctly (measured in bytes).

Ex:
1a is the first word, 2nd byte (for user-defined values)
b1a is the first word, 2nd byte (for built-in values)


Note: Add the "b" type for built-in values.

1 is the first word (1st byte) - for user-defined values.
1-1 is the first word, (1st byte), 1st bit.
1a-1 is the first word, 2nd byte, 1st bit.

Remark: only the specified bit will be modified.
I'll add an example of this to the Rectangle Class and upload it.


The "a" type - use with caution:

"a" allows accessing the memory directly - not for normal use (meant for container development and other, rare, instances, where the "class values" are not part of the Class object). DO NOT USE unless you know what you are doing - they are not needed for normal cases. Also, in this case, "Word" becomes the byte offset (starting at 0). The bit value still starts at 1.


Also, now, I'm focusing on the website purely. I thought that since there may be others trying to convert their code to OOP, it would be good to modify the website. Also, with fincs gendocs, it will be very easy to generate docs for the website. Hopefully I can get that up soon.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2009, 9:30 pm 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
Thanks for working on the site :) The more documentation there is, the easier it will be to convert my libs into classes.

Currently working on converting my FOMS (Fallout 3 Mod Sorter) AHK utility to utilize OOP, and I think I'm starting to get in the swing of pseudo-OOP with AHK :)

Where I used to have a jumbled mess of Fallout Mods all accessed using either XML values or script variables, now I've got a clear set of classes, class values, and related functions, keeping everything tidy and easily expandable.

I'm even utilizing XMind to visualize my object interactions and structure them, and it's working really great.

It's truly a good feeling to get a group of classes finished and have their interactions be so much simpler and better defined than the old libs they replaced.

Thanks again for building and maintaining these functions!

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2009, 9:34 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
No problem, glad to do it. It might be some time before everything is updated and all - have a TON on my plate. I'm so busy that I actually have to prioritize :D.

I take it that means it works now?

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2009, 10:27 pm 
Offline

Joined: November 24th, 2007, 9:07 pm
Posts: 774
Hmm... OOP-related question for you.

I'm setting up my Mod class. I previously based it on the Node class, because each Mod represents one single mod.

I also have the following classes: ModConflicts, ModDependencies, and ModMessages

Each Mod object can have any number of ModConflicts, ModDependencies, and ModMessages assigned to it.

I was thinking about creating three built-in vars: conflicts, dependencies, and messages. Each one would be a Vector object containing the sub-items.

Is there a better way to do this? I'm not sure if conflicts and dependencies will be freed properly if I delete the Mod object, as I'm assuming I'll have to loop through each Vector object and delete its sub-objects?

_________________
Ben

My Trac projects
My Wiki
[Broken] - My music


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 259 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 18  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group