It is currently Fri May 24, 2013 9:51 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 429 posts ]  Go to page Previous  1 ... 22, 23, 24, 25, 26, 27, 28, 29  Next
Author Message
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Dec 03, 2010 7:41 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon May 29, 2006 11:29 am
Posts: 238
Location: BARCELONA - SPAIN
:D Thanks a lot Gnozal!

_________________
QuimV


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Thu Jun 09, 2011 7:06 am 
Offline
User
User

Joined: Tue Jul 03, 2007 3:48 am
Posts: 38
Location: Philippines
thank you very much for this gnozal. you rock!

_________________
PureBasic 4.51(x86) on WinXP SP3


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 2:55 am 
Offline
User
User

Joined: Tue Jul 03, 2007 3:48 am
Posts: 38
Location: Philippines
hello gnozal, i really find this lib extremely useful. however, i got stuck in a bit of a problem.
you see, one of my column is in currency format (i.e. $2,342.50, $549.00, etc) and currently purelvsort couldn't sort them using the existing templates
could you add another template pattern like "#PureLVSORT_Currency" which basically ignores all characters that are not "numeric" and "." and then sort them as floats?

_________________
PureBasic 4.51(x86) on WinXP SP3


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 7:11 am 
Offline
Addict
Addict
User avatar

Joined: Thu Feb 09, 2006 11:27 pm
Posts: 1716
Not sure, if implementing such things would slow down sorting (maybe someone needs rational numbers etc.)...
...I would think about adding a hidden column containing the unretouched values -- this column could be sorted easily 8)


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 7:22 am 
Offline
User
User

Joined: Tue Jul 03, 2007 3:48 am
Posts: 38
Location: Philippines
Michael Vogel wrote:
Not sure, if implementing such things would slow down sorting (maybe someone needs rational numbers etc.)...
...I would think about adding a hidden column containing the unretouched values -- this column could be sorted easily 8)

i have considered this method but the problem is how to click the column header if the column i want to sort is hidden.
then i tried using PureLVSORT_DefineUserCallback but i encountered another roadblock because i couldn't make it work with predefined procedures.
id be grateful, if you could provide a simple working example how to do this.

_________________
PureBasic 4.51(x86) on WinXP SP3


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 7:56 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
liam wrote:
then i tried using PureLVSORT_DefineUserCallback but i encountered another roadblock because i couldn't make it work with predefined procedures.
id be grateful, if you could provide a simple working example how to do this.
The user callback is quite easy to use.
Here is a basic example : column 0 uses a custom callback.
Code:
;/ USER CALLBACK
Procedure.l MySortingCallback(ListIconNumber.l, ListIconColumn.l, Item1.s, Item2.s)
  Protected ReturnValue.l
  Debug Str(ListIconNumber) + ":" + Str(ListIconColumn) + "->" + Item1 + ":" + Item2
  ;
  ; Compare Item1 And Item2 ..
  ; Return  1 If Item1 > Item2
  ; Return -1 If Item1 < Item2
  ; Return  0 If Item1 = Item2
  ;
  If Item1 > Item2
    ReturnValue = 1
  ElseIf Item1 < Item2
    ReturnValue = -1
  Else
    ReturnValue = 0
  EndIf
  ProcedureReturn ReturnValue
