home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / SHOWDATE.E < prev    next >
Text File  |  1992-08-26  |  2KB  |  44 lines

  1. ; Routine to add a file's date to the title bar.
  2.  
  3. ; By Larry Margolis
  4.  
  5. defload
  6.    if leftstr(.filename,1)='.' then return; endif  -- EPM temp. file
  7.    filename = .filename\0
  8.    DirHandle = atoi(1)
  9.    attribute = atoi(0)  -- 0=normal; no subdirectories, hidden or system
  10.    resultbuf = copies(' ',255)
  11.    resultbuflen = atoi(255)
  12.    searchcount = atoi(1)
  13.    reserved = atol(0)
  14.  
  15.    rc = dynalink('DOSCALLS',               -- dynamic link library name
  16.                  '#64',                    -- ordinal value for DosFindFirst
  17.                  selector(filename)    ||  -- string selector
  18.                  offset(filename)      ||  -- string offset
  19.                  selector(DirHandle)   ||  -- string selector
  20.                  offset(DirHandle)     ||  -- string offset
  21.                  attribute             ||
  22.                  selector(resultbuf)   ||  -- string selector
  23.                  offset(resultbuf)     ||  -- string offset
  24.                  resultbuflen          ||
  25.                  selector(searchcount) ||  -- string selector
  26.                  offset(searchcount)   ||  -- string offset
  27.                  reserved )
  28.    if rc then
  29.       if rc=18 then -- RC 18 = no more files
  30.          .titletext = .filename '(new file)'
  31.       else
  32.          sayerror 'Error' rc 'from DosFindFirst.'
  33.       endif
  34.       return
  35.    endif
  36.    date = ltoa(substr(resultbuf,9,2)\0\0,10); time = ltoa(substr(resultbuf,11,2)\0\0,10)
  37.    year = date % 512; date = date // 512
  38.    month = date % 32; day = date // 32 % 1     -- %1 to drop fraction.
  39.    date = year+1980'/'rightstr(month,2,0)'/'rightstr(day,2,0)
  40.    hour = time % 2048; time = time // 2048
  41.    min = time % 32; sec = time // 32 * 2 % 1
  42.    time = hour':'rightstr(min,2,0)':'rightstr(sec,2,0)
  43.    .titletext = .filename '('date time')'
  44.