Hello all,
I had problems to understand the class library found here in the forum
Class Wish List so I thougt that I invest some time to make another one:
The library
Jimulation.ahk is the only file needed to use it.
Jimulation.ahk
A demo that include a class for cars and the demonstration of it
and a browser-class that can be used to open a url either in the default browser or in firefox
can be found here:
Jimulation_demo.ahk
The library is (hopefully) good documented but here I show some aspects of it twice:
it gives in jimulation.ahk only one main function that is used to create classes:
Code:
class(cmd,class,objname,name,value)
Quote:
cmd can be new/set/get or destroy
objname is the object name that is to be used
name is the variable name that is to be set or to be get
value is the value that is wished to be saved in the variable name
It exist helper functions - you can say shortcuts for the commands that are understood by the class function:
Code:
class_new()
Quote:
Function: make a new object instance
the return value is a object instance name that is used by the other class-function commands
Code:
class_set(obj,name,value)
Quote:
Function: set the value from the object instance variable
obj is the return value from a class_new call
name is the variable name of this object instance
value is the value that is saved to this variable
Code:
class_get(obj,name)
Quote:
Function: get the value from the object instance variable
obj is the return value from a class_new call
name is the wished variable of this object instance
Code:
class_destroy(obj)
Quote:
Function: delete a object instance
obj is the return value from a class_new call
it is very easy to make a new class:
Code:
#include jimulation.ahk
dog(name) {
class:=class_new()
class_set(class,"name",name)
}
dog_bark(obj) {
msgbox, % class_get(obj,"name") ": wuff"
}
lassy:=dog("Lassy")
superdog:=dog("Superdog")
dog_bark(superdog)
dog_bark(lassy)
Hope this is interesting for someone