## There is a basic error in the shop9.js-e construal ## The dependency that links the price tag associated with an item with its price is missing ## To confirm this omission, use a Dependency Map to search for a chain of dependencies from price1 to item1text ## The file of functions and definitions below records the basic updates needed to implement this dependency ## The Dependency Map view will show how the dependencies are reconfigured dynamically as the updates are made ## The function pricedisplay() is updated so that a change in the value of the observable 'items' affects item1text func pricedisplay { para ix,items; if (ix==1) return displaycurrency(items[1][2]); if (ix==2) return displaycurrency(items[2][2]); if (ix==3) return displaycurrency(items[3][2]); if (ix==4) return displaycurrency(items[4][2]); if (ix==5) return displaycurrency(items[5][2]); if (ix==6) return displaycurrency(items[6][2]); } ## this very clumsy function definition can be refined: func pricedisplay { para ix,items; return displaycurrency(items[ix][2]); } ## the addition of a second parameter to pricedisplay() has to be reflected in the associated definitions: item1text is Text(pricedisplay(1, items), 0.6*scaleWidth,5*scaleWidth); item2text is Text(pricedisplay(2, items), 1.9*scaleWidth,5*scaleWidth); item3text is Text(pricedisplay(3, items), 3.2*scaleWidth,5*scaleWidth); item4text is Text(pricedisplay(4, items), 4.5*scaleWidth,5*scaleWidth); item5text is Text(pricedisplay(5, items), 5.8*scaleWidth,5*scaleWidth); item6text is Text(pricedisplay(6, items), 7.1*scaleWidth,5*scaleWidth); ## you can test the update so far thus: price1 = 0.31; price2 = 1.64; price3 = 0.39; price4 = 2.0; price5 = 0.29; price6 = 0.42; ## problematic aspects of JavaScript floating point arithmetic lead to inappropriate displays of prices: ## to resolve these the function displaycurrency() has to be modified so that the round() function is introduced: func displaycurrency { para amount; auto pounds, pence; pence = 100*amount; pounds = int (pence / 100); pence = round(pence - pounds*100); return decodeHTML("£") // ((pounds>0) ? str(pounds) : "0") // ((pence>0) ? "-" // str(pence) // "p" : ""); } ## the update then works correctly: price1 = 0.31; price2 = 1.64; price3 = 0.39; price4 = 2.0; price5 = 0.29; price6 = 0.42;