Announcement

Collapse
No announcement yet.

Did we loose Pointer?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts


  • Did we loose Pointer?

    Hello,
    Trying to set a table to store parts count every hour in an increment series of memory locations without needing to write a new line for each hour of the day, I believe in DirectSoft you could do this with a pointer using INCB instruction ( I never set up But played around with it and got working) But I am at a loss with DoMore Any suggestions?


  • #2
    No, we improved on it.

    All memory blocks are indirectly addressable via array indexing...Block[Index], where Index is the address of Block. If V13 were equal to 100, D[V13] would return the value of D100. Incrementing V13 (to 101) would then return D101.

    This works for all blocks, even structures, like T[V5].Acc.

    In normal ladder code, only V can be an array index. Within MATH boxes, array indices can be full expressions like C[D5 + sqrt(N2/PI())]. In the MATH box the output value can also be a full array expression. Very handy for doing multi-dimensional arrays, D[XIdx + YIdx*RowSize] = Expression.

    Comment



    • #3
      Originally posted by BobO View Post
      No, we improved on it.

      All memory blocks are indirectly addressable via array indexing...Block[Index], where Index is the address of Block. If V13 were equal to 100, D[V13] would return the value of D100. Incrementing V13 (to 101) would then return D101.

      This works for all blocks, even structures, like T[V5].Acc.

      In normal ladder code, only V can be an array index. Within MATH boxes, array indices can be full expressions like C[D5 + sqrt(N2/PI())]. In the MATH box the output value can also be a full array expression. Very handy for doing multi-dimensional arrays, D[XIdx + YIdx*RowSize] = Expression.
      Yes, this is waaaaay better than the DL pointer.

      Comment



      • #4
        I guess I need to play with this one to figure it out, thank you !

        Comment



        • #5
          Originally posted by BobO View Post
          Very handy for doing multi-dimensional arrays, D[XIdx + YIdx*RowSize] = Expression.
          Could you elaborate?

          Comment



          • #6
            Originally posted by pbw View Post
            Could you elaborate?
            Sure.

            Let's take a 2 dimension array. Let's say each row consists of 10 columns, and there are 10 rows. Allocate a single block of 100 items and call it ARRAY.

            In languages that support multiple dimensions, you would access row 3/column 5 like this: ARRAY[3][5], but all you are really doing is accessing linear memory with some simple math...ARRAY[Row*RowSize + Col]...or ARRAY[3*10 + 5].

            Since Do-more allows complex expressions for both the right and left side of a MATH box, it is easy to build and access n dimension arrays. I'm showing 2 dimensions, but this can easily be extended to 3 or more dimensions.

            So let's say you wanted to fill our example ARRAY with values:

            FOR Row = 0 to 9
            FOR Col = 0 to 9
            MATH ARRAY[Row*10+Col] = My source data
            NEXT
            NEXT

            Here it is in code. I created Symbolic Constants for the dimension values so the code is more readable. It also makes it easy to change the size later. Row and Col are just D locations.


            Click image for larger version

Name:	Array_2D.jpg
Views:	23
Size:	47.0 KB
ID:	116764

            Comment



            • #7
              Good stuff Bob!!
              Thanks.

              Comment



              • #8
                I was able to get all figured out, much simpler than I was making it! able to log hourly number into a new location every hour then on request (Will change to specified time) store to CSVfile and at the end of the day go back to the original location

                Click image for larger version

Name:	image_3396.jpg
Views:	17
Size:	139.7 KB
ID:	116813
                Last edited by Lucas.Allen; 08-01-2018, 10:58 AM.

                Comment

                Working...
                X