home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / totallyamos / issue4 / source_progs / diskute / diskutility.amos / diskutility.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1992-04-25  |  9.5 KB  |  425 lines

  1. 'This program was created by:   Kenneth Kowalewski 
  2. '                               5172 Westlake
  3. '                               Dearborn Heights, MI 48125 
  4. '                               U.S.A. 
  5. '
  6. ' Any contributions are accepted but not necessary, I would like to hear 
  7. ' about any comments or suggestions for this program. The coding is not
  8. ' very professional. This is my first AMOS program!
  9. '
  10. '  I am placing this program in the public domain as of August 29,1991 
  11. '
  12. '                 Utility to give free space on disks, 
  13. '                 delete files, make directories,  
  14. '                 rename files and show mounted devices.     
  15. '
  16. '  Create menu with zones  
  17. '
  18. 'If you move this prog off the ta disk remove the line below or  
  19. 'change it to the name of the new disk.
  20. '
  21. Dir$="Totally_amos_may_92:source_progs/diskute"
  22. Dim ITEM$(6)
  23. SELECTIONS
  24. '
  25. ' Copyright notice 
  26. '
  27. _SMALL_COPYRIGHT[225]
  28. '
  29. Procedure _SMALL_COPYRIGHT[YDISPLAY]
  30.    '
  31.    Auto View Off 
  32.    '  
  33.    Screen Open 7,320,24,16,0 : Curs Off : Flash Off : Cls 0
  34.    Screen Display 7,,-100,,
  35.    Load "copyright_sprite.abk"
  36.    Paste Bob 260,3,1
  37.    Paper 0 : Pen 7 : Print At(1,1);"This program was written using"
  38.    Get Sprite Palette 
  39.    View : Wait Vbl 
  40.    '
  41.    For Y=1 To Screen Height/2
  42.       Screen Display 7,,YDISPLAY+Screen Height/2-Y,,Y*2
  43.       Screen Offset 7,,Screen Height/2-Y
  44.       View : Wait Vbl 
  45.    Next 
  46.    '
  47.    Wait 100
  48.    '
  49.    For Y=Screen Height/2 To 0 Step -1
  50.       Screen Display 7,,YDISPLAY+Screen Height/2-Y,,Y*2
  51.       Screen Offset 7,,Screen Height/2-Y
  52.       View : Wait Vbl 
  53.    Next 
  54.    '
  55.    Screen Close 7
  56.    Auto View On 
  57.    '
  58. End Proc
  59. '
  60. MAIN:
  61. While CHOSEN<1
  62.    X=Mouse Zone
  63.    K=Mouse Key
  64.    If K<>0 Then CHOSEN=X
  65. Wend 
  66. '  
  67. Bell 
  68. Wait 20
  69. On CHOSEN Proc AMOUNT,XPUNGE,MAKE,CHANGENAME,MOUNTED,FINISHED
  70. CHOSEN=0
  71. Goto MAIN
  72. '
  73. '  Procedures start here.
  74. Procedure SELECTIONS
  75.    Shared ITEM$()
  76. '    Change the 200 in the screen open command to 256 on a PAL system
  77.    Screen Open 0,640,200,16,Hires
  78.    Curs Off 
  79.    Cls 0
  80.    Paper 14
  81.    Flash 14,"(019,200)(028,75)(037,75)(046,75)(055,75)(064,75)(073,75)(082,75)(091,200)(082,75)(073,75)(064,75)(055,75)(046,75)(037,75)(028,75)"
  82.    Reserve Zone 6
  83.    Pen 0
  84.    Print "                                  Disk Utility                                  "
  85.    Cup 
  86.    Print "                               by  Ken Kowalewski                               "
  87.    Cdown 
  88.    Cdown 
  89.    Cdown 
  90.    Paper 0
  91.    Pen 4
  92.    For R=1 To 6
  93.       Read ITEM$(R)
  94.       Centre Zone$(ITEM$(R),R)
  95.       Cdown 
  96.       Cdown 
  97.    Next R
  98.    Data "1. Number of bytes available on disk. "
  99.    Data "2. Delete a file from the disk.       "
  100.    Data "3. Create a new directory on disk.    "
  101.    Data "4. Rename a file on the disk.         "
  102.    Data "5. List all mounted devices.          "
  103.    Data "6. Return to the AMOS Editor.         "
  104.    Cdown 
  105.    Cdown 
  106.    Paper 0
  107.    Pen 12
  108.    Cline 
  109.    Centre "Place pointer on selection and press button."
  110.    Wind Save 
  111. End Proc
  112. '
  113. ' Within Procedure AMOUNT are the names for Df0: through Dh1:
  114. ' Each is named three times in If statement blocks 
  115. ' You may change any of these If blocks to reflect your system 
  116. '
  117. Procedure AMOUNT
  118.    Wind Open 1,144,50,42,12,1
  119.    If Exist("Df0:")
  120.       Dir$="Df0:"
  121.       Curs Off 
  122.       Paper 6
  123.       Clw 
  124.       Cdown 
  125.       Pen 0
  126.       F=Dfree
  127.       S$=Str$(F)
  128.       Centre "Space available on DF0:"+S$
  129.    End If 
  130.    If Exist("DF1:")
  131.       Cdown 
  132.       Dir$="DF1:"
  133.       F=Dfree
  134.       S$=Str$(F)
  135.       Centre "Space available on DF1:"+S$
  136.    End If 
  137.    If Exist("DF2:")
  138.       Cdown 
  139.       Dir$="DF2:"
  140.       F=Dfree
  141.       S$=Str$(F)
  142.       Centre "Space available on DF2:"+S$
  143.    End If 
  144.    If Exist("DF3:")
  145.       Cdown 
  146.       Dir$="DF3:"
  147.       F=Dfree
  148.       S$=Str$(F)
  149.       Centre "Space available on DF3:"+S$
  150.    End If 
  151.    If Exist("Dh0:")
  152.       Cdown 
  153.       Dir$="Dh0:"
  154.       F=Dfree
  155.       S$=Str$(F)
  156.       Centre "Space available in Dh0:"+S$
  157.    End If 
  158.    If Exist("Dh1:")
  159.       Cdown 
  160.       Dir$="Dh1:"
  161.       F=Dfree
  162.       S$=Str$(F)
  163.       Centre "Space available in Dh1:"+S$
  164.    End If 
  165.    Pen 3
  166.    Cdown 
  167.    Cdown 
  168.    Centre "Click mouse to continue..."
  169.    M=0
  170.    While M=0
  171.       M=Mouse Click
  172.    Wend 
  173.    Wind Close 
  174. End Proc
  175. Procedure XPUNGE
  176.    XPUNGE:
  177.    F$=Fsel$("**","","Locate File. Double-click on","File to be Deleted.")
  178.    If F$="" Then Pop Proc
  179.    Wind Open 1,24,50,74,7,1
  180.    Curs Off 
  181.    Paper 6
  182.    Clw 
  183.    Cdown 
  184.    Pen 0
  185.    Centre "Delete--> "+Pen$(4)+F$
  186.    Pen 3
  187.    Cdown 
  188.    Cdown 
  189.    Centre "Is this correct? [Y/N]"
  190.    M=0
  191.    A$=""
  192.    While A$="" and M=0
  193.       M=Mouse Click
  194.       A$=Inkey$
  195.    Wend 
  196.    If A$="Y"
  197.       Clw : Kill F$ : Pen 0 : Home : Cdown : Centre F$+" was deleted." : F$="" : Cdown : Cdown 
  198.    Else 
  199.       If A$="y"
  200.          Clw : Kill F$ : Pen 0 : Home : Cdown : Centre F$+" was deleted." : F$="" : Cdown : Cdown 
  201.       Else 
  202.          If M=1
  203.             Clw : Kill F$ : Pen 0 : Home : Cdown : Centre F$+" was deleted." : F$="" : Cdown : Cdown 
  204.          End If 
  205.       End If 
  206.    End If 
  207.    Pen 3
  208.    Cline 
  209.    Centre "Delete Another? [Y/N]"
  210.    M=0
  211.    A$=""
  212.    While A$="" and M=0
  213.       M=Mouse Click
  214.       A$=Inkey$
  215.    Wend 
  216.    Wind Close 
  217.    If A$-"Y"
  218.       M=0 : A$="" : Goto XPUNGE
  219.    Else 
  220.       If A$="y"
  221.          M=0 : A$="" : Goto XPUNGE
  222.       Else 
  223.          If M=1
  224.             M=0 : A$="" : Goto XPUNGE
  225.          End If 
  226.       End If 
  227.    End If 
  228. End Proc
  229. Procedure MAKE
  230.    DRECTORY:
  231.    F$=Fsel$("","","Locate level for directory.","Type name at prompt, then hit RETURN.")
  232.    If F$="" Then Pop Proc
  233.    Wind Open 1,24,50,74,7,1
  234.    Curs Off 
  235.    Paper 6
  236.    Clw 
  237.    Cdown 
  238.    Pen 0
  239.    Centre "New Directory--> "+Pen$(4)+F$
  240.    Pen 3
  241.    Cdown 
  242.    For POSITION=Len(F$) To 1 Step -1
  243.       If Mid$(F$,POSITION,1)="/"
  244.          POSITION=Len(F$)-POSITION : DNAME$=Right$(F$,POSITION) : POSITION=1
  245.       Else 
  246.          If Mid$(F$,POSITION,1)=":"
  247.             POSITION=Len(F$)-POSITION : DNAME$=Right$(F$,POSITION) : POSITION=1
  248.          End If 
  249.       End If 
  250.    Next POSITION
  251.    Cdown 
  252.    Centre "Is this correct? [Y/N]"
  253.    M=0
  254.    A$=""
  255.    While A$="" and M=0
  256.       M=Mouse Click
  257.       A$=Inkey$
  258.    Wend 
  259.    If A$="Y"
  260.       Clw : Mkdir F$ : Pen 0 : Home : Cdown : Centre "Directory--> "+DNAME$+" was created." : F$="" : Cdown : Cdown 
  261.    Else 
  262.       If A$="y"
  263.          Clw : Mkdir F$ : Pen 0 : Home : Cdown : Centre "Directory--> "+DNAME$+" was created." : F$="" : Cdown : Cdown 
  264.       Else 
  265.          If M=1
  266.             Clw : Mkdir F$ : Pen 0 : Home : Cdown : Centre "Directory--> "+DNAME$+" was created." : F$="" : Cdown : Cdown 
  267.          End If 
  268.       End If 
  269.    End If 
  270.    Pen 3
  271.    Cline 
  272.    Centre "Create Another? [Y/N]"
  273.    M=0
  274.    A$=""
  275.    While A$="" and M=0
  276.       M=Mouse Click
  277.       A$=Inkey$
  278.    Wend 
  279.    Wind Close 
  280.    If A$="Y"
  281.       M=0 : A$="" : Goto DRECTORY
  282.    Else 
  283.       If A$="y"
  284.          M=0 : A$="" : Goto DRECTORY
  285.       Else 
  286.          If M=1
  287.             M=0 : A$="" : Goto DRECTORY
  288.          End If 
  289.       End If 
  290.    End If 
  291. End Proc
  292. Procedure CHANGENAME
  293.    CHGNAME:
  294.    F$=Fsel$("**","","Locate file to be renamed,","then double-click on filename.")
  295.    If F$="" Then Pop Proc
  296.    Wind Open 1,24,50,74,7,1
  297.    Curs Off 
  298.    Paper 6
  299.    Clw 
  300.    Cdown 
  301.    Pen 0
  302.    Centre "Path of old name--> "+Pen$(4)+F$
  303.    Cdown 
  304.    Locate 8,
  305.    Pen 0
  306.    Curs On 
  307.    Input "Enter new filename--> "+Pen$(4);NNAME$
  308.    Curs Off 
  309.    For POSITION=Len(F$) To 1 Step -1
  310.       If Mid$(F$,POSITION,1)="/"
  311.          POSITION=Len(F$)-POSITION : DNAME$=Right$(F$,POSITION) : POSITION=1
  312.       Else 
  313.          If Mid$(F$,POSITION,1)=":"
  314.             POSITION=Len(F$)-POSITION : DNAME$=Right$(F$,POSITION) : POSITION=1
  315.          End If 
  316.       End If 
  317.    Next POSITION
  318.    Clw 
  319.    Cdown 
  320.    Pen 0
  321.    Centre "Change "+Pen$(4)+DNAME$+Pen$(0)+" to "+Pen$(4)+NNAME$
  322.    Pen 3
  323.    Cdown 
  324.    Cdown 
  325.    Centre "Is this correct? [Y/N]"
  326.    M=0
  327.    A$=""
  328.    While A$="" and M=0
  329.       M=Mouse Click
  330.       A$=Inkey$
  331.    Wend 
  332.    If A$="Y"
  333.       Clw : C$=F$-DNAME$ : Rename F$ To C$+NNAME$ : Pen 0 : Home : Cdown : Centre "The change has been made." : F$="" : Cdown : Cdown 
  334.    Else 
  335.       If A$="y"
  336.          Clw : C$=F$-DNAME$ : Rename F$ To C$+NNAME$ : Pen 0 : Home : Cdown : Centre "The change has been made." : F$="" : Cdown : Cdown 
  337.       Else 
  338.          If M=1
  339.             Clw : C$=F$-DNAME$ : Rename F$ To C$+NNAME$ : Pen 0 : Home : Cdown : Centre "The change has been made." : F$="" : Cdown : Cdown 
  340.          End If 
  341.       End If 
  342.    End If 
  343.    Pen 3
  344.    Cline 
  345.    Centre "Rename Another? [Y/N]"
  346.    M=0
  347.    A$=""
  348.    While A$="" and M=0
  349.       M=Mouse Click
  350.       A$=Inkey$
  351.    Wend 
  352.    Wind Close 
  353.    If A$="Y"
  354.       M=0 : A$="" : Goto CHGNAME
  355.    Else 
  356.       If A$="y"
  357.          M=0 : A$="" : Goto CHGNAME
  358.       Else 
  359.          If M=1
  360.             M=0 : A$="" : Goto CHGNAME
  361.          End If 
  362.       End If 
  363.    End If 
  364. End Proc
  365. Procedure MOUNTED
  366.    Wind Open 1,144,30,42,19,1
  367.    Curs Off 
  368.    Paper 6
  369.    Clw 
  370.    Cdown 
  371.    Pen 0
  372.    S$=Dev First$("*")
  373.    Print Space$(10);S$
  374.    Cup 
  375.    Do 
  376.       S$=Dev Next$
  377.       If S$="" Then Exit 
  378.       Print Space$(10);S$
  379.       Cup 
  380.    Loop 
  381.    Pen 3
  382.    Cdown 
  383.    Centre "Click mouse to continue..."
  384.    M=0
  385.    While M=0
  386.       M=Mouse Click
  387.    Wend 
  388.    Wind Close 
  389. End Proc
  390. Procedure FINISHED
  391.    A$=""
  392.    M=0
  393.    Wind Open 1,144,50,40,6,1
  394.    Curs Off 
  395.    Paper 6
  396.    Clw 
  397.    Cdown 
  398.    Pen 0
  399.    Centre "Return to AMOS"
  400.    Pen 3
  401.    Cdown 
  402.    Centre "Are you sure? [Y/N]"
  403.    While A$="" and M=0
  404.       M=Mouse Click
  405.       A$=Inkey$
  406.    Wend 
  407.    If A$<>"Y"
  408.       If A$<>"y"
  409.          If M<>1
  410.             Wind Close 
  411.             Pop Proc
  412.             Wait 40
  413.          End If 
  414.       End If 
  415.    End If 
  416.    For B=50 To 75 Step 5
  417.       Bell B
  418.       Wait B/5+1
  419.    Next B
  420.    Wind Close 
  421.    Flash Off 
  422.    Fade 7
  423.    Wait 55
  424.    Edit 
  425. End Proc