## function Split

New to FreeBASIC? Post your questions here.
ptitjoz
Posts: 25
Joined: Jun 24, 2017 8:10
Location: France, centre
Contact:

### Re: function Split

Hello
Many things to see to understand. This forum is rich in your contributions and it is difficult for me to understand everything (and English does not help)
Yes, it's true that copying and pasting does not help you to learn well. That's why I'm doing my experiments trying to help you with the documentation and your remarks.

A bit of code that I had fun doing with basic syntax. It is certainly not fast or optimized but as I often say I try to be pragmatic.

Regards

Code: Select all

`'Split  version 02Dim As String s = "aaaa;bbbbbb;ccccc;ddddddd;eeeeee"  'chaine à découperDim As String t=s 'chaine de travailDim As String d = ";" 'délimiteurDim As Integer nb=0 ' nombre d'éléments Dim As Integer p,i' Recherche du nombre d éléments pour dimenstionner le tableauFor i=1 To Len(s)   If Mid(s,i,1)=d Then nb=nb+1Next' dimensionnement du tableaunb=nb+1 ' rajout de 1 pour dernier élémentDim As String tableau(1 to nb) ' remplissage tableauFor i=1 To nb   p=instr(t,d)   tableau(i)= mid(t,1,p-1)   t=right(t,Len(t)-p)Next' VérificationFor i=1 To nb   Print i,Tableau(i),Len(Tableau(i))Next`
MrSwiss
Posts: 3083
Joined: Jun 02, 2013 9:27
Location: Switzerland

### Re: function Split

ptitjoz wrote:Yes, it's true that copying and pasting does not help you to learn well.
That depends also, on your preferred *way of learning*.

Provided, you study the *way its done* and, the reasons, for doing it *this way*.

You might have to have, the <FB-Manual> handy, to figure out yet unknown *KeyWords*.
(this goes, without *spelling it out*, to understand certain techniques used)

dodicat
Posts: 5771
Joined: Jan 10, 2006 20:30
Location: Scotland

### Re: function Split

Sometimes you'll want a string split by more than one character as a whole deliminator.
For example:

Code: Select all

` Sub string_split(byval s As String,chars As String,result() As String)    redim result(0)    Dim As String var1,var2Dim As long pst,LC=len(chars)      #macro split(stri)    pst=Instr(stri,chars)    var1="":var2=""    If pst<>0 Then    var1=Mid(stri,1,pst-1)    var2=Mid(stri,pst+LC)    Else    var1=striEnd if    if len(var1) then     redim preserve result(1 to ubound(result)+1)    result(ubound(result))=var1    end if    #endmacro   Do   split(s):s=var2Loop Until var2=""End Subdim as string s="aaaa123456789bbbbbb123456789ccccc123456789ddddddd123456789eeeeee"redim as string r()string_split(s,"123456789",r())for n as long=lbound(r) to ubound(r)    print n,r(n)nextsleep  `

There isn't much help within freeBASIC for the crt functions.
Sometimes examples help to understand. (D.J.Peters and strtok for example)
ptitjoz
Posts: 25
Joined: Jun 24, 2017 8:10
Location: France, centre
Contact:

### Re: function Split

MrSwiss wrote:
ptitjoz wrote:Yes, it's true that copying and pasting does not help you to learn well.
That depends also, on your preferred *way of learning*.

Provided, you study the *way its done* and, the reasons, for doing it *this way*.

You might have to have, the <FB-Manual> handy, to figure out yet unknown *KeyWords*.
(this goes, without *spelling it out*, to understand certain techniques used)

Hello
I am running Linux and * .chm help does not work.

Would not there be a manual in pdf (or epub) format?

Thank you
fxm
Posts: 8972
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

### Re: function Split

ptitjoz wrote:I am running Linux and * .chm help does not work.

Use xchm (or gnochm for gnome)?
dodicat
Posts: 5771
Joined: Jan 10, 2006 20:30
Location: Scotland

### Re: function Split

fxm
Posts: 8972
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

### Re: function Split

Or use an online converter to have a newer version.
dodicat
Posts: 5771
Joined: Jan 10, 2006 20:30
Location: Scotland

### Re: function Split

1.05.0
is it not?

Here is the site I used to convert (very good)
http://www.convertfiles.com/convert/ebook/CHM-to-PDF.html
fxm
Posts: 8972
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

### Re: function Split

I thought about convert the daily manual version (.chm) from:
http://users.freebasic-portal.de/stw/builds/
ptitjoz
Posts: 25
Joined: Jun 24, 2017 8:10
Location: France, centre
Contact:

### Re: function Split

thank you very much
the xchm crash
Best regards
dodicat
Posts: 5771
Joined: Jan 10, 2006 20:30
Location: Scotland

### Re: function Split

When I used Linux years ago Firefox and the default browser (can't remember the name), opened the .chm files.
fxm
Posts: 8972
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

### Re: function Split

With the CHM Reader extension for FireFox.
dodicat
Posts: 5771
Joined: Jan 10, 2006 20:30
Location: Scotland

### Re: function Split

Must get back to using Linux again.

There was a win 10 update last night.
It managed to wipe out all my internet history links, every last one.

Goodness knows, could you rely on a system like that for anything important?

### Who is online

Users browsing this forum: No registered users and 4 guests