Update of /cvsroot/win32forth/win32forth/apps/Player4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32047/apps/Player4
Modified Files:
Catalog.f PLAYER4.F
Log Message:
Jos: The catalog can now be exported to a CSV file (player4.csv). Note: the TAB is the separator.
Index: PLAYER4.F
===================================================================
RCS file: /cvsroot/win32forth/win32forth/apps/Player4/PLAYER4.F,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** PLAYER4.F 15 Jan 2006 09:30:14 -0000 1.35
--- PLAYER4.F 21 Jan 2006 18:23:54 -0000 1.36
***************
*** 84,87 ****
--- 84,88 ----
MENUITEM "&Add file(s)...\tCtrl+M" 'M' +k_control pushkey ;
MENUITEM "&Import directory tree...\tCtrl+I" 'I' +k_control pushkey ;
+ MENUITEM "&Export the catalog to Player.csv" csv-catalog ;
MENUITEM "S&earch and make a collection..." SearchCatalog ;
MENUSEPARATOR
Index: Catalog.f
===================================================================
RCS file: /cvsroot/win32forth/win32forth/apps/Player4/Catalog.f,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** Catalog.f 31 Dec 2005 20:48:13 -0000 1.23
--- Catalog.f 21 Jan 2006 18:23:54 -0000 1.24
***************
*** 342,353 ****
;
-
- : record-not-played ( n - ) n>record 0 swap RecordDef Played- c! ;
- : set-all-not-played ( - ) for-all-records record-not-played ;
-
: list-record ( n - ) n>record _list-record ;
: list-records ( - ) for-all-records list-record cr ;
: list-database ( - ) map-database list-records unmap-database ;
: change-randomlevel ( level n - )
n>record over random swap RecordDef RandomLevel !
--- 342,395 ----
;
: list-record ( n - ) n>record _list-record ;
: list-records ( - ) for-all-records list-record cr ;
: list-database ( - ) map-database list-records unmap-database ;
+ K_TAB variable separator separator c!
+ 0 value fid
+
+ : +inlineRecord ( adr cnt - ) InlineRecord +place ;
+ : type-separator ( adr cnt - ) +inlineRecord separator 1 +inlineRecord ;
+ : .csv ( n - adr cnt ) s>d (d.) ;
+ : fwrite ( adr cnt - ) fid write-line abort" Can't write to file" ;
+
+ : _csv-record ( n - )
+ dup >record
+ dup>r not-deleted?
+ if .csv type-separator
+ r@ RecordDef DriveType c@ .csv type-separator
+ r@ RecordDef MediaLabel r@ RecordDef Cnt_MediaLabel c@ type-separator
+ r@ RecordDef Artist r@ Cnt_Artist c@ type-separator
+ r@ RecordDef Album r@ Cnt_Album c@ type-separator
+ r@ RecordDef Title r@ Cnt_Title c@ type-separator
+ r@ RecordDef #played @ .csv type-separator
+ r@ RecordDef FileSize @ .csv +inlineRecord
+ InlineRecord count fwrite
+ else drop
+ then
+ r>drop
+ ;
+
+ : csv-record ( n - ) InlineRecord off _csv-record ;
+
+ : csv-catalog ( - )
+ wait-cursor
+ s" Player4.csv" r/w create-file abort" Can't create file" to fid
+
+ InlineRecord off
+ s" Id" type-separator s" Drivetype" type-separator
+ s" Label" type-separator s" Artist" type-separator
+ s" Album " type-separator s" Title" type-separator
+ s" #played" type-separator s" Size" +inlineRecord
+ InlineRecord count fwrite
+
+ for-all-records csv-record
+ fid close-file abort" close error"
+ arrow-cursor
+ ;
+
+ : record-not-played ( n - ) n>record 0 swap RecordDef Played- c! ;
+ : set-all-not-played ( - ) for-all-records record-not-played ;
+
: change-randomlevel ( level n - )
n>record over random swap RecordDef RandomLevel !
|