On Tuesday, June 29, 1999, 05:00 AM, mike7 wrote: Example If a field is define as 30 alpha(field named=#asd) , and that field Data was stored like----'fees..........................' (. = blank) and you wanted to print it like--'.............fees.............' or pretty closed to the center, how would this be done. I try Eval xxxx = %trim(#asd) #asd = the name of the field within a file xxxx = the name you want to print out Define blanks as a field or constant at least half as long as the name you want to print out. C eval xxxx = %subst(blanks:1: C %inth((%size(xxxx)- C -%len(%trim(#asd)))/2)) C + %triml(#asd)
That's pretty ugly, though. If you do a lot of centering, here's a procedure to center data for an output field up to 100 characters long. Call it like this: C eval xxxx = center(%trim(#asd) : %size(xxxx))
p center b D center pi 100a varying D data 100a varying const D result_len 10u 0 value D blanks s 100a inz(*blanks) D num_blanks s 10u 0 C eval(h) num_blanks = (result_len - %len(data))/2 C return %subst(blanks : 1 : num_blanks) C + data C + %subst(blanks : 1 : num_blanks) p center e
Barbara Morris, IBM Toronto Lab, RPG Compiler Development