Format 1: length(,length,position,padding character)
Format 2: lengthw(,length,position,padding character)
Convert to fixed length string. Specify padding characters for left justified or right justified
if it is less than specified length. Specify the justification using "L" or "R" in the “position” parameter. Define the character to be embedded in the “padding character” parameter. Note that if the length of
exceeds the defined length, the ending characters for right justified character strings or beginning characters for left justified character strings will be cut off.
Use fixlenw function for fixed-length conversion on multi-byte characters.
Convert values in the str column to 5 character fixed-length string. Right justified ("R") the strings and fill the empty positions with "#" for strings with less than 5 characters.
$ more dat1.csv id,str 1,abc 2,123 3, 4,1234567 $ mcal c='fixlen($s{str},5,"R","#")' a=rsl i=dat1.csv o=rsl1.csv #END# kgcal a=rsl c=fixlen($s{str},5,"R","#") i=dat1.csv o=rsl1.csv $ more rsl1.csv id,str,rsl 1,abc,##abc 2,123,##123 3,,##### 4,1234567,34567
Fill empty positions for left justified ("L") text with "#".
$ mcal c='fixlen($s{str},5,"L","#")' a=rsl i=dat1.csv o=rsl2.csv #END# kgcal a=rsl c=fixlen($s{str},5,"L","#") i=dat1.csv o=rsl2.csv $ more rsl2.csv id,str,rsl 1,abc,abc## 2,123,123## 3,,##### 4,1234567,12345