Page 1 of 1
trim() in dzVents ? [Solved]
Posted: Sunday 05 November 2023 11:00
by willemd
Does dzvents have a trim() function? I cannot find it in the documentation.
I am importing data and one of the fields has a trailing space that I want to remove.
I tried the stringSplit function with space as separator but this did not achieve the result.
Currently I am forcing conversion to a number and then converting back to a string to achieve this.
Does a trim() function exist?
Re: trim() in dzVents ?
Posted: Sunday 05 November 2023 11:13
by Doler
Don't know if dzvents has this function but in case not:
Code: Select all
-- Trim a string
stringTrim = function(s)
return s:match'^%s*(.*%S)' or ''
end
Re: trim() in dzVents ?
Posted: Sunday 05 November 2023 16:22
by waltervl
Dzvents has no trim function, neither does Lua but there are lots of ways to create one:
http://lua-users.org/wiki/StringTrim
Re: trim() in dzVents ?
Posted: Sunday 05 November 2023 17:30
by willemd
Thank you both, one solution is enough
What kind of programming language is used for that function definition? I don't recognise it and can't decifer the logic. It works but I don't see why.
Re: trim() in dzVents ?
Posted: Sunday 05 November 2023 21:53
by Doler
It's Lua. There is a little error in the function (sorry for that): 'match' should be 'string.match'. I guess you can recognize it now.
Re: trim() in dzVents ?
Posted: Sunday 05 November 2023 22:34
by willemd
Assembler, basic, algol, pascal, lisp, cobol, various 4gl's, python, dzVents, probably forgetting a few .... I am trying not to add Lua to it.
Thank you for your solution.