| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| shekar123 Advanced
 
 
 Joined: 22 Jul 2005
 Posts: 528
 Topics: 90
 Location: Bangalore India
 
 | 
			
				|  Posted: Wed Nov 09, 2005 5:29 am    Post subject: String syntax needed |   |  
				| 
 |  
				| Hi all, 
 I am basically trying to generate a output like this :
 
 
 
  	  | Code: |  	  | TODAY IS WEDNESDAY@WED
 
 | 
 
 
 
 So i declared the variables like this :
 
 
  	  | Code: |  	  | 01 P PIC X(30) VALUE SPACES.
 01 Q PIC X(1)  VALUE SPACES.
 01 R PIC X(30) VALUE SPACES.
 01 S PIC X(30) VALUE SPACES.
 
 
 PROCEDURE DIVISION.
 
 MOVE 'TODAY IS WEDNESDAY' TO P.
 MOVE '@'                  TO Q.
 MOVE 'WED'                TO R.
 STRING P Q R DELIMITED BY SIZE INTO S.
 DISPLAY "S IS:" S.
 
 | 
 
 
 
 OUTPUT
 ------
 
 
  	  | Code: |  	  | S IS:TODAY IS WEDNESDAY
 
 | 
 
 
 
 But i am not able to get the desired output.Can anybody help me out to get the desired result ?
 _________________
 Shekar
 Grow Technically
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| shekar123 Advanced
 
 
 Joined: 22 Jul 2005
 Posts: 528
 Topics: 90
 Location: Bangalore India
 
 | 
			
				|  Posted: Wed Nov 09, 2005 5:52 am    Post subject: string syntax needed |   |  
				| 
 |  
				| Kolusu, 
 If i use
 
 
  	  | Code: |  	  | STRING P Q R DELIMITED BY SPACE INTO S
 
 | 
 
 i get the result as :
 
 
 
 I am interested in getting the desired output.I still get the same output as before.How can i get the desired output ?
 
 
  	  | Code: |  	  | TODAY IS WEDNESDAY@WED
 
 | 
 
 _________________
 Shekar
 Grow Technically
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Wed Nov 09, 2005 5:55 am    Post subject: |   |  
				| 
 |  
				| shekar123, 
 Did you even read the example I posted ?
  Read the string statement in my example post once again. 
 You can specify the delimited clause for individual fields ! spend some time reading
 
 Kolusu
 _________________
 Kolusu
 www.linkedin.com/in/kolusu
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| shekar123 Advanced
 
 
 Joined: 22 Jul 2005
 Posts: 528
 Topics: 90
 Location: Bangalore India
 
 | 
			
				|  Posted: Wed Nov 09, 2005 6:14 am    Post subject: string syntax needed |   |  
				| 
 |  
				| Kolusu, 
 I have tried out the different options after reading the material & here is what i have tried
 
 
 
  	  | Code: |  	  | STRING P DELIMITED BY SPACE Q DELIMITED BY SPACE
 R DELIMITED BY SPACE INTO S.
 
 | 
 
 
 OUTPUT
 
 
 
 
 
 
 
  	  | Code: |  	  | STRING P DELIMITED BY SIZE  Q DELIMITED BY SPACE
 R DELIMITED BY SPACE INTO S.
 
 | 
 
 
 OUTPUT
 
 
 
 
 My desired result is
 
 
  	  | Code: |  	  | TODAY IS WEDNESDAY@WED
 
 | 
 
 _________________
 Shekar
 Grow Technically
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Wed Nov 09, 2005 8:38 am    Post subject: |   |  
				| 
 |  
				| Shekhar123, 
 Try this.
 
 
  	  | Code: |  	  | 01 P PIC X(30) VALUE SPACES.
 01 Q PIC X(1)  VALUE SPACES.
 01 R PIC X(30) VALUE SPACES.
 01 S PIC X(50) VALUE SPACES.
 01 WS-LEN   PIC S9(04) COMP.
 01 WS-TALLY  PIC S9(04) COMP.
 
 PROCEDURE DIVISION.
 
 MOVE 'TODAY IS WEDNESDAY' TO P.
 MOVE '@'                  TO Q.
 MOVE 'WED'                TO R.
 
 INSPECT FUNCTION REVERSE(P) TALLYING WS-TALLY
 FOR LEADING SPACES
 
 COMPUTE WS-LEN  = LENGTH OF P - WS-TALLY
 
 STRING P(1:WS-LEN) DELIMITED BY SIZE
 Q DELIMITED BY SIZE
 R DELIMITED BY SPACE
 INTO S.
 
 DISPLAY "S IS:" S.
 
 | 
 
 Hope this helps...
 
 Cheers
 
 Kolusu
 _________________
 Kolusu
 www.linkedin.com/in/kolusu
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| shekar123 Advanced
 
 
 Joined: 22 Jul 2005
 Posts: 528
 Topics: 90
 Location: Bangalore India
 
 | 
			
				|  Posted: Wed Nov 09, 2005 8:54 am    Post subject: string syntax needed |   |  
				| 
 |  
				| Thanks Kolusu, 
 You are great.The code worked fine and it gave me expected result.The logic used by you is really awesome and i was able to put light that even intrsinsic functions as well as reference modifications can also be used in Character Functions.
 
 
 
  	  | Code: |  	  | S IS:TODAY IS WEDNESDAY@WED
 
 | 
 
 _________________
 Shekar
 Grow Technically
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  | 
	
		|  |