Reverse a string

ChapChap Member Posts: 8
edited 2012-05-11 in Navision Attain
Hello,

is there any function to reverse a string

(like: String_1= "ABC", String_2="CBA") ?

In other programming languages there are special functions for that but I haven't figured out a function solving this problem in Nav.

Answers

  • Timo_LässerTimo_Lässer Member Posts: 481
    There is no predefined function for that, but you can write it yourself:
    J := 0;
    FOR I := STRLEN(YourText) DOWNTO 1 DO BEGIN
      J += 1;
      ReverseText[J] := YourText[I];
    END;
    
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • ChapChap Member Posts: 8
    Hello Timo,

    thanks a lot for your reply. :D
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Chap wrote:
    Hello,

    is there any function to reverse a string

    (like: String_1= "ABC", String_2="CBA") ?

    In other programming languages there are special functions for that but I haven't figured out a function solving this problem in Nav.

    Hi Chap.

    Navision is not a programming language, its and ERP product with an integrated development environment. Please don't go down the path of looking for C++ and Fortran and Prolog constructs or you will just end out banging your head against a wall.

    Work with NAV and you will grow to love it. :mrgreen:
    David Singleton
  • mb6606mb6606 Member Posts: 30
    This code works perfectly well
    [code][
    J := 0;
    FOR I := STRLEN(YourText) DOWNTO 1 DO BEGIN
    J += 1;
    ReverseText[J] := YourText;
    END;
    /code]

    Any I deas how to make it work with an array? YourText[k])
    FOR I := STRLEN(YourText[k]) DOWNTO 1 DO BEGIN
    J += 1;
    ReverseText[k][J] := YourText;
    END;
Sign In or Register to comment.