web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)
Answered

Ascii Value of a string

(0) ShareShare
ReportReport
Posted on by 3,099

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

I have the same question (0)
  • Suggested answer
    Divesh Profile Picture
    327 on at

    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

  • jsshivalik Profile Picture
    3,099 on at

    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

  • Verified answer
    Divesh Profile Picture
    327 on at

    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
    3,099 on at

    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

  • Divesh Profile Picture
    327 on at

    So where you want to use the ascii value ?

  • jsshivalik Profile Picture
    3,099 on at

    Hi

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

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans