Re: new people, new problems
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Jan 27, 2004
- 451 views
----- Original Message ----- From: "Guest" <guest at RapidEuphoria.com> To: <EUforum at topica.com> Subject: new people, new problems > > > posted by: (not specified) > > Here is a new Euphoriac :o) > > Perhaps somebody knows how to: > > 1. sort by Date a column of a ListView There are at least two ways. The first is the easiest but may not suit your users. The trick is to store the date in the column in the format "YYYY/MM/DD", thus the 27th of January, 2004 would appear as "2004/01/27". If you must store the date in a different format, then you need to implement a custom sort for it. This is done by creating a function to compare two rows and return -1, 0, or 1 to indicate if the first row is less than, equal to, or greater than respectively. You also need to tell win32lib about this function. function mySortitems( integer id, integer lItem1, integer lItem2, integer column ) sequence text1, text2 integer num1, num2 text1 = getLVItemText(id, lItem1, column) text2 = getLVItemText(id, lItem2, column) num1 = myGetYear(text1) num2 = myGetYear(text2) if num1 < num2 then return -1 elsif num1 > num2 then return 1 end if num1 = myGetMonth(text1) num2 = myGetMonth(text2) if num1 < num2 then return -1 elsif num1 > num2 then return 1 end if num1 = myGetDay(text1) num2 = myGetDay(text2) if num1 < num2 then return -1 elsif num1 > num2 then return 1 end if return 0 end function object oldvalues -- In this example, the third and fifth column has dates in it. -- The '-2' values just mean that these columns use the inbuilt sort routine. oldvalues = setLVAttr( myLV, {{kLVSortRtn, {-2,-2,routine_id("mySortitems"),-2,routine_id("mySortitems")}}}) Note, this assumes you have your own functions (myGetYear() etc...) to extract the year, month and day values out of a text (formatted) date string. > 2. add items to the pop menu of an EditText area (add to the existing > [Cut,Copy,Paste, etc.], not create a new pop menu) This menu is built into Windows and not win32lib, so playing with it will require lots of trickery somewhere. It may be easier to trap the right mousebutton and invoke your own popup menu instead. > 3. I met a problem with the db_open(), that is: > after having performed a Win32lib getOpenFileName(), db_open() doesn't work > anymore. It becomes impossible to open any File.EDB, which before that > instruction was opened, read, written and then closed. > Is there any medicine for? If you are opening a .EDB file using open(), you must use the "rb" (read binary) method and you really should NEVER write to it. That would most likely break the internal structure of the database file. > Too many questions? No, just too little time-- Derek