[Gambas-user] [Gambas Bug Tracker] Bug #1102: ODBC driver super buggy 3: impossible made subquerys if the previous its a call/select to SP

2017-06-27 Thread bugtracker
http://gambaswiki.org/bugtracker/edit?object=BUG.1102=L21haW4-

Comment #1 by PICCORO LENZ MCKAY:

hi, this query make me impossible document and find a solution to how populate 
a grid not using the Data event...

i send a issue to freetds project, due this error today does not permit to me 
got some progress in the odbc+gridview work 
https://github.com/FreeTDS/freetds/issues/131

but the problem i guess its not totally freetds driver due in odbc+sqlite i 
cannot make simple quierys after connected... but the odbc+sqlite module are in 
good shape



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Fernando Cabral
Jussi said:

> As Fernando stated your code is good only for small arrays. But if someone
>is going to use it, here is correct implementation:

No, Jussi, I didn't say it is good only for small arrays. I said some
suggestions apply only
to small arrays because if I have to traverse the array again and again,
advancing one item at a time, and coming back to the next item, to repeat
it one more time, then time requirement will grow exponentially. This makes
most suggestion unusable for large arrays. The arrays I have might grow to
thousands and thousands os items.

Regards

- fernando






2017-06-27 15:43 GMT-03:00 Jussi Lahtinen :

