WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: JTaylor on November 14, 2020, 01:42:44 PM

Title: StrTrim() Enhancement
Post by: JTaylor on November 14, 2020, 01:42:44 PM
Adding a new flag which causes StrTrim()  to remove Spaces, TABs, CRs and LFs would be very helpful.  Thank you.

Jim
Title: Re: StrTrim() Enhancement
Post by: ChuckC on November 14, 2020, 02:04:28 PM
As a stop-gap means of getting that functionality for the time being, have you looked at the string trimming methods available in .NET in System.String class?
Title: Re: StrTrim() Enhancement
Post by: JTaylor on November 14, 2020, 05:35:36 PM
No.  I obviously have ways of accomplishing the task.  Just thought it would be an easy and useful addition to the function and avoid extra code.   I can create a function combining StrTrim() and StrClean() that will do the job since I can't think of time, in this context, when I would want to Trim a string and still want CR or LF anywhere in the string.   Run into this issue a lot dealing with web page data.

I didn't realize until today that the function even had flags until I was going to make the suggestion but wanted to read the documentation and make sure it didn't do more than I thought.

Thanks though.

Jim
Title: Re: StrTrim() Enhancement
Post by: stanl on November 15, 2020, 02:54:40 AM
OT: but in checking out the flag I ran across StrTypeInfo() which I had never used and just found a use for it.


[EDIT:
To elaborate. I was writing CLR code to check if strings were valid HEX. In order to determine this using .NET system.string involved an additional syste.uri class which contained an IsHexDigit() method. StrTypeInfo() a lot easier.
Title: Re: StrTrim() Enhancement
Post by: JTaylor on November 15, 2020, 08:59:48 AM
Thanks for the info.  Will keep this in mind along with Chuck's suggestion.

Jim