Announcement

Collapse
No announcement yet.

Did we loose Pointer?

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

  • Lucas.Allen
    started a topic Did we loose Pointer?

    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?

  • Lucas.Allen
    replied
    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:	9
Size:	139.7 KB
ID:	116813
    Last edited by Lucas.Allen; 08-01-2018, 10:58 AM.

    Leave a comment:


  • pbw
    replied
    Good stuff Bob!!
    Thanks.

    Leave a comment:


  • BobO
    replied
    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:	10
Size:	47.0 KB
ID:	116764

    Leave a comment:


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

    Leave a comment:


  • Lucas.Allen
    replied
    I guess I need to play with this one to figure it out, thank you !

    Leave a comment:


  • kewakl
    replied
    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.

    Leave a comment:


  • BobO
    replied
    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.

    Leave a comment:

Working...
X