Re: Error reporting
- Posted by ChrisB (moderator) Jan 12, 2014
- 1736 views
Hi
To put this argument, and that line into context, here is the modified code, I found this quite readable, after 2 years of not looking at it, but had changed something in another part, which of course had its knock on effects. Despite not having looked at this part for 2 years took me 2 minutes to understand again.
------------------------------------------------------------------------------------ function price_increase() ------------------------------------------------------------------------------------ sequence cmd, data, category_list, result, prod_list, --the list of products to apply price rises too price_list, tmp, --contains prices only for listed products, [1] original [2] percentage inc [3] new price display_list atom percentage integer choice, current_choice --choose categories to apply price increases too category_list = call_func(rid_category_list, {}) --in reports.ex --check for un categorised products VOID = check_uncategorised() if length(category_list) = 0 then return 0 end if cmd = "SELECT * FROM Products WHERE type LIKE 'S%'" data = query_database("xprods.sql", cmd) if length(data) = 0 then return 0 end if prod_list = {} for i = 2 to length(data) do data[i] = data_validate_product(data[i]) if length(data[i][PROD_CATEGORY]) > 0 then for j = 1 to length(category_list) do if length(category_list[j]) > 0 then if category_list[j][1] = data[i][PROD_CATEGORY][1] then prod_list = append(prod_list, data[i]) end if end if end for end if end for
Thanks to Matt for enhancing the error reporting, which even if everyone writes code in plain English, will still catch those occasions where there might a touch of laziness and brevity in the case of the programmer.
Chris

