home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / APP / TASKBAR / JAYGRPII / SIC / SORTGRP.SIC < prev   
Encoding:
Text File  |  2000-08-14  |  954 b   |  44 lines

  1. // sortgrp.sic (c) 09.08.2000 by JAY Software
  2. //
  3. // This script sorts the group taken as a script argument or chosen
  4. // with FileSelector by title and sets the AutoSave flag off to let
  5. // you choose whether to save the result or not.
  6.  
  7.  
  8. uses "sort.lib";
  9.  
  10. proc main(...)
  11. {
  12.     if ( address( "JAYGrpII" ) ) {
  13.         if ( argc < 1 ) {
  14.             if ( ! fsel( FileName, "Choose a .GRP file...", "*.grp" ) ) exit(1);
  15.         } else    FileName = argv[0];
  16.  
  17.         if ( ! Load( FileName ) ) exit(1);
  18.  
  19.         gi = GroupInfo();    // Switch the AutoSave off
  20.         gi[ 2 ] = 0;
  21.         GroupInfo( gi );
  22.  
  23.         if ( First() ) do {    // Get all entries
  24.             SortArray[ i++ ] = Item();
  25.         } while ( Next() );
  26.     
  27.         cmpIdx = 1;        // Sort by Title
  28.         qsort_array(SortArray, CompareItems);
  29.     
  30.         Delete( "*" );        // Fill the .GRP again
  31.         while( i-- ) {
  32.             add( SortArray[ i ] );
  33.         }
  34.         Update();
  35.         Open();
  36.     }
  37. }
  38.  
  39.  
  40. proc CompareItems(i1, i2)
  41. {
  42.     return stricmp( i2[ cmpIdx ], i1[ cmpIdx ] );
  43. }
  44.