home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1996 / ARCHIVE_96.iso / discs / gerald / 7_12 / ReadMe < prev   
Text File  |  1993-12-27  |  15KB  |  288 lines

  1. %OP%VS4.13 (28-Apr-92), Gerald L Fitton, R4000 5966 9904 9938 
  2. %OP%DP0
  3. %OP%IRY
  4. %OP%PL0
  5. %OP%HM0
  6. %OP%FM0
  7. %OP%BM0
  8. %OP%LM4
  9. %OP%PT1
  10. %OP%PDPipeLine
  11. %OP%WC1026,2262,188,1748,0,0,0,0
  12. %CO:A,72,72%
  13. %C%Chained Dependent Documents
  14. %C%by Gerald L Fitton
  15. Keywords:
  16. accounts set_value chain dependent Names Fitton
  17.  
  18. Introduction
  19.  
  20. In some applications you can generate what I am going to refer to as "a 
  21. long chain of unwanted dependent documents".  As the application grows 
  22. the chain grows unwieldy because all the files in the chain are loaded 
  23. one after the other when, perhaps, you want to work on only the most 
  24. recent document.
  25.  
  26. The set_value(,) function can be used to 'unlink' the chain without 
  27. destroying the (occasionally wanted) dependency.  Using Named variables 
  28. further simplifies many applications which use dependent documents.
  29.  
  30. For my example I've chosen a simple accounts application where each 
  31. month's transactions are kept in a separate document.  First I'll 
  32. explain how the basic application works, then I'll go on to to 
  33. demonstrate how the chain of dependent documents becomes unwieldy and, 
  34. then we'll see how set_value(,) can help by 'unlinking' the chain.  
  35. Finally we shall see how the use of Names for variables further 
  36. simplifies the creation of new documents which have to be added to the 
  37. 'unlinked' chain.
  38.  
  39. Monthly transactions
  40.  
  41. Double click on the file [Acc_9301] to load it.  You will see that it 
  42. represents a set of transactions for January 1993.  Position the cursor 
  43. in slot [Acc_9301]D5 and you will find the formula D4+B5-C5.  The value 
  44. brought forward from the previous month is held in slot [Acc_9301]D4,  
  45. credits are added to that amount and debits are subtracted from it 
  46. (line by line) to find the current balance and, finally, the amount to 
  47. be carried forward to next month's accounts.
  48.  
  49. This formula has been replicated down the column from D5 to D8 by 
  50. marking D5D8 and using the command <CtrláBRD> (Block Replicate Down) so 
  51. that, for example, the formula in [Acc_9301]D7 is D6+B7-C7.
  52.  
  53. In the form in which I've included it on this disc, the file [Acc_9301] 
  54. contains only three transactions, two credits and one debit but you can 
  55. extend it quite simply.  Place the caret anywhere in the last row and 
  56. tap <F7> to insert a new row, make your credit or debit entry and, 
  57. finally, replicate the formula in the "Balance" column through to the 
  58. line marked "Carried Forward".
  59.  
  60. Usually you would Save the file at this point but, in this case, don't 
  61. do that or my next exercise won't work properly!
  62.  
  63. Brought Forward
  64.  
  65. Delete the modified file [Acc_9301] from your screen (decline to Save 
  66. it by clicking on the 'No' box) and then double click on the file 
  67. [Acc_9302] (the transactions for Februaryá1992).  You will find that 
  68. [Acc_9302] and [Acc_9301] are both loaded.  The reason why [Acc_9301] 
  69. is loaded is because slot [Acc_9302]D4 contains the formula 
  70. [Acc_9301]D8.  Provided that you have not modified my version of 
  71. [Acc_9301] then this formula will bring forward the balance from 
  72. Januaryá1993 into the Februaryá1993 document.
  73.  
  74. There are at least two difficulties which arise when you use this 
  75. strategy of entering the slot reference of the previous "Carried 
  76. Forward" file, [Acc_9301]D8, into the "Brought Forward" slot, 
  77. [Acc_9302]D4, of the current month's document.
  78.  
  79. The first difficulty arises if you don't have both [Acc_9301] and 
  80. [Acc_9302] loaded and you want to add to or delete rows from the 
  81. earlier document.  If you have [Acc_9302] loaded and add a row to 
  82. [Acc_9301] then you will find that the slot reference in [Acc_9302]D4 
  83. will change to match the extended [Acc_9301].  However, it is all too 
  84. easy to forget that you need both files loaded.  If you don't have them 
  85. both loaded when you add a row to the earlier document then, when you 
  86. do load the later document, it will look for the amount to bring 
  87. forward in the slot where it used to be instead of where it now is.  
  88.  
  89. Yes!  Before you start writing to me, I do know that a method of 
  90. avoiding the 'loss' (some would say 'corruption') of slot references in 
  91. this fashion is to use Names in the earlier document for the slots used 
  92. by the later document.  Some of the examples I have received from you 
  93. use this method of 'non-local' Names - I don't recommend it.  I shall 
  94. explain how I use Names (and give my explanation of why 'non-local' 
  95. Names are not a good idea) later in this tutorial!
  96.  
  97. The second difficulty is one about which I get much correspondence.  To 
  98. understand why I get so many letters on this topic I'd like you to 
  99. imagine the situation in Decemberá1993.  When you load [Acc_9312] then 
  100. it will call up [Acc_9311], which in turn will call up [Acc_9310], and 
  101. so on until either all the monthly sheets have been loaded into memory 
  102. or (as has happened to some of my correspondents) you don't have any 
  103. memory left to use!
  104.  
  105. Loading all these earlier files is what I mean when I refer to a "chain 
  106. of unwanted dependent documents".  As a document become older the 
  107. likelihood of you wanting to change it is reduced so one way of 
  108. 'breaking the chain' is to 'snapshot' a "Brought Forward" value with 
  109. <CtrláBSS> (Block SnapShot).  This method of 'unlinking' the earlier 
  110. dependent documents from later ones seems to be the favourite solution 
  111. adopted by the majority of my correspondents.  Of course, it requires a 
  112. personal judgement about the likelihood of wanting to change an earlier 
  113. 'unlinked' document against the desirability of keeping it (and all 
  114. earlier ones in the chain) 'alive'.  I'd like to suggest to you what I 
  115. believe to be a much better alternative.
  116.  
  117. Carried Forward
  118.  
  119. You might regard the use of the formula [Acc_9301]D8 in slot 
  120. [Acc_9302]D4 as a function which creates a 'backwards chain' of 
  121. dependency.
  122.  
  123. Let me try to convince you that chaining backwards is not consistent 
  124. with the nature of the application we're considering.  The application 
  125. is one in which amendments to an earlier document need to be 'chained' 
  126. in the forward direction whereas additions to the most recent document 
  127. have no effect on earlier documents.  Chaining backwards, loading 
  128. earlier documents into memory, is a waste of time and effort!  What we 
  129. need is a set of documents which 'chain forwards'.  To put it another 
  130. way, we want to 'push' the "Carry Forward" balance from the earlier 
  131. document into the "Brought Forward" slot of the later document rather 
  132. than drag the value from the earlier document into the "Brought 
  133. Forward" slot of the later document.  If we can find a way of doing 
  134. this then we don't need to have the earlier documents in memory (unless 
  135. they need amendment - in which case we want any amendment to 'ripple 
  136. forwards' through the 'chain').
  137.  
  138. This is where the function set_value(,) comes in useful.  It can be 
  139. used to 'push' the "Carried Forward" balance into the "Brought Forward" 
  140. slot of the next document in exactly the way we want.  This is the 
  141. strategy I have adopted in dealing with the [Acc_94##] series.
  142.  
  143. Load the file [Acc_9403] and look at the "Brought Forward" balance in 
  144. slot [Acc_9403]D4.  You will find that it does not contain a formula 
  145. but a value.  The document [Acc_9403] contains no reference to earlier 
  146. documents so it does not 'pull' on the next link in the "chain of 
  147. unwanted dependent documents" uselessly dragging them into memory in 
  148. the way I've described in the previous section.
  149.  
  150. So how do we know that the "Brought Forward" balance is correct?  How 
  151. did it get there?  One way would be to use <CtrláBSS> (Block SnapShot) 
  152. and another would be to copy the "Carry Forward" manually into the 
  153. "Brought Forward" slot.  Either of these methods are unsatisfactory if 
  154. there is a chance that you might want to make an amendment to an 
  155. earlier document.  Amendments to earlier documents won't ripple through 
  156. a 'snapshot' and it's too easy to make a mistake!
  157.  
  158. Load [Acc_9402] and look at slot [Acc_9402]D12.  You will find the 
  159. formula set_value([Acc_9403]D4,D8).  It is this set_value(,) function 
  160. which 'pushes' the "Carried Forward" value from [Acc_9302]D8 into the 
  161. "Brought Forward" slot of the Marchá1994 document.  Make an amendment 
  162. to the earlier document and you will find the the amendment is 
  163. 'chained' through to the later document.  Try adding rows to the 
  164. Februaryá1994 document and you will see that the set_value(,) formula 
  165. in what was [Acc_9402]D12 adjusts to the enlarged sheet.
  166.  
  167. Now delete the earlier [Acc_9402] document from the screen.  You can 
  168. continue to work on the Marchá1994 document and ultimately Save it with 
  169. all the additions you have just made.
  170.  
  171. To see how the 'chain' works delete both the Februaryá1994 and 
  172. Marchá1994 documents from the screen and then double click on 
  173. [Acc_9401] (the Januaryá1994 file).  That file and all subsequent files 
  174. (February and Marchá1994) will be loaded.  Make an amendment to the 
  175. Januaryá1994 file, Save it (not on the master disc) and then delete it 
  176. from the screen.
  177.  
  178. Using the 1994 Chain of Documents
  179.  
  180. For most of your work you will not need the earlier documents loaded; 
  181. probably you will need only the most recent document.  Make your 
  182. changes to it and then Save it.
  183.  
  184. Now and again you will need to change an earlier document either to 
  185. amend a value which has been entered incorrectly or to add an item 
  186. which has been forgotten.  If you load that earlier document then all 
  187. subsequent documents in the chain will be loaded because the 
  188. set_value(,) function will drive the "Carried Forward" value into the 
  189. next sheet.  When you make your amendments to an early document the 
  190. consequences of those changes will 'ripple through' all later 
  191. documents.
  192.  
  193. When you have finished with the early document you can Save it and then 
  194. delete it from the screen; in fact you can work through all the chained 
  195. documents in chronological order Saving the new versions and then 
  196. deleting them from the screen.
  197.  
  198. If you run out of memory you can 'unlink' the chain by tricking the 
  199. package into believing that a particular file can't be found.  For 
  200. example, if you change the name of the file [Acc_9404] to, say, 
  201. [Acc_9404a] (use the RISCáOS feature Rename) and then double click on 
  202. [Acc_9401] you will find that the chain is broken when [Acc_9404] can't 
  203. be found.  You can make your amendments to the earliest file and then 
  204. go through the process of Saving the chain of files and deleting them 
  205. from the screen.
  206.  
  207. Restore the renamed file to its original name and then load the file 
  208. whose position in the chain is just prior to that one.  The new values 
  209. will ripple through the rest of the files in the chain.
  210.  
  211. Using Names
  212.  
  213. The process of creating a new document is made easier if you use Names.
  214.  
  215. I have used Names in the [Acc_95##] series.  Before we have a look at 
  216. the detail, double click on [Acc_9501] and you will find that the 1995 
  217. series will load and can be used in exactly the same way as you have 
  218. seen when you used the [Acc_94##] series.
  219.  
  220. Load all three files by clicking on [Acc_9501] and then have a look at 
  221. the contents of slot [Acc_9502]D12.  You will see that the formula, 
  222. instead of set_value([Acc_9503]D4,D8) has been replaced by 
  223. set_value([Acc_9503]bf,cf).  Two names, bf and cf (Brought Forward & 
  224. Carried Forward) are used in the formula instead.  The Name cf is 
  225. 'local' to the [Acc_9502] sheet whereas the Name [Acc_9503]bf is what I 
  226. am calling 'non-local'.
  227.  
  228. Now let's have a look at the Names which have been defined in 
  229. [Acc_9502], what I am calling 'local' Names.  Place the pointer on the 
  230. italic f which is just to the left of the cross and tick boxes (in the 
  231. same line as the formula line) and click once.  At the bottom of the 
  232. pop-up menu you will find the option Edit name.  Run the pointer 
  233. through Edit name and you will see that within [Acc_9502] only two 
  234. names have been defined, bf and cf which are both 'local'.  By looking 
  235. at the definitions (as if you were going to edit them) you will see 
  236. that the name bf refers to D4 and the name cf refers to D8 both slots 
  237. within the current sheet.  There are no definitions which refer to 
  238. slots in other sheets.
  239.  
  240. Now let's see how many names we have in the whole chain of three 
  241. documents.  Once again click on the italic f but this time run the 
  242. pointer through Names.  You will find that six names have been defined, 
  243. two we know about (bf and cf) but the other four are names which have 
  244. been defined (locally) in the other two documents.
  245.  
  246. Defining the two names bf and cf in all documents makes it easier to 
  247. create the next document.  Let's create [Acc_9504] using the blank file 
  248. [Acc_95xx] as the template.  Double click on the file [Acc_95xx] to 
  249. load it, change the formula in the slot [Acc_95xx]D12 from its present 
  250. value to set_value([Acc_9505]bf,cf) and then Save the file as 
  251. [Acc_9504].
  252.  
  253. Next you will need to 'push' the "Carried Forward" value from the 
  254. previous document, [Acc_9503] into your new [Acc_9504] file.  To do 
  255. this you double click on [Acc_9503] to load it - then delete it from 
  256. the screen!  You will find that the "Brought Forward" value in 
  257. [Acc_9504] has taken the correct value 'pushed' into it from the 
  258. [Acc_9503] file you loaded and then removed from the screen and memory.
  259.  
  260. To summarise
  261.  
  262. When you have a long 'chain' of dependent documents then you should 
  263. consider whether you want to 'drag' or 'push' values from one member of 
  264. the 'chain' to another.  I suggest that for an application such as that 
  265. of this tutorial you need to 'push' rather than 'drag' slot values from 
  266. one sheet to the next in the 'chain'.  When you have decided that the 
  267. correct strategy is to 'push' you need to use the set_value(,) function 
  268. in the (often unwanted) 'dependent' document to 'push' the value (or 
  269. values) you want to carry forward to the next document.
  270.  
  271. Names can be used for single slots or for ranges of slots.  Generally 
  272. it is better to define names in such a way that the definition is 
  273. 'local'.  That is to say the definition does not refer to (and thus 
  274. call into memory) another document.  If you define a Name in one 
  275. document you can always use it in another document - we have done this 
  276. in the 1995 'chain' of documents - but if you define a name in one 
  277. document which refers to a slot in a different document (what I call a 
  278. 'non-local' definition) then you have a 'link' that you may not want.
  279.  
  280. Finally
  281.  
  282. If you have an application which you think may be simplified by the use 
  283. of set_value(,) or Names but can't quite work out how to do it, then 
  284. please ask me.  I will be able to work on your problem and send you the 
  285. solution much more easily if you provide a disc based example of what 
  286. you are doing together with some note (in a [ReadMe] file) indicating 
  287. exactly what you are trying to achieve.
  288.