View previous topic :: View next topic
|
Author |
Message |
suvidha Warnings : 1 New User
Joined: 06 Aug 2007 Posts: 1 Location: Bangalore
|
|
|
|
Can I move value of variable of length 9 characters to variable of length 7.Only I want first 7 characters in final variable.If yes , then how? |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
suvidha,
Quote: |
I want first 7 characters in final variable.If yes , then how? |
You can directly move the data from X(9) to X(7) as both the fields are declared as alphanumeric. The last two bytes would get truncated moving the first 7 characters to the X(7) field.
Even though this works, try using the reference modification technique. |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
In details:
Field9 pic x(9)
Field7 pic x(7)
Pos pic s9(4) comp
Lng pic s9(4) comp
Dlm pic x(1) value '$'
move field9 to field7 ...simple & clear !!!
move field9 (1:7) to field7 ...a very little bit more transparent
move 1 to pos ...for making it of variable use
move 7 to lng
move field9 (pos:lng) to field7
move field9 (pos:lng) to field7 (pos:lng)
move dlm to field9 (8:1) ...for making it more confusing
string field9 delimited by dlm into field7
unstring field9 delimited by dlm into field7
Regards, UmeySan |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi all !
That's why i posted it. Because six answers had been posted before mine
for solving this simple question. So i was leaded into temptation to put in my two cents.
Only YES and "move field9 to field7" could have been enougth.
@ enrico-sorichetti
Right, i agree! A link to the fine manual would have been a good hint.
Regards, UmeySan |
|
Back to top |
|
|
|