home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / editors / epm / e_macros / sortepm.e < prev    next >
Encoding:
Text File  |  1993-09-01  |  1.8 KB  |  49 lines

  1. compile if EVERSION < '5.60'
  2.  Error:  SORTEPM.E (SORT_TYPE = 'EPM') can only be used with EPM 5.60 or above.
  3. compile endif
  4.  
  5. defproc sort(firstline, lastline, firstcol, lastcol, fileid)
  6.    Revers=not verify('R',upcase(arg(6))) + 2*(not verify('I',upcase(arg(6)))) + 4*(not verify('C',upcase(arg(6))))
  7. compile if EPM32
  8.    return dynalink32(E_DLL, 'EtkSort',
  9.                      gethwndc(5)     || atol(fileid)   ||
  10.                      atol(firstline) || atol(lastline) ||
  11.                      atol(firstcol)  || atol(lastcol)  ||
  12.                      atol(Revers),
  13.                      2)
  14. compile else
  15.    return dynalinkc( E_DLL, '_EtkSort',      /* function name                 */
  16.                      gethwndc(5)     || atol(fileid)   ||
  17.                      atol(firstline) || atol(lastline) ||
  18.                      atoi(firstcol)  || atoi(lastcol)  ||
  19.                      atol(Revers),
  20.                      2);
  21. compile endif
  22.  
  23. defc sort =
  24.    if browse() then
  25.       sayerror BROWSE_IS__MSG ON__MSG
  26.       return
  27.    endif
  28.    TypeMark=marktype()
  29.    if TypeMark='' then  /* if no mark, default to entire file */
  30.       getfileid fileid
  31.       firstline=1 ; lastline=.last ; firstcol=1; lastcol = 40
  32.    else
  33.       getmark firstline, lastline, firstcol, lastcol, fileid
  34.       /* If it was a line mark, the LastCol value can be 255.  Can't */
  35.       /* imagine anyone needing a key longer than 40.                */
  36.       if TypeMark='LINE' then lastcol=40 endif
  37.    endif
  38.  
  39.    sayerror SORTING__MSG lastline-firstline+1 LINES__MSG'...'
  40.  
  41.    /* Pass the sort switches "rc", if any, as a sixth argument to sort().    */
  42.    result = sort(firstline, lastline, firstcol, lastcol, fileid, arg(1) )
  43.    if result then
  44.       sayerror 'SORT' ERROR_NUMBER__MSG result
  45.    else
  46.       sayerror 0
  47.    endif
  48.  
  49.