AnsweredAssumed Answered

VRfQuestion about records and datasets

Question asked by VRFuser on Sep 8, 1997
One way to do this is to pull in all of the records in the dataset into an
     array.  Then run the array into a formula box with :
          where ARY is your array of records
     This will give you the last 50 elements of the array.  You could then
     calculate the average with:
         where ARY is the array of records
               FIELD is the name of the field of interest
     These two formulas could even be combined into one box if desired.  The
     only problem with this method is that it takes in all of the data records
     and the array could become too large for VEE to handle if the dataset is
     very large.  You could cut that down if you had some idea of the number of
     samples you might get in a day and then set your read dataset object to
     read the records after a particular date, and then just take the last 50 as
     in the line above.
        The only other thing I could think of would be to read them in one at a
     time in a loop and build an array of the appropriate size with a formula:
         where PREV_ARRAY is the array of records you are building
               NEW_RECORD is the latest record to add
     In this case, the new element is added as the first element is dropped -
     forming a QUEUE structure.  The loop is an UNTIL BREAK with a BREAK on EOF.
      This assumes that PREV_ARRAY is already an array of the desired size
     (initialize the loop with an array of null records).  Then run a loop the
     build up the array and you want and send it through the calculation above. 
     The disadvantage to this method is that looping tends to be rather slow in
     VEE, so it will take some time to get through the dataset.  One way to
     increase the speed is to send the resulting array into a SAMPLE & HOLD
     object and XEQ the sample & hold from the sequence out pin of the UNTIL
     BREAK,  That way, any processing is held off until the desired set of data
     is collected. 
        Hope that helps.
     Tom Groleau
     HMSC, Tucson, Az

______________________________ Reply Separator _________________________________
Subject: Question about records and datasets
Author:  "Roger D. Martin" <> at CCGATE
Date:    9/8/97 10:55 AM

I'm new to HP VEE 4.0 so hopefully there is a simple solution to my

I want to search a dataset and "grab" the most recently added 50 records
within it.  Then I want to extract the values of ONE of the fields of
all 50 records and compute the average value.

I don't know what search specifier to use in the "From Data Set" box so
that I will always get the last 50 records.  (The total number of
records will continually increase.)  One of the fields will be a time
stamp; perhaps there is some way to "grab" the 50 records with the
"smallest" time stamp?

Thanks for any help

Roger Martin