[Gambas-user] An utility component for Gambas

Julio Sanchez jusabejusabe at ...626...
Mon Dec 1 15:33:08 CET 2014


Hi, Benoît:

 I think this function is interesting: Between

Function Between(string_large as string, word_begin as string, word_end as
string) as string

DIM iinf AS Integer
DIM isup AS Integer
iinf = InStr(string_large,word_begin) + Len(word_begin)
isup = InStr(string_large ,  word_end, iinf)
RETURN Mid(string_large , iinf, isup - iinf)

END

The Between function is the one responsible for finding and extracting a
part of a chain , this contained in a larger string between two words (or
strings).
example :

string_large=" Hello Gambas [improvements] 3.6.9 [/improvements] :)"
word1="[improvements]"
word2="[/improvements]"

text = Between(string_large,word1,word2)

print text
" 3.6.9 "


Note:
Ideally extend to extract parts of web pages ( "<div>" and "</div>" , and
supports nested structures "<div>")

text = "<div> Hello <div> bye </div> <div> "

content = between ( text , "<div>", "</div>")

print content
"<div> bye </div> "

Regards

Julio

2014-12-01 14:48 GMT+01:00 Benoît Minisini <gambas at ...1...>:

> Hi,
>
> I'd like to create a 'gb.util' component, written in Gambas, to collect
> useful non-GUI programming routines that can't go directly into the
> interpreter because it would make it too heavy.
>
> For example:
>
> - Creating a directory and all its parent.
>
> - Removing accents from an UTF-8 string.
>
> - A CsvFile class to read CSV files easily.
>
> - Removing a directory recursively.
>
> - Moving a file or a directory, whether source and destination are on
> the same device or not.
>
> ...
>
> If you have ideas, just drop them. And better, uf you have code, and are
> agree to share it, modify it, maintain it, you are welcome!
>
> The difficulty will be to find the best interface (class name, method
> name, where to put it) for that.
>
> For example, for the removing accents method, I extended the String
> class. Logical... For directory methods, I created a new Shell static
> class...
>
> I'm waiting for your comments!
>
> P.S. The gambas fram client is more and more polished. Don't hesitate to
> play with it. The more tests, the sooner it will be released. I want to
> release Gambas 3.7 as soon as it is ready, even if there is not a lot of
> other changes in Gambas.
>
> Regards,
>
> --
> Benoît Minisini
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list