question about "Collection example"

  • audi0615

    audi0615 - 2020-11-18


    With regard to "Collection example" in the store,
    I'd like to know why there are no collections for real type variable.(RealList, RealQueue, RealStack)
    if i want to add real type variables into a collection, do i have to convert them to int type variables??
    Another question is, what is a limitation of size of dynamic collection. no limit?

  • aliazzz

    aliazzz - 2020-11-18


    Since the Collection Elements are FB types you can program whatever you wish.
    So implementing a REAL or LREAL will not be an issue. Either you implement the Collection Interface or you extend collection FB type (read the extensive help on it). If you do this you can design your own Element FB types. This choice is up to you.

    On "dynamic" collections:
    In theory there is no limit to maximum size of the collection, but please read the following article very very carefully.;product=codesys;version=

  • audi0615

    audi0615 - 2020-11-18

    Thank you for your reply.
    but still i don't understand how to implement real type collection.
    the library provides bool,int, dint, udint, lint, string, wstring type collection. only real type is missing.

    • aliazzz

      aliazzz - 2020-11-19

      If you look at this part of the example, you can build it yourself.

  • audi0615

    audi0615 - 2020-11-21

    Thanks for your kind reply. I would try it.

  • audi0615

    audi0615 - 2020-11-21

    I was able to build a libary for Lreal type except "hashcode".

    According to comments in the element example, "hashcode" is used in a hash table. Is it correct to just use LrealValue as the hashcode?

    ElementHashCode := LREAL_TO_LINT(LrealValue);
  • aliazzz

    aliazzz - 2020-11-21

    It all depends whether you need a (unique) hash in your solution? If you don't need hash codes in your collection elements, my suggestion would be to remove it.

    PS instead of searching examples in the store, try searching your examples here. It is a new feature and more convenient IMHO:


    Last edit: aliazzz 2020-11-21
  • audi0615

    audi0615 - 2020-11-22

    Thank you so much for your reply.
    I need to use a hash table in my project, so i would make the hashcode unique.
    Thanks for the new example site, very convenient.


Log in to post a comment.