May 09, 2024, 02:14:38 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


REQUET: Text Functions

Started by tekrat, March 12, 2008, 04:28:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tekrat

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.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

tekrat

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.