"Our system prints out its share of reports and thus has to deal with its share of string padding," writes Jon B.
"There are many, many ways to pad strings with spaces, but our developers has chosen to go use this 'trick' to do it. Here's one example, where a particular field needed to be padded to 30 characters... or perhaps 35"
// Set Route string to 35 bytes first Redim ArrayElement[30]; StrLength := Len(Route); if StrLength > 0 then ArrayElement[1] := Route[1] else ArrayElement[1] := ' '; if StrLength > 1 then ArrayElement[2] := Route[2] else ArrayElement[2] := ' '; if StrLength > 2 then ArrayElement[3] := Route[3] else ArrayElement[3] := ' '; if StrLength > 3 then ArrayElement[4] := Route[4] else ArrayElement[4] := ' '; if StrLength > 4 then ArrayElement[5] := Route[5] else ArrayElement[5] := ' '; if StrLength > 5 then ArrayElement[6] := Route[6] else ArrayElement[6] := ' '; if StrLength > 6 then ArrayElement[7] := Route[7] else ArrayElement[7] := ' '; if StrLength > 7 then ArrayElement[8] := Route[8] else ArrayElement[8] := ' '; if StrLength > 8 then ArrayElement[9] := Route[9] else ArrayElement[9] := ' '; if StrLength > 9 then ArrayElement[10] := Route[10] else ArrayElement[10] := ' '; if StrLength > 10 then ArrayElement[11] := Route[11] else ArrayElement[11] := ' '; if StrLength > 11 then ArrayElement[12] := Route[12] else ArrayElement[12] := ' '; if StrLength > 12 then ArrayElement[13] := Route[13] else ArrayElement[13] := ' '; if StrLength > 13 then ArrayElement[14] := Route[14] else ArrayElement[14] := ' '; if StrLength > 14 then ArrayElement[15] := Route[15] else ArrayElement[15] := ' '; if StrLength > 15 then ArrayElement[16] := Route[16] else ArrayElement[16] := ' '; if StrLength > 16 then ArrayElement[17] := Route[17] else ArrayElement[17] := ' '; if StrLength > 17 then ArrayElement[18] := Route[18] else ArrayElement[18] := ' '; if StrLength > 18 then ArrayElement[19] := Route[19] else ArrayElement[19] := ' '; if StrLength > 19 then ArrayElement[20] := Route[20] else ArrayElement[20] := ' '; if StrLength > 20 then ArrayElement[21] := Route[21] else ArrayElement[21] := ' '; if StrLength > 21 then ArrayElement[22] := Route[22] else ArrayElement[22] := ' '; if StrLength > 22 then ArrayElement[23] := Route[23] else ArrayElement[23] := ' '; if StrLength > 23 then ArrayElement[24] := Route[24] else ArrayElement[24] := ' '; if StrLength > 24 then ArrayElement[25] := Route[25] else ArrayElement[25] := ' '; if StrLength > 25 then ArrayElement[26] := Route[26] else ArrayElement[26] := ' '; if StrLength > 26 then ArrayElement[27] := Route[27] else ArrayElement[27] := ' '; if StrLength > 27 then ArrayElement[28] := Route[28] else ArrayElement[28] := ' '; if StrLength > 28 then ArrayElement[29] := Route[29] else ArrayElement[29] := ' '; if StrLength > 29 then ArrayElement[30] := Route[30] else ArrayElement[30] := ' '; InsertString := ''; for i := 1 to 30 do InsertString := InsertString + ArrayElement[i];
Jon adds, "it wouldn't be so bad, except this same code is repeated 10 lines further down to pad something else to 8 chars. And the business wonders why it takes so long to create new reports..."
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!