Okay, I gave this my first try, and... well, some things worked, and then I wrote code that literally crashes AHK. XD
I decided to organize things a little differently (basically an array of each type of value instead of an array of items), but I'm not adverse to changing that. In any case, I got the basics working; the part that is stumping me is assigning and retrieving data from the class. I though I would use a get/set property for that, but I'm not sure it will do what I need. Here is the code I have so far:
Code: Select all
class Items
{
__New()
{
this.Barcode := []
this.Brand := []
this.Product := []
this.PromoRetail := []
this.RegularRetail := []
this.Tax := []
this.CRV := []
this.Organic := []
this.GlutenFree := []
this.Size := []
this.SizeType := []
}
TestSet()
{
this.Barcode[1] := 11111122222
this.Brand[1] := "BRAND NAME"
this.Product[1] := "PRODUCT NAME"
this.PromoRetail[1] := 3.99
this.RegularRetail[1] := 5.99
this.Tax[1] := true
this.CRV[1] := false
this.Organic[1] := false
this.GlutenFree[1] := true
this.Size[1] := 10
this.SizeType[1] := "OZ"
}
Product[ItemNum]
{
get {
return { Slot : ItemNum, Barcode : this.Barcode[ItemNum]
, Brand : this.Brand[ItemNum], Product : this.Product[ItemNum]
, PromoRetail : this.PromoRetail[ItemNum], RegularRetail : this.RegularRetail[ItemNum]
, Tax : this.Tax[ItemNum], CRV : this.CRV[ItemNum]
, Organic : this.Organic[ItemNum], GlutenFree : this.GlutenFree[ItemNum]
, Size : this.Size[ItemNum], SizeType : this.SizeType[ItemNum] }
}
set {
if value[Slot] := ""
return
else
{
this.Barcode[Slot] := value[Barcode]
this.Brand[Slot] := value[Brand]
this.Product[Slot] := value[Product]
this.PromoRetail[Slot]:= PromoRetail[Barcode]
this.RegularRetail[Slot] := RegularRetail[Barcode]
this.Tax[Slot] := Tax[Barcode]
this.CRV[Slot] := CRV[Barcode]
this.Organic[Slot] := Organic[Barcode]
this.GlutenFree[Slot] := GlutenFree[Barcode]
this.Size[Slot] := Size[Barcode]
this.SizeType[Slot] := SizeType[Barcode]
return
}
}
}
}
Now obviously the part that doesn't work is the Product[] property, because I really have no idea what I am doing there. xD The
idea is that you could do something like
myObject := Items.Product[1] to create an object that holds all of the information for product #1, and also do
Items.Product[1] := myObject to take an object and store the appropriate product information in the class.
Buuut... I can't syntax, and I don't even really know if a get/set block is actually what I want there, or if you can even pass parameters to a get/set block like that...
Also among things I don't know: Does __New need to return? What about TestSet?
Thank you so much for your patience with me, I know I'm not the fastest learner ever. ^^;