home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscShell / MiscShell.subproj / DBTableView-StringValue.m next >
Encoding:
Text File  |  1995-04-12  |  1.3 KB  |  49 lines

  1. // Copyright (C) 1995 Steve Hayman
  2. // Use is governed by the MiscKit license
  3.  
  4. #import <dbkit/dbkit.h>
  5. #import <misckit/misckit.h>
  6.  
  7. @implementation DBTableView( StringValue )
  8.  
  9. /*
  10.  * I want my MiscShell objects to be able to get StringValues out of
  11.  * a DBTableView (which doesn't support a stringValue: method) so I
  12.  * added this category, which asks the tableview's data source
  13.  * for the value of various objects, and concats them all together.
  14.  *
  15.  * I hereby declare that the stringValue of a table view is
  16.  * all the selected rows, with columns separated by tabs and
  17.  * rows separated by newlines.
  18.  * Steve Hayman
  19.  * Sep 26 1994
  20.  */
  21.  
  22. - (const char *)stringValue
  23. {
  24.     DBValue *v = [[DBValue alloc] init];
  25.     MiscString *str = [[MiscString alloc] init];
  26.     unsigned int i;
  27.     DBTableVector *aColumn;
  28.     
  29.     unsigned int aRow = DB_NoIndex;
  30.     
  31.     while ( (aRow = [self selectedRowAfter:aRow]) != DB_NoIndex ) {
  32.     for ( i = 0; i < [self columnCount]; i++ ) {
  33.         aColumn = [[self columnList] objectAt:i];
  34.         [ [self dataSource] 
  35.         getValueFor: [aColumn identifier]
  36.         at:aRow
  37.         into: v];
  38.         [str catFromFormat:"%s%s", [v stringValue],
  39.             (i == [self columnCount] - 1) ? "" : "\t"];
  40.     }
  41.     [str cat:"\n"];
  42.     }
  43.     [v free];
  44.     return [str stringValueAndFree];
  45. }
  46. @end  
  47.     
  48.     
  49.