increment alpha variable?

zfmejennyzfmejenny Member Posts: 5
edited 2010-08-10 in NAV Tips & Tricks
I have a code variable that might be A or B or 1 or 2, etc.

I have a report that is using INCSTR(variable), but this is unable to increment the alpha variables.

Is it possible to increment to the next alpha?

Thanks!

Comments

  • ara3nara3n Member Posts: 9,256
    Here is an example on how to increment text. It will increment all the way to z.
    t := 'tada';
    if INCSTR(t) = '' then begin
      t[strlen(t)] := t[strlen(t)] + 1;
    end else
      t := INCSTR(t);
    message(t);
    


    You can use it to do more complex code. Such as increment past z.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • zfmejennyzfmejenny Member Posts: 5
    Thanks Rashed! That worked great.
  • ara3nara3n Member Posts: 9,256
    you are welcome.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DenSterDenSter Member Posts: 8,307
    That is a cool trick =D> it even goes beyond z
  • ara3nara3n Member Posts: 9,256
    edited 2006-10-18
    It does go beyond z but I don't think having } as an increment makes sense.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DenSterDenSter Member Posts: 8,307
    No that doesn't make sense indeed, but it is still a cool trick :mrgreen:
  • ara3nara3n Member Posts: 9,256
    I usually use this trick to see if last character is a '\' when a directory is specified for files.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    How wonderfull that I can sometimes move something TO the Tips & Tricks forum! :D
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ara3nara3n Member Posts: 9,256
    It's sad that I have to look for my own tips and trick?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DenSterDenSter Member Posts: 8,307
  • JesseJesse Member Posts: 1
    tyvm for the sample and the tip! :D
  • ara3nara3n Member Posts: 9,256
    you are welcome.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • kinekine Member Posts: 12,562
    I am using this code to do the same, but with possibility to define the string of "numbers"...
    IncStrAlpha(Code : Code[20]) : Code[20]
    //Increment Alpha Strig
    SeqText := '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; //sequence of "numbers"
    i := STRLEN(Code);
    REPEAT
      Pos := STRPOS(SeqText,FORMAT(Code[i]));
      IF Pos = STRLEN(SeqText) THEN BEGIN //Is last number in row
        Code[i] := SeqText[1];      //take first number
        i := i-1;              //change number on higher position
      END ELSE BEGIN
        Code[i] := SeqText[Pos+1];
        Switched := TRUE;
      END;
    UNTIL Switched or (i = 0);
    EXIT(Code);
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • AndwianAndwian Member Posts: 627
    =D> :thumbsup:
    Regards,
    Andwian
Sign In or Register to comment.