Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert char to num and back to char

Status
Not open for further replies.

thelearner

Programmer
Jan 10, 2004
153
US
D scsw S 2 INZ('03')
D num S 2 0

num = %uns(scsw) -1;
scsw = %editc(num:'X'); // scsw = '02'
why the above coding works but the below doesn't?
scsw = %editc((%uns(scsw)-1):'X'); // scsw = '00'
Is there anyway I can combine the coding into 1 line?

Thanks.



 
scsw = %editc((%uns(scsw)-1):'X');

The interim work field is a length of 2 bytes, thus has value of 002. If you move it to a char field with editcode of x, you get only the first 2 chars. To test, define a work field:
D Work 10A
Work = %editc((%uns(scsw)-1):'X');

and see what happens. Vary the length of scsw and see the result vary.

You could prob get it in one stmt with %subst, but it would be a lot simpler to leave it as 2 statements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top