EndProcedure
;/ Example
#Window_0 = 0
#ListIcon_0 = 0
Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT User Callback",   #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
    ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "UserCallback", 110)
    AddGadgetColumn(#ListIcon_0, 1, "DateDDMMYYYYHHMMSS", 130)
    AddGadgetColumn(#ListIcon_0, 2, "DateDDMMYYHHMM", 130)
    AddGadgetColumn(#ListIcon_0, 3, "DateDDMMYYYY", 120)
    AddGadgetColumn(#ListIcon_0, 4, "DateMMDDYYYY", 120)
    AddGadgetColumn(#ListIcon_0, 5, "FileSize", 120)
    AddGadgetColumn(#ListIcon_0, 6, "UserCallback", 120)
    AddGadgetItem(#ListIcon_0, -1, "aseza" + Chr(10) + "12/05/2001 06:41:30" + Chr(10) + "19/07/66 06:41" + Chr(10) + "31/12/2004" + Chr(10) + "12/31/2004" + Chr(10) + "15.02 MB" + Chr(10) + "0")
    AddGadgetItem(#ListIcon_0, -1, "zssdd" + Chr(10) + "05/07/2004 09:21:30" + Chr(10) + "12/05/01 07:50" + Chr(10) + "11/12/2004" + Chr(10) + "12/11/2004"   + Chr(10) + "65 B" + Chr(10) + "1")
    AddGadgetItem(#ListIcon_0, -1, "aeeed" + Chr(10) + "19/11/2003 07:18:31" + Chr(10) + "13/08/03 06:41" + Chr(10) + "21/01/2003" + Chr(10) + "01/21/2003" + Chr(10) + "5.98 GB" + Chr(10) + "3")
    AddGadgetItem(#ListIcon_0, -1, "udsdd" + Chr(10) + "19/11/2003 06:21:30" + Chr(10) + "12/05/01 06:41" + Chr(10) + "10/06/2001" + Chr(10) + "06/10/2001" + Chr(10) + "100 KB" + Chr(10) + "A")
    AddGadgetItem(#ListIcon_0, -1, "cdgdd" + Chr(10) + "19/11/2003 16:21:30" + Chr(10) + "12/05/01 06:41" + Chr(10) + "10/08/2001" + Chr(10) + "16/11/2001" + Chr(10) + "800 KB" + Chr(10) + "9")
    AddGadgetItem(#ListIcon_0, -1, "adsdg" + Chr(10) + "19/11/2003 06:21:31" + Chr(10) + "12/05/01 06:41" + Chr(10) + "10/06/2004" + Chr(10) + "06/10/2004" + Chr(10) + "101 KB" + Chr(10) + "z")
    AddGadgetItem(#ListIcon_0, -1, "azsdd" + Chr(10) + "19/11/2003 06:21:30" + Chr(10) + "12/05/01 06:41" + Chr(10) + "10/04/2001" + Chr(10) + "07/08/2004" + Chr(10) + "1000 B" + Chr(10) + "A")
  EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
  PureLVSORT_DefineUserCallback(@MySortingCallback())
  PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_UserCallback)
  PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_DateDDMMYYYYHHMMSS)
  PureLVSORT_SetColumnType(#ListIcon_0, 2, #PureLVSORT_DateDDMMYYHHMM)
  PureLVSORT_SetColumnType(#ListIcon_0, 3, #PureLVSORT_DateDDMMYYYY)
  PureLVSORT_SetColumnType(#ListIcon_0, 4, #PureLVSORT_DateMMDDYYYY)
  PureLVSORT_SetColumnType(#ListIcon_0, 5, #PureLVSORT_FileSize)
  PureLVSORT_SetColumnType(#ListIcon_0, 6, #PureLVSORT_UserCallback)
  PureLVSORT_SortListIconNow(#ListIcon_0, 1, -1)
EndIf
;
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 8:21 am 
Offline
User
User

Joined: Tue Jul 03, 2007 3:48 am
Posts: 38
Location: Philippines
thank you for the prompt reply gnozal but im still confused how to use call backs to sort the list according to another (hidden) column.

lets say i have this listicon data below. how do i sort the rows according to the 2nd column by clicking the 1st column header? im still learning PB programming so please bear with me :|
Code:
;/ USER CALLBACK
Procedure.l MySortingCallback(ListIconNumber.l, ListIconColumn.l, Item1.s, Item2.s)
  Protected ReturnValue.l
  Debug Str(ListIconNumber) + ":" + Str(ListIconColumn) + "->" + Item1 + ":" + Item2
  ;
  ; Compare Item1 And Item2 ..
  ; Return  1 If Item1 > Item2
  ; Return -1 If Item1 < Item2
  ; Return  0 If Item1 = Item2
  ;
  If Item1 > Item2
    ReturnValue = 1
  ElseIf Item1 < Item2
    ReturnValue = -1
  Else
    ReturnValue = 0
  EndIf
  ProcedureReturn ReturnValue
EndProcedure
;/ Example
#Window_0 = 0
#ListIcon_0 = 0
Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT User Callback",   #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
    ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "UserCallback", 110)
    AddGadgetColumn(#ListIcon_0, 1, "UserCallback", 120)
    AddGadgetItem(#ListIcon_0, -1, "$36.00" + Chr(10) + "36.00")
    AddGadgetItem(#ListIcon_0, -1, "$324.00" + Chr(10) + "324.00")
    AddGadgetItem(#ListIcon_0, -1, "$324,432.45" + Chr(10) + "324,432.45")
    AddGadgetItem(#ListIcon_0, -1, "$2,561.45" + Chr(10) + "2561.45")
  EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
  PureLVSORT_DefineUserCallback(@MySortingCallback())
  PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_UserCallback)
  PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_NoSorting)
EndIf
;
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End

_________________
PureBasic 4.51(x86) on WinXP SP3


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 8:48 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
liam wrote:
lets say i have this listicon data below. how do i sort the rows according to the 2nd column by clicking the 1st column header? im still learning PB programming so please bear with me :|
With PureLVSORT, the sorting is done according to the column you clicked on.
I don't understand why you need a hidden column.
See the example below. When you click on the 1st column, the data is sorted correctly, because the data is converted in the user callback.
Code:
;/ USER CALLBACK
Procedure.l MySortingCallback(ListIconNumber.l, ListIconColumn.l, Item1.s, Item2.s)
  Protected ReturnValue.l
  Protected Item1D.d, Item2D.d
  ;
  ; Quick and dirty transforming Currency to DOUBLE
  Item1 = RemoveString(Item1, "$")
  Item1 = RemoveString(Item1, ",")
  Item1D = ValD(Item1)
  Item2 = RemoveString(Item2, "$")
  Item2 = RemoveString(Item2, ",")
  Item2D = ValD(Item2)
  ;
  If Item1D > Item2D
    ReturnValue = 1
  ElseIf Item1D < Item2D
    ReturnValue = -1
  Else
    ReturnValue = 0
  EndIf
  ProcedureReturn ReturnValue
EndProcedure
;/ Example
#Window_0 = 0
#ListIcon_0 = 0
Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT User Callback",   #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
    ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "UserCallback", 110)
    AddGadgetColumn(#ListIcon_0, 1, "No sorting", 120)
    AddGadgetItem(#ListIcon_0, -1, "$36.00" + Chr(10) + "36.00")
    AddGadgetItem(#ListIcon_0, -1, "$324.00" + Chr(10) + "324.00")
    AddGadgetItem(#ListIcon_0, -1, "$324,432.45" + Chr(10) + "324,432.45")
    AddGadgetItem(#ListIcon_0, -1, "$2,561.45" + Chr(10) + "2561.45")
  EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
  PureLVSORT_DefineUserCallback(@MySortingCallback())
  PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_UserCallback)
  PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_NoSorting)
EndIf
;
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 9:02 am 
Offline
User
User

Joined: Tue Jul 03, 2007 3:48 am
Posts: 38
Location: Philippines
gnozal wrote:
liam wrote:
lets say i have this listicon data below. how do i sort the rows according to the 2nd column by clicking the 1st column header? im still learning PB programming so please bear with me :|
With PureLVSORT, the sorting is done according to the column you clicked on.
I don't understand why you need a hidden column.

if you'll backtrack a few posts, my initial problem is about sorting a column with numeric values in 'currency' formatting i.e. "$36.00", "$324.00", "$324,432.45", "$2,561.45" and so on. i couldnt use #PureLVSORT_Numeric, #PureLVSORT_Numeric_Quad, #PureLVSORT_Float on that column because it doesn't work due to the extra characters "$" and "," hence i requested that you also include a sorting template like #PureLVSORT_Currency which ignores all non-numeric characters and sorts it like a float.
michael vogel suggested that i use a 'hidden' column containing the unformatted values which could be sorted easily, this is where the issue of using usercallbacks came in. im not sure though how to implement usercallbacks to address my problem.
so if you could implement #PureLVSORT_Currency format, it could save a lot of people like me a lot of hair :D

_________________
PureBasic 4.51(x86) on WinXP SP3


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 9:19 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
liam wrote:
...im not sure though how to implement usercallbacks to address my problem.
so if you could implement #PureLVSORT_Currency format, it could save a lot of people like me a lot of hair :D
Did you try the code I posted ? It shows how to sort a column by transforming a format ('currency') to another (double float).

I did not implement a currency format because it does not exist in Purebasic. This is a case where one should use the user callback feature.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 9:32 am 
Offline
User
User

Joined: Tue Jul 03, 2007 3:48 am
Posts: 38
Location: Philippines
Quote:
Did you try the code I posted ? It shows how to sort a column by transforming a format ('currency') to another (double float).


i tried the code you posted, actually its identical to the sample code in PureLVSORT lib's documentation. all i see are strings, dates, filesizes but no currency-to-float conversions. i even posted a reply with your sample code and my sample currency data but it didn't work.

_________________
PureBasic 4.51(x86) on WinXP SP3


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 9:39 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
liam wrote:
i tried the code you posted, actually its identical to the sample code in PureLVSORT lib's documentation. all i see are strings, dates, filesizes but no currency-to-float conversions. i even posted a reply with your sample code and my sample currency data but it didn't work.
I mean this code I posted not one hour ago :
Code:
;/ USER CALLBACK
Procedure.l MySortingCallback(ListIconNumber.l, ListIconColumn.l, Item1.s, Item2.s)
  Protected ReturnValue.l
  Protected Item1D.d, Item2D.d
  ;
  ; Quick and dirty transforming Currency to DOUBLE
  Item1 = RemoveString(Item1, "$")
  Item1 = RemoveString(Item1, ",")
  Item1D = ValD(Item1)
  Item2 = RemoveString(Item2, "$")
  Item2 = RemoveString(Item2, ",")
  Item2D = ValD(Item2)
  ;
  If Item1D > Item2D
    ReturnValue = 1
  ElseIf Item1D < Item2D
    ReturnValue = -1
  Else
    ReturnValue = 0
  EndIf
  ProcedureReturn ReturnValue
EndProcedure
;/ Example
#Window_0 = 0
#ListIcon_0 = 0
Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 602, 302, "PureLVSORT User Callback",   #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
    ListIconGadget(#ListIcon_0, 5, 5, 590, 285, "UserCallback", 110)
    AddGadgetColumn(#ListIcon_0, 1, "No sorting", 120)
    AddGadgetItem(#ListIcon_0, -1, "$36.00" + Chr(10) + "36.00")
    AddGadgetItem(#ListIcon_0, -1, "$324.00" + Chr(10) + "324.00")
    AddGadgetItem(#ListIcon_0, -1, "$324,432.45" + Chr(10) + "324,432.45")
    AddGadgetItem(#ListIcon_0, -1, "$2,561.45" + Chr(10) + "2561.45")
  EndIf
EndProcedure
Open_Window_0()
; ListIcon Sort Setup
If PureLVSORT_SelectGadgetToSort(#ListIcon_0, #PureLVSORT_ShowClickedHeader_IconLeft) = #PureLVSORT_Ok
  PureLVSORT_DefineUserCallback(@MySortingCallback())
  PureLVSORT_SetColumnType(#ListIcon_0, 0, #PureLVSORT_UserCallback)
  PureLVSORT_SetColumnType(#ListIcon_0, 1, #PureLVSORT_NoSorting)
EndIf
;
Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
It's obviously not identical to the sample code in PureLVSORT lib's documentation.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Fri Jul 08, 2011 9:46 am 
Offline
User
User

Joined: Tue Jul 03, 2007 3:48 am
Posts: 38
Location: Philippines
ok now i see it! damn.. i think i need some sleep, i wont even recognize a cobra in front of my face.
i just tried it and its working! thanks. im gonna dissect and digest this one after some rest. thank you once again!

_________________
PureBasic 4.51(x86) on WinXP SP3


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Mon Sep 12, 2011 1:30 pm 
Offline
User
User

Joined: Sat Sep 02, 2006 7:56 pm
Posts: 14
Location: Oostzaan / Netherlands
Hi Gnozal,
I've tried to run one of your example programs PureLVSORT_TEST_2.pb and I get a Polink error "Unresolved external symbol '_PB_Findstring2.'
Tried it on XPsp3 and Windows 7. It seems to happen on the line "PureLVSORT_SelectGadgetToSort()". I dont get this error if I comment this line out.

Thanks,
Roel.

Oh, I use the latest jaPBe, PURELVSORT and PureBasic 4.51


Top
 Profile  
 
 Post subject: Re: PureLVSORT library : sorting ListIconGadgets (and more)
PostPosted: Tue Sep 13, 2011 7:45 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4231
Location: Strasbourg / France
rule wrote:
I've tried to run one of your example programs PureLVSORT_TEST_2.pb and I get a Polink error "Unresolved external symbol '_PB_Findstring2.'
It looks like your are using the wrong library version.
With PB4.51, you should be using PureLVSORT_450.zip.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 429 posts ]  Go to page Previous  1 ... 22, 23, 24, 25, 26, 27, 28, 29  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye