home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1995 / ARCHIVE95.iso / discs / pipeline / abacus / p_line / Array1 / ReadMe < prev   
Text File  |  1991-12-15  |  7KB  |  136 lines

  1. %OP%VS4.11 (04-Dec-91), Gerald Lewis Fitton, R4000 5065 0380 9644 
  2. %OP%DP0
  3. %OP%IRY
  4. %OP%PL0
  5. %OP%HM0
  6. %OP%FM0
  7. %OP%BM0
  8. %OP%LM4
  9. %OP%FX
  10. %OP%FY
  11. %OP%FS
  12. %OP%PT1
  13. %OP%PDPipeLine
  14. %OP%WC810,2050,180,1620,0,0,0,0
  15. %CO:A,72,72%
  16. %C%Arrays - Part 1
  17. %C%by Gerald L Fitton
  18. Keywords:
  19. Array Matrix Fitton
  20.  
  21. The directory "Array01" is the first on this disc because the word 
  22. "Array" starts with "A", the first letter of the alphabet.  However, 
  23. the content of this directory might not be the best to study first.  I 
  24. suggest that the files in PipeDream4 and Documents should be read first 
  25. followed by those in the directory BusLetter.  If you are unfamiliar 
  26. with PipeDreamá3 spreadsheets then you may benefit from reading the 
  27. Sheets series before the Array series.
  28.  
  29. What is a PipeDreamá4 Array?
  30. Load the file [Array01] from this directory.  A "Range" is a range of 
  31. slots.  The range [Array01]B2C6 contains the ten numbers (1 to 10).  In 
  32. PipeDreamá3 you would have to address each of these slots individually 
  33. but in PipeDreamá4 we can treat the range as a single entity.  The 
  34. range can be given a variable name and the name operated on by an array 
  35. function.  Before we get into such complications let's see how I've 
  36. loaded the whole range into a single slot so that [Array01]B10 contains 
  37. a 5ábyá2 array of the numbers in the range B2C6.
  38.  
  39. Transferring Values from a Range to an Array
  40. There are three ways of transferring values from a range to an array.  
  41. The file [Array01] shows what I believe to be the easiest way.
  42.  
  43. If you click the mouse select (left) button in slot [Array01]B10 then 
  44. you will see the formula I have used to store the range in the array.
  45.  
  46. You can experiment yourself by loading [Array01z].  The caret is ready 
  47. positioned in slot [Array01z]B10.  If it isn't there (because I've made 
  48. a mistake when I saved the file) then place the caret in slot B10 using 
  49. the pointer and the mouse (position the pointer over slot B10 and click 
  50. the mouse select button).  Next, use the mouse to position the pointer 
  51. in the formula line, position the pointer in B2 and click select, 
  52. repeat this process in C6 to specify the range, finally, click on the 
  53. green tick to transfer the formula from the formula line to the slot.
  54.  
  55. Alternative methods
  56. The file [Array01b] shows a second method which uses the function 
  57. set_value(slot, range).  Again you can experiment with [Array01z].  
  58. This time, after clicking in the formula line click select over the 
  59. formula button (the italic f),  run the pointer through misc (for 
  60. miscellaneous functions) and click on set_value.  Click on B10, click 
  61. in the formula line just after the comma which separates the two 
  62. arguments, click on the two ends of the range, B2C6, and finally on the 
  63. green tick.  Easy, isn't it?
  64.  
  65. The third method is messy but it allows me to explain the Pipedreamá4 
  66. index function which is different from the PipeDreamá3 function of the 
  67. same name.  Load [Array01b] and look at the formula in B10.  In 
  68. PipeDreamá4 index has the syntax index(range,col,row,cols,rows) and it 
  69. can be used to transfer part (or, in this case, all) of a range into an 
  70. array.  In PipeDreamá3 the function index has only two arguments, a 
  71. column number and a row number (note that column Aá=á1, Bá=á2, Cá=á3, 
  72. etc).  In PipeDreamá4 the index function has three obligatory and two 
  73. optional arguments.  The first argument is a range or an array 
  74. (generally, in PipeDreamá4 arrays and ranges are interchangeable - 
  75. hence my surprise to find PipeDreamá4 crashed when I tried to enter a 
  76. range in an array slot).  I have entered B2C6 as the range to be 
  77. transferred to the array.  The second and third arguments of index 
  78. allow you to transfer only part of the range to the array; they are the 
  79. "coordinates" of the "first" element of the range which you want 
  80. transferred to the top left corner of the array.  I have used 
  81. index(range,1,1,cols,rows); ie I have made colá=á1 and rowá=á1 so that 
  82. the top left element of the range (slot B2) is the first element (top 
  83. left corner) of the array.  If I had used index(range,1,3,cols,rows) 
  84. then the first two rows of the range (which contain the numbers 1, 6, 2 
  85. and 7) would not be transferred to the array.  If you like to 
  86. experiment then try changing the index function to index(B2C6,1,3,1,3) 
  87. and see what happens.
  88.  
  89. The size of the range is 2 columns and 5 rows.  To transfer all the 
  90. range of 2 columns and 5 rows to the array in [Array01b]B10 I must use 
  91. 2 and 5 as the fourth and fifth arguments of the index function.  If 
  92. you use values for these arguments that are less than the number of 
  93. columns and rows in the range then you will transfer only part of the 
  94. range to the array.  For simplicity I could have written my index 
  95. function as index(range,1,1,2,5), (ie with colsá=á2 and with rowsá=á5) 
  96. and the range would be transferred into the array but then, if I 
  97. changed the size of the range from a 5ábyá2 matrix to say a 6ábyá2 (eg 
  98. by inserting an extra row with <F7>) then I would have had to change 
  99. the last argument of my index function from 5 to 6.  One maxim of good 
  100. spreadsheet (and programming) practice is "Never use a value when you 
  101. can use a variable".  Instead I have uses the functions cols and rows 
  102. to calculate the numbers of columns and rows of the range.
  103.  
  104. Taking a Snapshot of an Array
  105. I would have liked to snapshot slot [Array01]B10 and then deleted the 
  106. range [Array01]B2C6 but, when I tried this in version 4.11 I found that 
  107. the array in [Array01]B10 became a single value.  The rest of the array 
  108. disappeared!  The benefit I can see for such a sequence of operations 
  109. is that I could enter the data making up the range in a dependent 
  110. document, hide it in an array which is then snapshotted, etc.  Perhaps 
  111. in a later version of PipeDreamá4.
  112.  
  113. Transferring Values from an Array to a Range
  114. The function set_value is the easiest way I have found of transferring 
  115. the whole of an array to a range.  I have entered that function into 
  116. slot B12.  The syntax of set_value is set_value(to,from).  Generally 
  117. "to" and "from" are slot references but, if "to" is a range and "from" 
  118. is the slot containing an array then as much as possible of the array 
  119. as will fit the range is transferred to the range.
  120.  
  121. Recovering a Single Value from an Array
  122. Sometimes you may want to recover only one value from an array.  The 
  123. index function can be used to do this.  In slot [Array01]B20 I have 
  124. used the index function to recover the value from column 2, row 4 of 
  125. the array stored in slot [Array01]B10.
  126.  
  127. Over to You
  128. Experiment with this spreadsheet.  You can insert additional rows into 
  129. the range [Array01]B2C6 with <F7>.  However, if you do insert a row 
  130. then beware that I have not written the formula in slot [Array01]B12 
  131. (for recovering the array) in its most "general" form.  Because of this 
  132. you will have to alter the space allocated to the output range by 
  133. inserting a row somewhere between row 12 and row 16 with <F7> to match 
  134. the extra row you have inserted between rows 2 and 6.  You can insert a 
  135. column between B and C using <CtrláEIC> with impunity!
  136.