IonicWind Software

IWBasic => General Questions => Topic started by: tekrat on March 12, 2008, 04:28:00 PM

Title: REQUET: Text Functions
Post by: tekrat on March 12, 2008, 04:28:00 PM
I was wondering if in the next sub version of Emergence BASIC, if a couple of function could be added:

SPLIT(<SOURCE STRING>, <STRING TO SPLIT THE SOURCE BY>) return an array of STRINGs or WSTRINGs as needed based on the SOURCE STRING

TRIM$(<SOURCE STRING>) - Just combine LTRIM$ and RTRIM$ as needed based on the SOURCE STRING

LEFT$(<SOURCE STRING>, <LENGTH>) - Starts at the first charector and cut of after the LENGTH if the string is at least that long.  Otherwise, just return the original string.

RIGHT$(<SOURCE STRING>, <LENGTH>) - Starts at the first charector and cut of after the LENGTH if the string is at least that long.  Otherwise, just return the original string.

I know its basic string manipulation and can be done other ways, but having them native would be alot faster then anything I could write.  Plus it would help others coiming into the language.  I would be willing donate some extra money if it would help.
Title: Re: REQUET: Text Functions
Post by: LarryMc on March 12, 2008, 05:23:17 PM
I'm missing something ???

Your description of left$ and right$ are exactly the same.
What are you wanting LEFT$ and RIGHT$ to do that the embedded LEFT$ and RIGHT$ functions don't already do?

I use my own function that I call btrim$

global sub btrim$(text$ as string),string
   string ret
   ret=ltrim$(rtrim$(text$))
   return ret
endsub


And for the split thing I use the SplitTwo function from Fletchie's CTL.lib.

Larry
Title: Re: REQUEST: Text Functions
Post by: tekrat on March 13, 2008, 06:10:47 AM
I stand corrected on the left$ and right$.  For some reason it wasn't coming up in my help documentation. 

As to the trim function, I've built something similar to what you've posted.  But it would be much faster, easier, and use less memory if the function was already built into the language.  A trim function already exists in most modern basic languages, as does a version of the split function.

Again, I know others have generated their own version of the split function but again it would faster, easier, and use less memory if it was already built into Emergence Basic.