> As Fernando stated your code is good only for small arrays. But if someone
> is going to use it, here is correct implementation:
>
> For x = 0 to a.Max
>   if z.Find(a[x]) = -1 Then z.Add(a[x])
> Next
>
>
> z.Exist() might be faster... I don't know.
>
>
>
> Jussi
>
>
>
> On Tue, Jun 27, 2017 at 6:59 PM,  wrote:
>
> > Well, there is complicated, then there is simplicity:
> > I tested this. Works for sorted, unsorted.
> > Can't be any simpler.
> >
> > Public Function RemoveMultiple(a As String[]) As String[]
> >
> > Dim x as Integer
> > Dim z as NEW STRING[]
> >
> > For x = 1 to a.count()
> >   if z.Find(a) = 0 Then z.Add(a[x])
> > Next
> >
> > 'if you want it sorted, do it here
> > Return z
> >
> > END
> >
> > ' - - - - -
> > use it this way:
> >
> > myArray = RemoveMultiple(myArray)
> >   'the z array is now myArray.
> >   'the original array is destroyed because there are no references.
> >
> >
> >
> > --
> > Open WebMail Project (http://openwebmail.org)
> >
> >
> > -- Original Message ---
> > From: Gianluigi 
> > To: mailing list for gambas users 
> > Sent: Tue, 27 Jun 2017 16:52:48 +0200
> > Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate
> items
> > in a array
> >
> > > My two cents.
> > >
> > > Public Sub Main()
> > >
> > >   Dim sSort As String[] = ["A", "B", "B", "B", "C", "D", "D", "E", "E",
> > > "E", "E", "F"]
> > >   Dim sSame As String[] = sSort
> > >   Dim bb As New Byte[]
> > >   Dim sSingle As New String[]
> > >   Dim i, n As Integer
> > >
> > >   For i = 0 To sSort.Max
> > > If i < sSort.Max Then
> > >   If sSort[i] = sSame[i + 1] Then
> > > Inc n
> > >   Else
> > > sSingle.Push(sSort[i])
> > > bb.Push(n + 1)
> > > n = 0
> > >   Endif
> > > Endif
> > >   Next
> > >   sSingle.Push(sSort[sSort.Max])
> > >   bb.Push(n + 1)
> > >   For i = 0 To sSingle.Max
> > > Print sSingle[i]
> > >   Next
> > >   For i = 0 To bb.Max
> > > Print bb[i] & sSingle[i]
> > >   Next
> > >
> > > End
> > >
> > > Regards
> > > Gianluigi
> > >
> > > 2017-06-27 16:33 GMT+02:00 :
> > >
> > > > Another very effective and simple would be:
> > > >
> > > > You have your array with data
> > > > You create a new empty array.
> > > >
> > > > Loop through each item in your array with data
> > > > If it's not in the new array, then add it.
> > > >
> > > > Destroy the original array.
> > > > Keep the new one.
> > > > ...something like (syntax may not be correct)
> > > >
> > > > Public Function RemoveMultiple(a As String[]) As String[]
> > > >
> > > >   Dim x as Integer
> > > >   Dim z as NEW STRING[]
> > > >
> > > >   For x = 1 to a.count()
> > > > if z.Find(a) = 0 Then z.Add(a[x])
> > > >   Next
> > > >
> > > >   Return z
> > > >
> > > > END
> > > >
> > > > -Nando (Canada)
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Open WebMail Project (http://openwebmail.org)
> > > >
> > > >
> > > > -- Original Message ---
> > > > From: Hans Lehmann 
> > > > To: gambas-user@lists.sourceforge.net
> > > > Sent: Tue, 27 Jun 2017 15:51:19 +0200
> > > > Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate
> > items
> > > > in a array
> > > >
> > > > > Hello,
> > > > >
> > > > > look here:
> > > > >
> > > > > 8<--
> > > > -
> > > > > -- Public Function RemoveMultiple(aStringListe As String[])
> > As
> > > > String[]
> > > > >  Dim iCount As Integer   Dim iIndex As Integer   Dim sElement As
> > String
> > > > >
> > > > >iIndex = 0 ' Initialisierung NICHT notwendig
> > > > >While iIndex < aStringListe.Count
> > > > >  iCount = 0
> > > > >  sElement = aStringListe[iIndex]
> > > > >  While aStringListe.Find(sElement) <> -1
> > > > >Inc iCount
> > > > >aStringListe.Remove(aStringListe.Find(sElement))
> > > > >  Wend
> > > > >  If iCount Mod 2 = 1 Then
> > > > > aStringListe.Add(sElement, iIndex)
> > > > > Inc iIndex
> > > > >  Endif ' iCount Mod 2 = 1 ?
> > > > >Wend
> > > > >
> > > > >Return aStringListe
> > > > >
> > > > > End ' RemoveMultiple(...)
> > > > > 

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Jussi Lahtinen
As Fernando stated your code is good only for small arrays. But if someone
is going to use it, here is correct implementation:

For x = 0 to a.Max
  if z.Find(a[x]) = -1 Then z.Add(a[x])
Next


z.Exist() might be faster... I don't know.



Jussi



On Tue, Jun 27, 2017 at 6:59 PM,  wrote:

> Well, there is complicated, then there is simplicity:
> I tested this. Works for sorted, unsorted.
> Can't be any simpler.
>
> Public Function RemoveMultiple(a As String[]) As String[]
>
> Dim x as Integer
> Dim z as NEW STRING[]
>
> For x = 1 to a.count()
>   if z.Find(a) = 0 Then z.Add(a[x])
> Next
>
> 'if you want it sorted, do it here
> Return z
>
> END
>
> ' - - - - -
> use it this way:
>
> myArray = RemoveMultiple(myArray)
>   'the z array is now myArray.
>   'the original array is destroyed because there are no references.
>
>
>
> --
> Open WebMail Project (http://openwebmail.org)
>
>
> -- Original Message ---
> From: Gianluigi 
> To: mailing list for gambas users 
> Sent: Tue, 27 Jun 2017 16:52:48 +0200
> Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate items
> in a array
>
> > My two cents.
> >
> > Public Sub Main()
> >
> >   Dim sSort As String[] = ["A", "B", "B", "B", "C", "D", "D", "E", "E",
> > "E", "E", "F"]
> >   Dim sSame As String[] = sSort
> >   Dim bb As New Byte[]
> >   Dim sSingle As New String[]
> >   Dim i, n As Integer
> >
> >   For i = 0 To sSort.Max
> > If i < sSort.Max Then
> >   If sSort[i] = sSame[i + 1] Then
> > Inc n
> >   Else
> > sSingle.Push(sSort[i])
> > bb.Push(n + 1)
> > n = 0
> >   Endif
> > Endif
> >   Next
> >   sSingle.Push(sSort[sSort.Max])
> >   bb.Push(n + 1)
> >   For i = 0 To sSingle.Max
> > Print sSingle[i]
> >   Next
> >   For i = 0 To bb.Max
> > Print bb[i] & sSingle[i]
> >   Next
> >
> > End
> >
> > Regards
> > Gianluigi
> >
> > 2017-06-27 16:33 GMT+02:00 :
> >
> > > Another very effective and simple would be:
> > >
> > > You have your array with data
> > > You create a new empty array.
> > >
> > > Loop through each item in your array with data
> > > If it's not in the new array, then add it.
> > >
> > > Destroy the original array.
> > > Keep the new one.
> > > ...something like (syntax may not be correct)
> > >
> > > Public Function RemoveMultiple(a As String[]) As String[]
> > >
> > >   Dim x as Integer
> > >   Dim z as NEW STRING[]
> > >
> > >   For x = 1 to a.count()
> > > if z.Find(a) = 0 Then z.Add(a[x])
> > >   Next
> > >
> > >   Return z
> > >
> > > END
> > >
> > > -Nando (Canada)
> > >
> > >
> > >
> > >
> > > --
> > > Open WebMail Project (http://openwebmail.org)
> > >
> > >
> > > -- Original Message ---
> > > From: Hans Lehmann 
> > > To: gambas-user@lists.sourceforge.net
> > > Sent: Tue, 27 Jun 2017 15:51:19 +0200
> > > Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate
> items
> > > in a array
> > >
> > > > Hello,
> > > >
> > > > look here:
> > > >
> > > > 8<--
> > > -
> > > > -- Public Function RemoveMultiple(aStringListe As String[])
> As
> > > String[]
> > > >  Dim iCount As Integer   Dim iIndex As Integer   Dim sElement As
> String
> > > >
> > > >iIndex = 0 ' Initialisierung NICHT notwendig
> > > >While iIndex < aStringListe.Count
> > > >  iCount = 0
> > > >  sElement = aStringListe[iIndex]
> > > >  While aStringListe.Find(sElement) <> -1
> > > >Inc iCount
> > > >aStringListe.Remove(aStringListe.Find(sElement))
> > > >  Wend
> > > >  If iCount Mod 2 = 1 Then
> > > > aStringListe.Add(sElement, iIndex)
> > > > Inc iIndex
> > > >  Endif ' iCount Mod 2 = 1 ?
> > > >Wend
> > > >
> > > >Return aStringListe
> > > >
> > > > End ' RemoveMultiple(...)
> > > > 8<--
> > > -
> > > > --
> > > >
> > > > Hans
> > > > gambas-buch.de
> > > >
> > > > 
> > > --
> > > > Check out the vibrant tech community on one of the world's most
> > > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > > ___
> > > > Gambas-user mailing list
> > > > Gambas-user@lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > --- End of Original Message ---
> > >
> > >
> > > 
> > > --
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > ___
> > > Gambas-user mailing list
> > > Gambas-user@lists.sourceforge.net
> > > 

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Fernando Cabral
Nando

The problem with this search and destroy method without pre-sorting is the
exponentional
growth in time needed to do the job.  If my math is not wrong, this is how
quickly it gets unmanageable:

Items / Comparisons needed (worst case scenario)
10 = 45
100 = 4,950
1000 = 499,500
1000 = 49,995,000

My program has to face a few thousand items, so not sorting does not seem a
good option.

Regards

- fernando



2017-06-27 12:59 GMT-03:00 :

> Well, there is complicated, then there is simplicity:
> I tested this. Works for sorted, unsorted.
> Can't be any simpler.
>
> Public Function RemoveMultiple(a As String[]) As String[]
>
> Dim x as Integer
> Dim z as NEW STRING[]
>
> For x = 1 to a.count()
>   if z.Find(a) = 0 Then z.Add(a[x])
> Next
>
> 'if you want it sorted, do it here
> Return z
>
> END
>
> ' - - - - -
> use it this way:
>
> myArray = RemoveMultiple(myArray)
>   'the z array is now myArray.
>   'the original array is destroyed because there are no references.
>
>
>
> --
> Open WebMail Project (http://openwebmail.org)
>
>
> -- Original Message ---
> From: Gianluigi 
> To: mailing list for gambas users 
> Sent: Tue, 27 Jun 2017 16:52:48 +0200
> Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate items
> in a array
>
> > My two cents.
> >
> > Public Sub Main()
> >
> >   Dim sSort As String[] = ["A", "B", "B", "B", "C", "D", "D", "E", "E",
> > "E", "E", "F"]
> >   Dim sSame As String[] = sSort
> >   Dim bb As New Byte[]
> >   Dim sSingle As New String[]
> >   Dim i, n As Integer
> >
> >   For i = 0 To sSort.Max
> > If i < sSort.Max Then
> >   If sSort[i] = sSame[i + 1] Then
> > Inc n
> >   Else
> > sSingle.Push(sSort[i])
> > bb.Push(n + 1)
> > n = 0
> >   Endif
> > Endif
> >   Next
> >   sSingle.Push(sSort[sSort.Max])
> >   bb.Push(n + 1)
> >   For i = 0 To sSingle.Max
> > Print sSingle[i]
> >   Next
> >   For i = 0 To bb.Max
> > Print bb[i] & sSingle[i]
> >   Next
> >
> > End
> >
> > Regards
> > Gianluigi
> >
> > 2017-06-27 16:33 GMT+02:00 :
> >
> > > Another very effective and simple would be:
> > >
> > > You have your array with data
> > > You create a new empty array.
> > >
> > > Loop through each item in your array with data
> > > If it's not in the new array, then add it.
> > >
> > > Destroy the original array.
> > > Keep the new one.
> > > ...something like (syntax may not be correct)
> > >
> > > Public Function RemoveMultiple(a As String[]) As String[]
> > >
> > >   Dim x as Integer
> > >   Dim z as NEW STRING[]
> > >
> > >   For x = 1 to a.count()
> > > if z.Find(a) = 0 Then z.Add(a[x])
> > >   Next
> > >
> > >   Return z
> > >
> > > END
> > >
> > > -Nando (Canada)
> > >
> > >
> > >
> > >
> > > --
> > > Open WebMail Project (http://openwebmail.org)
> > >
> > >
> > > -- Original Message ---
> > > From: Hans Lehmann 
> > > To: gambas-user@lists.sourceforge.net
> > > Sent: Tue, 27 Jun 2017 15:51:19 +0200
> > > Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate
> items
> > > in a array
> > >
> > > > Hello,
> > > >
> > > > look here:
> > > >
> > > > 8<--
> > > -
> > > > -- Public Function RemoveMultiple(aStringListe As String[])
> As
> > > String[]
> > > >  Dim iCount As Integer   Dim iIndex As Integer   Dim sElement As
> String
> > > >
> > > >iIndex = 0 ' Initialisierung NICHT notwendig
> > > >While iIndex < aStringListe.Count
> > > >  iCount = 0
> > > >  sElement = aStringListe[iIndex]
> > > >  While aStringListe.Find(sElement) <> -1
> > > >Inc iCount
> > > >aStringListe.Remove(aStringListe.Find(sElement))
> > > >  Wend
> > > >  If iCount Mod 2 = 1 Then
> > > > aStringListe.Add(sElement, iIndex)
> > > > Inc iIndex
> > > >  Endif ' iCount Mod 2 = 1 ?
> > > >Wend
> > > >
> > > >Return aStringListe
> > > >
> > > > End ' RemoveMultiple(...)
> > > > 8<--
> > > -
> > > > --
> > > >
> > > > Hans
> > > > gambas-buch.de
> > > >
> > > > 
> > > --
> > > > Check out the vibrant tech community on one of the world's most
> > > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > > ___
> > > > Gambas-user mailing list
> > > > Gambas-user@lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > --- End of Original Message ---
> > >
> > >
> > > 
> > > --
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, Slashdot.org! 

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Tobias Boege
On Tue, 27 Jun 2017, Fernando Cabral wrote:
> So, my question is basically if Gambas has some built in method do
> eliminate duplicates.
> The reason I am asking this is because I am new to Gambas, so I have found
> myself coding
> things that were not needed. For instance, I coded some functions to do
> quicksort and bubble sort and then I found Array.sort () was available.
> Therefore, I waisted my time coding those quicksort and bubble sort
> functions :-(
> 

Ah, ok. I'm almost sure there is no built-in "uniq" function which gets
rid of consecutive duplicates, so you can go ahead and write your own :-)

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Fernando Cabral
2017-06-27 11:29 GMT-03:00 Tobias Boege :

>
> Your first sentence is a bit confusing. First you say that your array is
> sorted but then you say that duplicates may be scattered across the array.
>
You are right. My fault. The array is sorted. What I meant by scattered was
that
pairs, duples, triplets or a bunch of duplicates may appear all over
interspersed with non-duplicated items.

My items are either words or sentences (extracted from an ODT file.
After the extraction, the words (or sentences) are sorted with the method
Array.sort(gb.descent).

After sorting it is much more efficient to search for the duplicates. And
it can be done
with some simple code (as some people have exemplified in this thread).

So, my question is basically if Gambas has some built in method do
eliminate duplicates.
The reason I am asking this is because I am new to Gambas, so I have found
myself coding
things that were not needed. For instance, I coded some functions to do
quicksort and bubble sort and then I found Array.sort () was available.
Therefore, I waisted my time coding those quicksort and bubble sort
functions :-(

Regards

- fernando


> If you have a sorting where duplicates are consecutive, the solution is
> very easy: just go through the array linearly and kick out these
> consecutive
> duplicates (which is precisely what uniq does), e.g. for integers:
>
>   Dim aInts As Integer[] = ...
>   Dim iInd, iLast As Integer
>
>   If Not aInts.Count Then Return
>   iLast = aInts[0]
>   iInd = 1
>   While iInd < aInts.Count
> If aInts[iInd] = iLast Then ' consecutive duplicate
>   aInts.Remove(iInd, 1)
> Else
>   iLast = aInts[iInd]
>   Inc iInd
> Endif
>   Wend
>
> Note that the way I wrote it to get the idea across is not a linear-time
> operation (it depends on the complexity of aInts.Remove()), but you can
> achieve linear performance by writing better code. Think of it as an
> exercise. (Of course, you can't hope to be more efficient than linear
> time in a general situation.)
>
> The counting task is solved with a similar pattern, but while you kick
> an element out, you also increment a dedicated counter:
>
>   Dim aInts As Integer[] = ...
>   Dim aDups As New Integer[]
>   Dim iInd, iLast As Integer
>
>   If Not aInts.Count Then Return
>   iLast = aInts[0]
>   iInd = 1
>   aDups.Add(0)
>   While iInd < aInts.Count
> If aInts[iInd] = iLast Then ' consecutive duplicate
>   aInts.Remove(iInd, 1)
>   Inc aDups[aDups.Max]
> Else
>   iLast = aInts[iInd]
>   aDups.Add(0)
>   Inc iInd
> Endif
>   Wend
>
> After this executed, the array aInts will not contain duplicates (supposing
> it was sorted before) and aDups[i] will contain the number of duplicates of
> the item aInts[i] that were removed.
>
> Regards,
> Tobi
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: fernandojosecab...@gmail.com
Facebook: f...@fcabral.com.br
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread nando_f
Well, there is complicated, then there is simplicity:
I tested this. Works for sorted, unsorted.
Can't be any simpler.

Public Function RemoveMultiple(a As String[]) As String[]

Dim x as Integer
Dim z as NEW STRING[]

For x = 1 to a.count()
  if z.Find(a) = 0 Then z.Add(a[x])
Next

'if you want it sorted, do it here
Return z

END

' - - - - -
use it this way:

myArray = RemoveMultiple(myArray)
  'the z array is now myArray.
  'the original array is destroyed because there are no references.



--
Open WebMail Project (http://openwebmail.org)


-- Original Message ---
From: Gianluigi 
To: mailing list for gambas users 
Sent: Tue, 27 Jun 2017 16:52:48 +0200
Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate items in a 
array

> My two cents.
> 
> Public Sub Main()
> 
>   Dim sSort As String[] = ["A", "B", "B", "B", "C", "D", "D", "E", "E",
> "E", "E", "F"]
>   Dim sSame As String[] = sSort
>   Dim bb As New Byte[]
>   Dim sSingle As New String[]
>   Dim i, n As Integer
> 
>   For i = 0 To sSort.Max
> If i < sSort.Max Then
>   If sSort[i] = sSame[i + 1] Then
> Inc n
>   Else
> sSingle.Push(sSort[i])
> bb.Push(n + 1)
> n = 0
>   Endif
> Endif
>   Next
>   sSingle.Push(sSort[sSort.Max])
>   bb.Push(n + 1)
>   For i = 0 To sSingle.Max
> Print sSingle[i]
>   Next
>   For i = 0 To bb.Max
> Print bb[i] & sSingle[i]
>   Next
> 
> End
> 
> Regards
> Gianluigi
> 
> 2017-06-27 16:33 GMT+02:00 :
> 
> > Another very effective and simple would be:
> >
> > You have your array with data
> > You create a new empty array.
> >
> > Loop through each item in your array with data
> > If it's not in the new array, then add it.
> >
> > Destroy the original array.
> > Keep the new one.
> > ...something like (syntax may not be correct)
> >
> > Public Function RemoveMultiple(a As String[]) As String[]
> >
> >   Dim x as Integer
> >   Dim z as NEW STRING[]
> >
> >   For x = 1 to a.count()
> > if z.Find(a) = 0 Then z.Add(a[x])
> >   Next
> >
> >   Return z
> >
> > END
> >
> > -Nando (Canada)
> >
> >
> >
> >
> > --
> > Open WebMail Project (http://openwebmail.org)
> >
> >
> > -- Original Message ---
> > From: Hans Lehmann 
> > To: gambas-user@lists.sourceforge.net
> > Sent: Tue, 27 Jun 2017 15:51:19 +0200
> > Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate items
> > in a array
> >
> > > Hello,
> > >
> > > look here:
> > >
> > > 8<--
> > -
> > > -- Public Function RemoveMultiple(aStringListe As String[]) As
> > String[]
> > >  Dim iCount As Integer   Dim iIndex As Integer   Dim sElement As String
> > >
> > >iIndex = 0 ' Initialisierung NICHT notwendig
> > >While iIndex < aStringListe.Count
> > >  iCount = 0
> > >  sElement = aStringListe[iIndex]
> > >  While aStringListe.Find(sElement) <> -1
> > >Inc iCount
> > >aStringListe.Remove(aStringListe.Find(sElement))
> > >  Wend
> > >  If iCount Mod 2 = 1 Then
> > > aStringListe.Add(sElement, iIndex)
> > > Inc iIndex
> > >  Endif ' iCount Mod 2 = 1 ?
> > >Wend
> > >
> > >Return aStringListe
> > >
> > > End ' RemoveMultiple(...)
> > > 8<--
> > -
> > > --
> > >
> > > Hans
> > > gambas-buch.de
> > >
> > > 
> > --
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > ___
> > > Gambas-user mailing list
> > > Gambas-user@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > --- End of Original Message ---
> >
> >
> > 
> > --
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > ___
> > Gambas-user mailing list
> > Gambas-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
--- End of Original Message ---


--
Check out the vibrant tech community on one of the world's most
engaging tech 

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Gianluigi
My two cents.

Public Sub Main()

  Dim sSort As String[] = ["A", "B", "B", "B", "C", "D", "D", "E", "E",
"E", "E", "F"]
  Dim sSame As String[] = sSort
  Dim bb As New Byte[]
  Dim sSingle As New String[]
  Dim i, n As Integer

  For i = 0 To sSort.Max
If i < sSort.Max Then
  If sSort[i] = sSame[i + 1] Then
Inc n
  Else
sSingle.Push(sSort[i])
bb.Push(n + 1)
n = 0
  Endif
Endif
  Next
  sSingle.Push(sSort[sSort.Max])
  bb.Push(n + 1)
  For i = 0 To sSingle.Max
Print sSingle[i]
  Next
  For i = 0 To bb.Max
Print bb[i] & sSingle[i]
  Next

End

Regards
Gianluigi

2017-06-27 16:33 GMT+02:00 :

> Another very effective and simple would be:
>
> You have your array with data
> You create a new empty array.
>
> Loop through each item in your array with data
> If it's not in the new array, then add it.
>
> Destroy the original array.
> Keep the new one.
> ...something like (syntax may not be correct)
>
> Public Function RemoveMultiple(a As String[]) As String[]
>
>   Dim x as Integer
>   Dim z as NEW STRING[]
>
>   For x = 1 to a.count()
> if z.Find(a) = 0 Then z.Add(a[x])
>   Next
>
>   Return z
>
> END
>
> -Nando (Canada)
>
>
>
>
> --
> Open WebMail Project (http://openwebmail.org)
>
>
> -- Original Message ---
> From: Hans Lehmann 
> To: gambas-user@lists.sourceforge.net
> Sent: Tue, 27 Jun 2017 15:51:19 +0200
> Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate items
> in a array
>
> > Hello,
> >
> > look here:
> >
> > 8<--
> -
> > -- Public Function RemoveMultiple(aStringListe As String[]) As
> String[]
> >  Dim iCount As Integer   Dim iIndex As Integer   Dim sElement As String
> >
> >iIndex = 0 ' Initialisierung NICHT notwendig
> >While iIndex < aStringListe.Count
> >  iCount = 0
> >  sElement = aStringListe[iIndex]
> >  While aStringListe.Find(sElement) <> -1
> >Inc iCount
> >aStringListe.Remove(aStringListe.Find(sElement))
> >  Wend
> >  If iCount Mod 2 = 1 Then
> > aStringListe.Add(sElement, iIndex)
> > Inc iIndex
> >  Endif ' iCount Mod 2 = 1 ?
> >Wend
> >
> >Return aStringListe
> >
> > End ' RemoveMultiple(...)
> > 8<--
> -
> > --
> >
> > Hans
> > gambas-buch.de
> >
> > 
> --
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > ___
> > Gambas-user mailing list
> > Gambas-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> --- End of Original Message ---
>
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread nando_f
Another very effective and simple would be:

You have your array with data
You create a new empty array.

Loop through each item in your array with data
If it's not in the new array, then add it.

Destroy the original array.
Keep the new one.
...something like (syntax may not be correct)

Public Function RemoveMultiple(a As String[]) As String[] 

  Dim x as Integer
  Dim z as NEW STRING[]

  For x = 1 to a.count()
if z.Find(a) = 0 Then z.Add(a[x])
  Next

  Return z

END

-Nando (Canada)




--
Open WebMail Project (http://openwebmail.org)


-- Original Message ---
From: Hans Lehmann 
To: gambas-user@lists.sourceforge.net
Sent: Tue, 27 Jun 2017 15:51:19 +0200
Subject: Re: [Gambas-user] I need a hint on how to deleted duplicate items in a 
array

> Hello,
> 
> look here:
> 
> 8<---
> -- Public Function RemoveMultiple(aStringListe As String[]) As 
> String[]  
>  Dim iCount As Integer   Dim iIndex As Integer   Dim sElement As String
> 
>iIndex = 0 ' Initialisierung NICHT notwendig
>While iIndex < aStringListe.Count
>  iCount = 0
>  sElement = aStringListe[iIndex]
>  While aStringListe.Find(sElement) <> -1
>Inc iCount
>aStringListe.Remove(aStringListe.Find(sElement))
>  Wend
>  If iCount Mod 2 = 1 Then
> aStringListe.Add(sElement, iIndex)
> Inc iIndex
>  Endif ' iCount Mod 2 = 1 ?
>Wend
> 
>Return aStringListe
> 
> End ' RemoveMultiple(...)
> 8<---
> --
> 
> Hans
> gambas-buch.de
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
--- End of Original Message ---


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Tobias Boege
On Tue, 27 Jun 2017, Fernando Cabral wrote:
> Hi
> 
> I have a sorted array that may contain several repeated items scattered all
> over.
> 
> I have to do two different things at different times:
> a) Eliminate the duplicates leaving a single specimen from each repeated
> item;
> b) Eliminate the duplicates but having a count of the original number.
> 
> So, if I have, say
> 
> A
> B
> B
> C
> D
> D
> 
> In the first option, I want to have
> A
> B
> C
> D
> In the second option, I want to have
> 1 A
> 2 B
> 1 C
> 2 D
> 
> Any hints on how to do this using some Gambas buit in method?
> 
> Note; Presently I have been doing it using external calls to
> the utilities sort and uniq.
> 

Your first sentence is a bit confusing. First you say that your array is
sorted but then you say that duplicates may be scattered across the array.
There are notions of order (namely *preorder*) which are so weak that this
could happen, but are you actually dealing with a preorder on your items?
What are your items, anyway?

When I hear "sorted", I think of a partial order and if you have a partial
order, then sorted implies that duplicates are consecutive! Anyway, I don't
want to bore you with elementary concepts of order theory. There are ways
to handle preorders, partial orders and every stronger notion of order,
of course, from within Gambas. You simply have to ask a better question,
by giving more details.

If you have a sorting where duplicates are consecutive, the solution is
very easy: just go through the array linearly and kick out these consecutive
duplicates (which is precisely what uniq does), e.g. for integers:

  Dim aInts As Integer[] = ...
  Dim iInd, iLast As Integer

  If Not aInts.Count Then Return
  iLast = aInts[0]
  iInd = 1
  While iInd < aInts.Count
If aInts[iInd] = iLast Then ' consecutive duplicate
  aInts.Remove(iInd, 1)
Else
  iLast = aInts[iInd]
  Inc iInd
Endif
  Wend

Note that the way I wrote it to get the idea across is not a linear-time
operation (it depends on the complexity of aInts.Remove()), but you can
achieve linear performance by writing better code. Think of it as an
exercise. (Of course, you can't hope to be more efficient than linear
time in a general situation.)

The counting task is solved with a similar pattern, but while you kick
an element out, you also increment a dedicated counter:

  Dim aInts As Integer[] = ...
  Dim aDups As New Integer[]
  Dim iInd, iLast As Integer

  If Not aInts.Count Then Return
  iLast = aInts[0]
  iInd = 1
  aDups.Add(0)
  While iInd < aInts.Count
If aInts[iInd] = iLast Then ' consecutive duplicate
  aInts.Remove(iInd, 1)
  Inc aDups[aDups.Max]
Else
  iLast = aInts[iInd]
  aDups.Add(0)
  Inc iInd
Endif
  Wend

After this executed, the array aInts will not contain duplicates (supposing
it was sorted before) and aDups[i] will contain the number of duplicates of
the item aInts[i] that were removed.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Hans Lehmann

Hello,

look here:

8<-
Public Function RemoveMultiple(aStringListe As String[]) As String[]
  Dim iCount As Integer
  Dim iIndex As Integer
  Dim sElement As String

  iIndex = 0 ' Initialisierung NICHT notwendig
  While iIndex < aStringListe.Count
iCount = 0
sElement = aStringListe[iIndex]
While aStringListe.Find(sElement) <> -1
  Inc iCount
  aStringListe.Remove(aStringListe.Find(sElement))
Wend
If iCount Mod 2 = 1 Then
   aStringListe.Add(sElement, iIndex)
   Inc iIndex
Endif ' iCount Mod 2 = 1 ?
  Wend

  Return aStringListe

End ' RemoveMultiple(...)
8<-

Hans
gambas-buch.de

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Fernando Cabral
Hi

I have a sorted array that may contain several repeated items scattered all
over.

I have to do two different things at different times:
a) Eliminate the duplicates leaving a single specimen from each repeated
item;
b) Eliminate the duplicates but having a count of the original number.

So, if I have, say

A
B
B
C
D
D

In the first option, I want to have
A
B
C
D
In the second option, I want to have
1 A
2 B
1 C
2 D

Any hints on how to do this using some Gambas buit in method?

Note; Presently I have been doing it using external calls to
the utilities sort and uniq.

Regards

- fernando


-- 
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: fernandojosecab...@gmail.com
Facebook: f...@fcabral.com.br
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Playing ".swf" files- can play OK in browser but will not open with webviewer in gambas on one PC but works OK on another!

2017-06-27 Thread Phil D
Hi Piccoro,


Many thanks for the speedy reply.


The project currently uses the following components:


gb

gb.form

gb.image

gb.net

gb.qt4

gb.qt4.ext

gb.qt4.ext

gb.qt4.webkit

gb.vb


Regards,

Phil


From: PICCORO McKAY Lenz 
Sent: 26 June 2017 17:24
To: mailing list for gambas users
Subject: Re: [Gambas-user] Playing ".swf" files- can play OK in browser but 
will not open with webviewer in gambas on one PC but works OK on another!

the capability of playing flash relies on the webkit interface of gui so
seems the loading of the swf can be overlaping by the html5 implementation
if you are using qt4 vs qt5 ..

so gambas list will be need more information of your system like version of
qt and what qt version (4 or 5) are using the interface and also if the
webkit are in use

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com
[http://www4.clustrmaps.com/counter/index2.php?url=http://qgqlochekone.blogspot.com]

McKAY brothers, multimedia emulation and 
support
qgqlochekone.blogspot.com
This documentation has two parts, and overall ODBC documentation and a specific 
Devuan ODBC documentation. The firs part are provided due most administrators 
and ...



2017-06-26 12:23 GMT-04:00 Phil D :

> Hi!
>
>
> Im making a user interface, and have a flash animation in part of it.
>
>
> I am developing the code on 2 computers: one is a slimmed down PC which
> will run the interface in the end, this is running linux mint 18. The other<
> http://aka.ms/weboutlook> other is a windows PC running Gambas OS2 under
[http://www.microsoft.com/en-us/outlook-com/img/Outlook_Facebook_Icon-2927f4df28.jpg]

Check out Outlook.com – free, personal email from 
Microsoft.
aka.ms
Take your email anywhere you go when you add your free, personal, Outlook.com 
webmail to your Android, iPhone, or Windows mobile devices. Send and receive 
messages with mobile mail from Outlook.com


> oracle VM virtualbox. (Both running Gambas 3.7.1)
>
>
> I have the gambas code working nicely on the windows computer, and the swf
> animation file loads into the webviewer and plays without problems. On the
> other computer however the code runs without error, but the animation does
> not show. The computer will open swf files fine, but it seems like gambas
> is not able to open it.
>
>
> Is there some way to tell gambas how to open these files, some way of
> fixing an association?
>
>
> (My linux skills are a little limited so please dont spare the detail!)
>
>
> Many thanks,
>
> Phil
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
Gambas-user Info Page - 
SourceForge
lists.sourceforge.net
To see the collection of prior postings to the list, visit the Gambas-user 
Archives. Using Gambas-user: To post a message to all the list members ...


>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user
Gambas-user Info Page - 
SourceForge
lists.sourceforge.net
To see the collection of prior postings to the list, visit the Gambas-user 
Archives. Using Gambas-user: To post a message to all the list members ...


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user