News:

  • September 24, 2026, 04:23:37 AM

Login with username, password and session length

Author Topic: SUMR on a UDT  (Read 6869 times)

Bolt

  • Hero Member
  • *****
  • Posts: 598
SUMR on a UDT
« on: December 20, 2021, 10:14:24 AM »
Is there a simple way to do SUMR on a group of values in a UDT?  If I have my memory lay out as V0=Value0, V1=Value1,... V9=Value9 it is easy, SUMR(V0,10).  Now if I do MemBlock0.Value, MemBlock1.Value,... MemBlock9.Value, it becomes trickier.  Do I need to do a FOR loop to create a SUM, or something else?

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 702
  • Hmmm...
    • Host Engineering, Inc.
Re: SUMR on a UDT
« Reply #1 on: January 18, 2022, 12:49:02 PM »
Sorry you never received a reply on this. You probably figured it out already, that the only way to do this is a FOR/NEXT loop with a MATH instruction that indexes using V0 for your MemBlock[V0].Value structure. If there's a better way, I'd like to see it too.
There are two types of people in the world; those that can extrapolate from incomplete data sets.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: SUMR on a UDT
« Reply #2 on: January 19, 2022, 05:35:44 PM »
It kind of relates to the need for a syntax for subsetting n-D arrays and slicing in arbitrary direction.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: SUMR on a UDT
« Reply #3 on: January 20, 2022, 03:07:26 PM »
Yes, I ended up doing a loop with some MATH instructions to summarize everything.  It works out alright, some values in the UDT needed to be minimum/maximum calculations, others sums or averages, so some extra syntax in a loop isn't the end of the world.  Keeps the brain sharpened.