home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / advbas.zip / MONKEY.BAS < prev    next >
BASIC Source File  |  1987-12-13  |  4KB  |  131 lines

  1.    defint a-z
  2.    def fnf$(x)=right$("0"+mid$(str$(x),2),2)
  3.  
  4.    seekattr=23   ' seek read-only, normal, hidden, system, and directory files
  5.  
  6.    cmd$=command$
  7.    if cmd$="" then goto BadMonkey
  8.  
  9.    i=instr(cmd$," ")
  10.    if i then fil$=left$(cmd$,i-1): cmd$=mid$(cmd$,i+1) _
  11.    else fil$=cmd$: goto DoIt
  12.  
  13.    i=instr(cmd$," ")
  14.    if i then parm1$=left$(cmd$,i-1): cmd$=mid$(cmd$,i+1) _
  15.    else parm1$=cmd$: goto DoIt
  16.  
  17.    i=instr(cmd$," ")
  18.    if i then parm2$=left$(cmd$,i-1): parm3$=mid$(cmd$,i+1) _
  19.    else parm2$=cmd$
  20.  
  21. DoIt:
  22.    if parm1$="" then goto Display
  23.    if instr(parm1$,"/") then p$=parm1$: gosub ExtractDate _
  24.    else if instr(parm1$,":") then p$=parm1$: gosub ExtractTime _
  25.    else p$=parm1$: gosub ExtractAttr
  26.  
  27.    if parm2$="" then goto Display
  28.    if instr(parm2$,"/") then p$=parm2$: gosub ExtractDate _
  29.    else if instr(parm2$,":") then p$=parm2$: gosub ExtractTime _
  30.    else p$=parm2$: gosub ExtractAttr
  31.  
  32.    if parm3$="" then goto Display
  33.    if instr(parm3$,"/") then p$=parm3$: gosub ExtractDate _
  34.    else if instr(parm3$,":") then p$=parm3$: gosub ExtractTime _
  35.    else p$=parm3$: gosub ExtractAttr
  36.  
  37. Display:
  38.    fil$=fil$+chr$(0)
  39.    call FindFirstF(fil$,seekattr,ercd)
  40.    if ercd then call UpCase(fil$): print "No such file as ";fil$: end
  41.    while ercd=0
  42.       gosub DisplayFile
  43.       call FindNextF(ercd)
  44.    wend
  45.    end
  46.  
  47. BadMonkey:
  48.    print "Disk Monkey v1.2      Public Domain 12/13/87    by Thomas Hanlin III"
  49.    print
  50.    print "Allows you to monkey with file date, time, and attributes."
  51.    print
  52.    print "Format: MONKEY filename.ext [date] [time] [attributes]"
  53.    print "Filename may include wildcards.  Date/time/attr may be in any order."
  54.    print "Attributes: N normal, H hidden, S system, D directory, R read-only, A archive."
  55.    end
  56.  
  57. ExtractTime:
  58.    i=instr(p$,":")
  59.    hour=val(p$)
  60.    p$=mid$(p$,i+1)
  61.    minute=val(p$)
  62.    i=instr(p$,":")
  63.    if i then second=val(mid$(p$,i+1))
  64.    stime=-1
  65.    return
  66.  
  67. ExtractDate:
  68.    i=instr(p$,"/")
  69.    month=val(p$)
  70.    p$=mid$(p$,i+1)
  71.    day=val(p$)
  72.    i=instr(p$,"/")
  73.    if i then year=val(mid$(p$,i+1)) else year=val(mid$(date$,7))
  74.    sdate=-1
  75.    return
  76.  
  77. ExtractAttr:
  78.    attr=0
  79.    call upcase(p$)
  80.    if instr(p$,"R") then attr=attr+1
  81.    if instr(p$,"H") then attr=attr+2
  82.    if instr(p$,"S") then attr=attr+4
  83.    if instr(p$,"D") then attr=attr+16
  84.    if instr(p$,"A") then attr=attr+32
  85.    sattr=-1
  86.    return
  87.  
  88. DisplayFile:
  89.    ky$=inkey$
  90.    if ky$=chr$(19) then while inkey$="": wend      '  handle CTRL-S for pause
  91.  
  92.    dname$=space$(12)
  93.    call GetNameF(dname$,dlen)
  94.    call GetTimeF(dhour,dmin,dsec)
  95.    call GetDateF(dmonth,dday,dyear)
  96.    call GetAttrF(dattr)
  97.  
  98.    print dname$;"   ";fnf$(dmonth);"/";fnf$(dday);"/";fnf$(dyear);"   ";
  99.    print fnf$(dhour);":";fnf$(dmin);":";fnf$(dsec);"   ";
  100.    pattr=dattr: gosub DisplayAttr
  101.  
  102.    if not (sdate or stime or sattr) then return
  103.  
  104.    dname$=left$(dname$,dlen)+chr$(0)
  105.    print "   ------>     ";
  106.  
  107.    if sdate and not stime then hour=dhour: minute=dmin: second=dsec
  108.    if stime and not sdate then day=dday: month=dmonth: year=dyear
  109.  
  110.    if sdate or stime then call setftd(dname$,month,day,year,hour,minute,second)
  111.    if sdate then print fnf$(month);"/";fnf$(day);"/";fnf$(year);"   ";_
  112.    else print space$(11);
  113.    if stime then print fnf$(hour);":";fnf$(minute);":";fnf$(second);"   ";_
  114.    else print space$(11);
  115.  
  116.    if not sattr then print: print: return
  117.    if sattr then call SetFattr(dname$,attr)
  118.    pattr=attr: gosub DisplayAttr
  119.    print
  120.    return
  121.  
  122. DisplayAttr:
  123.    if pattr=0 then print "N";
  124.    if pattr and 1 then print "R";
  125.    if pattr and 2 then print "H";
  126.    if pattr and 4 then print "S";
  127.    if pattr and 16 then print "D";
  128.    if pattr and 32 then print "A";
  129.    print
  130.    return
  131.