Skip to Content
author's profile photo Former Member
Former Member

help

Hi,

How to get the last character of character value? for example: '1226262M', I wanna get the suffix 'M'. Length of the character can be varying.

Many thanks.

Alia

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    Posted on Sep 27, 2005 at 09:05 AM

    Hi,

    try that:

    data: len type i,

    result(1).

    parameters word(20).

    len = strlen( word ) - 1.

    result = word+len(1).

    write result.

    best regards

    Vladimir

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 09:03 AM

    Hi,

    Alia can you be much clear plzzzz.

    Why means Length of the character or charecter no is varying?

    Thanks.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 09:06 AM

    use fm STRING_REVERSE and take 1st character from result.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 09:06 AM

    hi,

    data i type i,

    data x(15) type c,

    y type c,

    x = '1226262M'

    i = strlen( x )

    i = i - 2.

    y = x+i(1).

    cheers,

    sasi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 09:14 AM

    Hy Alia

    you can use the command strlen to get the length of the string.

    len = strlen(your_string).

    and then use SHIFT.

    I put some example code.

    data len type i.

    data my_string type string value '1226262M'.

    len = strlen( my_string ).

    len = len - 1.

    shift my_string by len.

    that's all. In my_string variable you'll have 'M'.

    By enzo

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2005 at 09:42 AM

    Hi,

    there are many string manipulation functions so take a look of them first, u will get many ways to do this.

    You can measure the length of the string through strlen() function and then shift your string length - 1 place and you will get the desired value.

    you can use this:

    data: a type string value '1226262M'.

    data: b type i.

    b = strlen( a ) - 1.

    shift a by b places.

    write /: a.

    Regards,

    Animesh

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.