Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Ascii Value of a string

Posted on by 3,027

Hi

  I have a string like INV-1819-0001. I want to get Ascii value of each character of a string

Thanks

*This post is locked for comments

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Ascii Value of a string

    Hi

      I want to save the values in a string and then pass to parameter

    Thanks

  • Divesh Profile Picture
    Divesh 327 on at
    RE: Ascii Value of a string

    So where you want to use the ascii value ?

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Ascii Value of a string

    Hi Divesh

     i am able to get Ascii values . For eg i have text = INV . I have got values 73,78,86. Now i want to save these values in one string

    like 73&78&86&

    Thanks

  • Verified answer
    Divesh Profile Picture
    Divesh 327 on at
    RE: Ascii Value of a string

    Since you have not provided more details on your reply, I have assumed the Data Type of the Array1 is Integer, below is the code for updating the Ascii value to Array1.

    lText := "No.";
    FOR li := 1 TO STRLEN(lText) DO BEGIN
      Array1[li]  := lText[li];
    END;
  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Ascii Value of a string

    Hi

     I have below code and how i should convert sAscii to Ascii value.

    array1[1] := "No.";

    FOR i := 1 TO STRLEN(array1[1]) DO BEGIN
    sAscii := COPYSTR(array1[1], i,1);

    END;

    Thanks

  • Suggested answer
    Divesh Profile Picture
    Divesh 327 on at
    RE: Ascii Value of a string

    Hi

    You can use the below function to get the Ascii Value of each character from the string.

    LOCAL GetASCIIValue(pText : Text)
    //Variables
    //Name	  DataType
    //lAscii	Integer
    //li	    Integer
    
    FOR li := 1 TO STRLEN(pText) DO BEGIN
      lAscii := pText[li];
      MESSAGE('Character %1 Ascii Value %2',pText[li],lAscii);
    END;
    
    LOCAL GetASCIIValue2(pText : Text)
    //Variables
    //Name	  DataType
    //lChar	  Char
    //lAscii	Integer
    //li	    Integer
    
    FOR li := 1 TO STRLEN(pText) DO BEGIN
      lChar := pText[li];
      lAscii := lChar;
      MESSAGE('Character %1 Ascii Value %2',pText[li],lAscii);
    END;

    GetASCIIValue('INV-1819-0001');
    GetASCIIValue('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
    GetASCIIValue('0123456789');
    GetASCIIValue2('INV-1819-0001');
    GetASCIIValue2('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
    GetASCIIValue2('0123456789');

    Hope this helps. Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans