home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Miscellaneous / CopyPaste 3.3.4 / CopyPaste Tools Sourcecode / Selection Sort.c / SelToText.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-16  |  1.0 KB  |  51 lines  |  [TEXT/KAHL]

  1. #include "ToolSort.h"
  2.  
  3. /*=========================================================================
  4. Module:        SelToText
  5.  
  6. Purpose:    Transform the structure SelLine to SelTxt (text).  
  7.  
  8. Returns:    txt, err
  9.  
  10. =========================================================================*/
  11.  
  12. SelToText( sortSel, txt )
  13.     SelLine    sortSel;    /* array of handles to sorted lines of text */
  14.     Text    *txt;        /* handle to lines in text format */
  15.     {
  16.     int        err = 0;
  17.     long        num;        /* number of lines */
  18.     int     l;            /* line number index */
  19.     
  20.     *txt = 0L;    
  21.     num = sortSel.noLines;
  22.     
  23.     if ( num > 0 )
  24.         {
  25.         *txt = NewHandle(0L);
  26.         
  27.         if (*txt != 0L)
  28.             {
  29.             for ( l=0; l<num && err == noErr; l++ )
  30.                 {
  31.                 HLock( sortSel.lines[l] );    /* HandAndHand dereference */
  32.                 err = HandAndHand( sortSel.lines[l],*txt);
  33.                 HUnlock( sortSel.lines[l] );    
  34.                 }
  35.             if ( err != noErr )
  36.                 {
  37.                 DisposHandle( *txt );
  38.                 *txt = NIL;                /* mark handle empty */
  39.                 err = Memory_Error;
  40.                 }
  41.             }
  42.         else
  43.             err = Nil_Hand_Error;
  44.  
  45.         }
  46.     else
  47.         err = Empty_Error;
  48.  
  49.     return ( err );
  50.     }
  51.