AnsweredAssumed Answered

Dismembering_Arrays

Question asked by VRFuser on Jul 31, 1996
from: Greg Goebel / HP-MXD
      gvg@lvld.hp.com / 970-679-3030 / FAX 970-679-5971
to:   VRF
date: Thursday, 01 August 1996 1109 MDT

Hi All:

I wasn't sure that the message I got yesterday about reading traces really
concerned breaking up a linear array into pieces, but I got curious about
the subject just on principle and wrote this up last night ... it'll go
out in Exchange presently:


[VEE] DISMEMBERING AN ARRAY UNDER VEE

* A customer sent in a request to our email forum that involved displaying
the elements of a 2048-element array as 16 sets of 128 elements each.  While
the question focused on the display of the data, rather than its generation,
I got to thinking about the task of breaking up the array. 

It was really quite simple; the following program shows how it's done:

           +-------+
           | Start |                                
           +---+---+
               |
   +-----------+----------+
   | ramp( 2048, 0, 2047) +--+   +----------------------------+
   +-----------+----------+  |   |           Formula          |
               |             |   +---+------------------------+
      +--------+-------+     +-->| A | A[B*128:(128*(B+1)-1)] +-->
      | For Count: 16  +-------->| B |                        |
      +----------------+         +---+------------------------+

The "ramp()" function simply generates a 2048-element array with values from
0 to 2047 for test purposes.  The For Count object ticks off each of the
16 individual arrays to be generated, while the Formula box selects the
appropriate sub-array using indexes generated from the count:

    A[0:127], A[128:255], A[256:384], ... , A[1920:2047]

Of course this assumes a fixed array size, number of subarrays, and size of
subarrays ... get any of them wrong and you get an error box.  The routine
could be made much smarter to accept as many subarrays as desired of any
size wanted from any input data (truncating the output in number of arrays
or array size as necessary to come out even), but that would be a cluttered
exercise, and in the absence of a visible need, one that I am not interested
in pursuing for the moment.

I suppose just for saying, that I'll get back a similar example program from
sombody with a formula box about as long as my arm.

[<>]

----------------------------- cut here ------------------------------------
#! e:vee/vee -r
(saveFormat "1.2")
(date "Wed 31/Jul/1996")
(SaveCF "no")
(filterNAN 0)
(component 0 "ROOTCONTEXT"
(name "Untitled")
(interface
)
(implementation
  (locked no)
  (trigMode deg)
  (nextID 8)
  (component 0 "FORMULA"
   (name "ramp(numElem,from,thru)")
   (subType "ramp")
   (interface
    (sequence in)
    (sequence out)
    (output 1
     (name "Result")
     (lock name constraints)
    )
   )
   (implementation
    (component expr 1 "ramp(2048, 0, 2047)")
   )
   (views
    (icon
    )
    (detail
     (origin 62 170)
     (extent 156 41)
    )
    (terminals on)
    (active detail)
   )
  )
  (component 1 "START25"
   (interface
    (sequence out)
   )
   (implementation
   )
   (views
    (icon
    )
    (detail
     (origin 127 99)
     (extent 47 22)
    )
    (title off)
    (active detail)
   )
  )
  (component 2 "FORCOUNT"
   (interface
    (sequence in)
    (sequence out)
    (output 1
     (name "Count")
     (lock name constraints)
    )
   )
   (implementation
    (component count 16)
   )
   (views
    (icon
     (iconImage "loop.icn")
    )
    (detail
     (origin 97 274)
     (extent 106 32)
    )
    (active detail)
   )
  )
  (component 3 "FORMULA"
   (interface
    (sequence in)
    (sequence out)
    (input 1
     (name "A")
     (optional yes)
    )
    (input 2
     (name "B")
     (optional yes)
    )
    (output 1
     (name "Result")
     (lock name constraints)
    )
   )
   (implementation
    (component expr 1 "A[B*128:(128*(B+1)-1)]")
   )
   (views
    (icon
    )
    (detail
     (origin 338 259)
     (extent 185 42)
    )
    (terminals on)
    (active detail)
   )
  )
  (component 4 "TEXTDISPLAY"
   (interface
    (sequence in)
    (sequence out)
    (input 1
     (name "Data")
    )
   )
   (implementation
    (component clearAtPrerun 1)
    (component clearAtActivate 1)
   )
   (views
    (icon
    )
    (detail
     (origin 639 65)
     (extent 143 430)
    )
    (active detail)
   )
  )
  (component 5 "DELAY"
   (interface
    (sequence in)
    (sequence out)
    (output 1
     (name "Done")
     (tag "Done")
     (lock constraints)
    )
   )
   (implementation
    (component delay 1)
   )
   (views
    (icon
     (origin 580 332)
     (extent 40 16)
    )
    (detail
     (origin 652 534)
     (extent 76 32)
    )
    (active icon)
   )
  )
  (component 6 "LABEL"
   (name "Dismembering An Array")
   (interface
    (sequence in)
    (sequence out)
   )
   (implementation
    (component labelValue "Dismembering An Array")
   )
   (views
    (icon
     (extent 163 0)
    )
    (detail
     (origin 234 59)
     (extent 312 42)
     (just c)
    )
    (title off)
    (active detail)
    (font "Arial" 26 bold)
   )
  )
  (component 7 "NOTE"
   (interface
   )
   (implementation
    (component text 11 5
    
     Dismembering An Array / v1.0 / 31 jul 96 / gvg
    
     * A customer wanted to take a 2048-element array and break it up
     into 16 separate 128-byte arrays ... not hard to do.  In this
     example, the "ramp()" function generates the test data, while
     the For Count object drives a Formula box -- that uses the
     array index to step through the appropriate indexes for the
     subarrays.
    
     [<>]
    )
   )
   (views
    (icon
     (origin 256 364)
     (extent 68 52)
     (iconImage "notepad.icn")
    )
    (detail
     (origin 81 351)
     (extent 559 178)
     (editing enabled)
    )
    (active icon)
   )
  )
  (configuration
   (connect D1:0 D0:0)
   (connect D0:0 D2:0)
   (connect D0:1 D3:1)
   (connect D2:1 D3:2)
   (connect D3:1 D4:1)
   (connect D3:1 D5:0)
  )
)
(views
  (detail
   (origin 0 24)
   (extent 800 538)
   (configuration
    (connect D1:0 D0:0
     (Point 150 123)
     (Point 150 149)
    )
    (connect D0:0 D2:0
     (Point 150 213)
     (Point 150 253)
    )
    (connect D0:1 D3:1
     (Point 270 190)
     (Point 290 190)
     (Point 290 270)
     (Point 305 270)
    )
    (connect D2:1 D3:2
     (Point 205 290)
     (Point 305 290)
    )
    (connect D3:1 D4:1
     (Point 575 280)
     (Point 636 280)
    )
    (connect D3:1 D5:0
     (Point 575 280)
     (Point 600 280)
     (Point 600 329)
    )
   )
   (stackingOrder 0 1 3 2 4 5 6 7)
  )
  (active detail)
  (numberFormats
   (realFormat standard)
   (realSigDigits 4)
   (realRadixSpec 4)
   (integerBase decimal)
  )
)
)
----------------------------- cut here ------------------------------------

Outcomes