ID:105455
 
Redundant
Applies to:DM Language
Status: Redundant

This feature has already been implemented, or is already achievable with existing methods.
A simple trim() proc would be nifty feature to reduce spammers (a problem I've had recently).

I've noticed it's not a default proc, so perhaps this could be added and/or be useful to someone else.

proc
trim(msg as text)
var/st = 1
var/len = length(msg)
while(st < len && text2ascii(msg,st) <= 32)
st++

while(st < len && text2ascii(msg,len) <= 32)
len--

return ((st > 0) || (len < length(msg)))? copytext(msg, st, len+1):msg
...if it is so easily made like that then there's not really any reason to add it to the built-in functions. :O
Still, why make something yourself when someone else can make it for you? :)
All you have to do is copytext(Message,1,MaxLength)
Though, I'm not 100% sure what that code of yours is supposed to be doing
my code removes all spaces in front and at the back of a text.
I'm a big fan of trim() in any language, but it can be easily soft-coded and IIRC it already has been in several text handling libraries.