I have defined a custom type 'menuitem' and dimed a global as this type
The app lists menu items (as in food) and the user can select one and add it to their order. When an item is selected I load its values into gItem and then add it to the order which is a list (orderlist) of menuitems
I believe this only adds a pointer to gItem into the list so that if I subsequently change one of the values of gItem (without adding any further items to the list) the item in the list will change. Since I process gItem within various subs I need it as a global so how can I add it to the list and not have the problem when it is subsequently changed.
I don't know if I have explained the issue well enough but I imagine that it is common enough and there must be some way of overcoming it.
B4X:
Type menuItem (ID As Int, category As String, item As String, description As String, price As String, qty as Int, options As String, optionCode As String)
dim gItem as menuitem
The app lists menu items (as in food) and the user can select one and add it to their order. When an item is selected I load its values into gItem and then add it to the order which is a list (orderlist) of menuitems
B4X:
orderlist.add(gItem)
I believe this only adds a pointer to gItem into the list so that if I subsequently change one of the values of gItem (without adding any further items to the list) the item in the list will change. Since I process gItem within various subs I need it as a global so how can I add it to the list and not have the problem when it is subsequently changed.
I don't know if I have explained the issue well enough but I imagine that it is common enough and there must be some way of overcoming it.