Code: Select all
--This is what I want:
--[123 ]
--[1234 ]
--[ 456]
--[ 3456]
--This is what I get:
--[123 ]
--[1234 ]
--[ 456]
--[ 3456]
stringOud="123"
stringNieuw = stringLengte(stringOud,6,"R")
print(stringNieuw)
stringOud="1234"
stringNieuw = stringLengte(stringOud,6,"R")
print(stringNieuw)
stringOud="456"
stringNieuw = stringLengte(stringOud,6,"L")
print(stringNieuw)
stringOud="3456"
stringNieuw = stringLengte(stringOud,6,"L")
print(stringNieuw)
function stringLengte(stringOud,lengteGewenst,kantOpvullen)
local stringNieuw=""
local lengteBasis=string.len(stringOud)
local lengteRest=lengteGewenst-lengteBasis
if kantOpvullen=="R" then
stringNieuw=(stringOud..string.rep(string.char(32),lengteRest))
elseif kantOpvullen=="L" then
stringNieuw=(string.rep(string.char(32),lengteRest)..stringOud)
end
return stringNieuw
end
The problem with character 32 (space) is that in a print or io.write you don't get all the spaces you want.
I want it because I want a file output with horizontal equal distances.
What is the solution?