Counter with specific number of digits

mravlincek
2017-06-13
2017-11-06
  • mravlincek

    mravlincek - 2017-06-13

    Hi all.

    So I am having this strange problem, where I need specific number of digits in my counter. I need the counter to be able to count up to 9999999, but the number of digits always has to be the same. This means, when the counter starts it should be 0000001, then later on it will be 0001021 and so on.

    I would prefer to convert the counter into string later on, so maybe there is a solution there? I am completely out of ideas on how to easily realize this.

    Please help

    Best regards,

     
  • Anonymous - 2017-06-16

    Originally created by: scott_cunningham

    First, make sure your counter supports the high number (you need a dword output). Then you Use DWORD_TO_STRING to get the number as a string. Also define a string '0000000'. Concat the two together and then your answer is MID(togetherstring, LEN(togetherstring)-7,7). Or about that

     
  • mravlincek

    mravlincek - 2017-06-26

    I actually made it happen like this, because I am not familiar with repeat of while funcitons as yet

    STRINGcounter:=DWORD_TO_STRING(DWORDcounter);
    IF LEN(STRINGcounter)=1 THEN
       TEMPcounter:=CONCAT('0', STRINGcounter);
       TEMPcounter:=CONCAT('0', TEMPcounter);
       TEMPcounter:=CONCAT('0', TEMPcounter);
       TEMPcounter:=CONCAT('0', TEMPcounter);
       TEMPcounter:=CONCAT('0', TEMPcounter);
       TEMPcounter:=CONCAT('0', TEMPcounter);
    ELSIF LEN(STRINGcounter)=2 THEN
       TEMPcounter:=CONCAT('0', STRINGcounter);
       TEMPcounter:=CONCAT('0', TEMPcounter);
       TEMPcounter:=CONCAT('0', TEMPcounter);
       TEMPcounter:=CONCAT('0', TEMPcounter);
       TEMPcounter:=CONCAT('0', TEMPcounter);
    .
    .
    .
    ELSIF LEN(STRINGcounter)=7 THEN
       TEMPcounter:=STRINGcounter;
    END_IF
    

    I am not proud of it but it works

     
  • shooter

    shooter - 2017-11-06

    have a look at w www.oscat.de w for a nice library containing all sorts of manipulation, and yes you may be proud of your solution.

     

Log in to post a comment.