[Gambas-user] User Digest, Vol 35, Issue 50

John Rose john.aaron.rose at mailbox.org
Mon Aug 24 18:08:19 CEST 2020


On 24/08/2020 16:03, user-request at lists.gambas-basic.org wrote:
> Also you have this thing interesting  :
>
> Public MyValue as String Use $MyValue
>
>
> That replace your stuff
>
> Public MyValue as String
> Private $MyValue
>
> Public Sub MyValue_Read()
> Return $MyValue
> End
>
> Public Sub MyValue_Write(Value as String)
>    $MyValue = Value
> End
>
> the same in One only Line, But in the case of a bidimentionnal array
> I'm not sur it is so mandatory.
>
>
>
>
> Le lun. 24 août 2020 à 14:52, Gianluigi<bagonergi at gmail.com>  a écrit :
>>
>> Il giorno lun 24 ago 2020 alle ore 14:34 Fabien Bodard<gambas.fr at gmail.com>  ha scritto:
>>> Arf..
>>>
>>> make a class
>>>
>>> 'Class CEpisode
>>> Static Public SortMode As Integer
>>> Public Enum bySeriesName, byEpisodeName, byEpisodeNumber '... etc
>>>
>>> Public SeriesName As String
>>> Public EpisodeName As String
>>> Public EpisodeNumber As Integer
>>> Public EpisodeDescription As String
>>> Public EpisodeDatePublished As String
>>> Public EpisodeIdentifier As String
>>> Public SeriesDescription As String
>>>
>>> Public Sub _Compare(Other As CEpisode) As Integer
>>>
>>>    Select Case SortMode
>>>      Case bySerieName
>>>        Return Comp(Me.SeriesName, Other.SeriesName)
>>>      Case ByEpisodeName
>>>        Return Comp(Me.EpisodeName, Other.EpisodeName)
>>>      Case ByEpisodNumber
>>>        If Me.EpisodeNumber < Other.EpisodeNumber Then Return -1
>>>        If Me.EpisodeNumber < Other.EpisodeNumber Then Return 1
>>>        Return
>>>
>>>
>>>        'etc...
>>>
>>>    End Select
>>>
>>> End
>> Hi Fabien,
>>
>> it's true I should have used enumerators, but other than that my class is nicer:-P
>>
>> ;-D
>>
>> Ciao e viva il Cognac!
>> Gianluigi

Thanks Gianluigi & Fabien for your replies. I'm confused. I have the 
feeling (though I could be wrong as I found the code examples difficult 
to follow) that the code in the above solutions (and in the 
DynamicMatrix & ClassEUser apps) doesn't do what I want. As I said in my 
previous post, I found it quite difficult to explain what I want. So 
here is a simple example: 3 rows (the first one being for one series and 
the latter two being for different episodes of the same series) in 
string array aData with (string) values as follows:
[0,0]=Storyville                   -> SeriesName
[0,1]=Dolce Vita Africana    ->EpisodeName
[0,2]=1400
[0,3]=Documentary about celebrated Malian photographer Malick Sidibe.
[0,4]=2008-03-04
[0,5]=b00936cb
[0,6]=Series showcasing the best in international documentaries
[1,0]=EastEnders 2008        -> SeriesName
[1,1]=03/06/2008                -> EpisodeName
[1,2]=1439
[1,3]=Patrick vows to sort Chelsea out and Bradley worries when his boss 
crosses the line.
[1,4]=2008-06-03
[1,5]=b00bygpz
[1,6]=Welcome to Walford, E20, in 2008.
[2,0]=EastEnders 2008        -> SeriesName
[2,1]=02/06/2008                -> EpisodeName
[2,2]=1440
[2,3]=Chelsea discovers she is not as untouchable as she thinks.
[2,4]=2008-06-02
[2,5]=b00byf6t
[2,6]=Welcome to Walford, E20, in 2008.

I want the sort results to be:
[0,0]=EastEnders 2008        ->SeriesName
[0,1]=02/06/2008                ->EpisodeName
[0,2]=1440
[0,3]=Chelsea discovers she is not as untouchable as she thinks.
[0,4]=2008-06-02
[0,5]=b00byf6t
[0,6]=Welcome to Walford, E20, in 2008.
[1,0]=EastEnders 2008        ->SeriesName
[1,1]=03/06/2008                ->EpisodeName
[1,2]=1439
[1,3]=Patrick vows to sort Chelsea out and Bradley worries when his boss 
crosses the line.
[1,4]=2008-06-03
[1,5]=b00bygpz
[1,6]=Welcome to Walford, E20, in 2008.
[2,0]=Storyville                    ->SeriesName
[2,1]=Dolce Vita Africana    ->EpisodeName
[2,2]=1400
[2,3]=Documentary about celebrated Malian photographer Malick Sidibe.
[2,4]=2008-03-04
[2,5]=b00936cb
[2,6]=Series showcasing the best in international documentaries

You can see that the the /first/ and the /third /rows have been swapped 
/completely/ i.e. in ALL columns. The sort order is *column 1*//(i.e. 
/EpisodeName/ using the original array name) *within*//*column 0* (i.e. 
/Series Name/ using the original array name).


PS For reference here is my previous post:

I have 7 string arrays defined as follows:
Private aSeriesName As String[]
Private aEpisodeName As String[]
Private aEpisodeNumber As String[]
Private aEpisodeDescription As String[]
Private aEpisodeDatePublished As String[]
Private aEpisodeIdentifier As String[]
Private aSeriesDescription As String[]

Each array is populated in a loop from a similarly named string variable 
e.g. aSeriesName.Add(sSeriesName).

The ith element of each array are correspondent to each other (i.e. like 
a Relational Database row).

You could visualise the above (thus replacing the above arrays) as 
equivalent to a 2D array aData defined as 'Private[7, 1000] - I used 
1,000 as I couldn't work out how to have a dynamic 2D array where one 
'index' is fixed: can that be done?

Next problem with aData is there seems to be no Add method for a 2D 
array. Any ideas? Only idea that I've had is to specifically set an 
element of Data using a counter which is incremented by 1 for each 
element's value setting: something like aData[0, iCounter]=sSeriesName

I would like to sort aData using 2 of the 'fields' (SeriesName being 
major & EpisodeName being minor). I've noticed that there is a Sort 
method for a 1D array but not for a 2D array. Any ideas?

PS apologies if my explanation is not clear.

For reference, here is my previous post:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200824/eb287705/attachment.html>


More information about the User mailing list