View previous topic :: View next topic
|
Author |
Message |
sunish
New User
Joined: 23 May 2005 Posts: 19
|
|
|
|
Hi
i want to calculate the length of a string.The varilable is declared
01 GR.
05 A PIC X(200).
05 B PIC S9(3) COMP.
now the varilable "A" contains "god is great ". the actual length of the srting is 12. Please tell me how to calculate the lenght.
thank you |
|
Back to top |
|
|
Aji
New User
Joined: 03 Feb 2006 Posts: 53 Location: Mumbai
|
|
|
|
Hi
Please try out the code below.
INSPECT FUNCTION REVERSE(TEXT1) TALLYING
L FOR LEADING SPACE
compute l = length of text1 - l
Regards
Aji Cherian |
|
Back to top |
|
|
gowtham_1982 Warnings : 1 Active User
Joined: 02 Dec 2005 Posts: 109
|
|
|
|
sunish wrote: |
Hi
i want to calculate the length of a string.The varilable is declared
01 GR.
05 A PIC X(200).
05 B PIC S9(3) COMP.
now the varilable "A" contains "god is great ". the actual length of the srting is 12. Please tell me how to calculate the lenght.
thank you |
Hi sunish,
please try this code...
compute b = function length of (a).
suggestions welcomed...
gowtham |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
hi gowtham_1982,
AJI is right.
You can't go for FUNCTION Lenght of (a) directly.
SInce the lenght includes the following spaces which is not the requirement.
~Vamsi |
|
Back to top |
|
|
sundaresanjs
New User
Joined: 29 May 2006 Posts: 18 Location: USA
|
|
|
|
sunish,
i have done a program regarding it, i think it may be helpful for u,
(using display(name(2:1)) which gives the value of the second position in name)
01 GR.
05 A PIC X(200).
05 B PIC S9(3) COMP
according to ur program a has value god is great,
MOVE 300 TO I.
PERFORM 300 TIMES
IF A(I:1) = " " THEN NEXT SENTENCE
ELSE
COMPUTE LEN = 300 - I
GO TO PRINTPARA
END-IF
END-PERFORM.
PRINTPARA.
DISPLAY "THE LENGTH OF STRING IN A IS : ", LEN.
STOP RUN.
comment if any errors
regards, |
|
Back to top |
|
|
|