home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / winutil / wspcr20 / wsdelete.wbt < prev    next >
Text File  |  1991-09-27  |  3KB  |  89 lines

  1. ; --- WSDELETE.WBT is the file needed to delete ALL or selected spaces.
  2. ;     WorkSpacer 2.0 ⌐ 1991 - WiGuys Software    
  3.  
  4. ; --- if there is nothing in the library, exit
  5.  
  6. Call ( "wsglobal.wbt", "" )
  7. deleted = 0
  8. If FileSize ( spacelib ) == 0 Then GoTo Nada
  9. DialogBox ( wsver, "wsdelete.wbd" )
  10. If del == 2 Then GoTo DelAll
  11.  
  12. ; --- for single workspace deletions, get the workspace name from the list
  13.  
  14. :Start
  15. grpname = TextBox ( "%wsver% Delete", spacelib )
  16. If StrICmp ( grpname, nul ) == 0 Then GoTo Start
  17. q = AskYesNo ( wsver, "OK to delete the WorkSpace : %tf% %grpname% ?" )
  18. IF q == @NO Then GoTo Start
  19.  
  20. ; --- rename the "old" library, and set it up to read from, with a "new"
  21. ;     library file to write the data being retained to
  22.  
  23. FileRename ( spacelib, spacebak )
  24. fHandle1 = FileOpen ( spacebak, "READ" )
  25. fHandle2 = FileOpen ( spacelib, "WRITE" )
  26.  
  27. ; --- read each line of the "old" library - if it is not the workspace to be
  28. ;     deleted, write the name to the "new" file
  29.  
  30. :ReadNext
  31. count = 1
  32. line = FileRead ( fHandle1 )
  33. If StrICmp ( line, grpname ) == 0 Then GoTo ReadNext
  34. If line == "*EOF*" Then GoTo CloseFile
  35. FileWrite ( fHandle2, line )
  36.  
  37. ; --- Read the information from the INI file, and write it to a "temp" INI
  38. ;     for those workspaces not to be deleted
  39.  
  40. :IniLines
  41. key1 = "App%count%"
  42. key2 = "Status%count%"
  43. key3 = "Load%count%"
  44. key4 = "Pos%count%"
  45. key5 = "Win%count%"
  46. filename = IniReadPvt ( line, key1, nul, "wspacer.ini" )
  47. If StrICmp ( filename, nul ) == 0 Then GoTo ReadNext
  48. IniWritePvt (line, key1, filename, "wspacer2.ini" )
  49. status = IniReadPvt ( line, key2, "Normal", "wspacer.ini" )
  50. IniWritePvt ( line, key2, status, "wspacer2.ini" )
  51. loadname = IniReadPvt ( line, key3, nul, "wspacer.ini" )
  52. IniWritePvt ( line, key3, loadname, "wspacer2.ini" )
  53. currpos = IniReadPvt ( line, key4, nul, "wspacer.ini" )
  54. IniWritePvt ( line, key4, currpos, "wspacer2.ini" )
  55. currwind = IniReadPvt ( line, key5, nul, "wspacer.ini" )
  56. IniWritePvt ( line, key5, currwind, "wspacer2.ini" )
  57. count = count + 1
  58. GoTo IniLines
  59.  
  60. ; --- close all open files, and clean up any "old" files left behind, then
  61. ;     check to see if the user wants to delete additional workspaces
  62.  
  63. :CloseFile
  64. FileClose ( fHandle1 )
  65. FileClose ( fHandle2 )
  66. FileDelete ( spacebak )
  67. FileDelete ( spaceini )
  68. If FileSize ( spacelib ) == 0 Then GoTo Fini
  69. FileRename ( inibak, spaceini )
  70. deleted = deleted + 1
  71. q = AskYesNo ( wsver, "%grpname%  has been deleted. %tf% Delete another WorkSpace?" )
  72. If q == @YES Then GoTo Start
  73. Message ( wsver, "%deleted% WorkSpace(s) have been deleted." )
  74. Return
  75.  
  76. :Nada
  77. Message ( wsver, " There are no WorkSpaces to delete." )
  78. Return
  79.  
  80. :DelAll
  81. q = AskYesNo ( wsver, "Delete ALL WorkSpace records ?" )
  82. If q == @NO Then Return
  83. FileDelete ( spacelib )
  84. FileDelete ( spaceini )
  85.  
  86. :Fini
  87. Message ( wsver, "All workspaces have been deleted!" )
  88. Return
  89.