' this program PERMANENTLY DELETES CHANNELS FROM A DATA FILE!!!!!!!!!!!!! ' it makes a backup file, checks whether channels were deleted and then deletes the backup file ' no warranty!!! Ónly work with copies of your file, never use the original - there is no UNDO!!!!!!! var janein$,chnumber$,fh%,ok%,channels$,savename$,laenge, Laenge2, rechterteil$, Loesch$,testsuccess,testsuccess2, Dosloesch$; var rename$, renamepath$, success$, message$,chnumber, stop$, renames2r$, renames2rnow$, original$, savedrename$; fh%:=view(); '*********************create dialog box ******************** view(fh%); DlgCreate("You want to ultimately delete channels!! NO UNDO!!!"); DlgString(1, "give channelnumbers TO KEEP separated by commas or leave blank -> removes all deleted channels", 50); DlgString(2, "type 'no' here if you do not want to proceed? ",50); ok% := DlgShow(chnumber$,stop$); if not ok% then Halt(); endif; if stop$="no" then halt; endif; '************************************************************ original$:=Filename$(); Laenge:=LEN(Filename$()); 'get number of characters in Filename Laenge2:=LEN(Filename$(1))+LEN(Filename$(2)); 'get number of characters in filename, path and drive only Loesch$:=DelStr$(Filename$(),Laenge-3,Laenge-3); ' returns path and filename without .smr rename$:=Mid$(Filename$(),Laenge2+1,200); 'gets filename with .smr rename$:="DELETE_THIS_" + rename$; ' add DELETE_ThIS to filename (no path!!!) savename$:=Loesch$+"_1"+".smr"; ' make new filename renames2r$:=Loesch$ + ".s2r"; ' this is the name of the according s2r file renames2rnow$:=Mid$(Loesch$,Laenge2+1,Laenge-Laenge2); ' and make it new filename.s2r (no path!!) savedrename$:="cmd /c ren " + savename$ + " " + renames2rnow$ + ".smr"; ' for renaming new saved file to original name renames2r$:="cmd /c ren " + renames2r$ + " " + renames2rnow$ + "_001.s2r"; ' for renaming s2r file, if necessary Dosloesch$:="cmd /c ren " + Filename$() + " " + rename$; 'create rename file from dos-command line printlog(savedrename$); if chnumber$="" then ' user wants to get rid of already deleted channels interact("please delete all channels that you want to get rid off", 1023); 'ask user to delete all unneccessary channels chnumber:=-1; ' means: all channels ExportChanFormat(1, 1, 1); ExportChanFormat(2, 1, 1); ExportChanFormat(3, 1, 1); ExportChanFormat(4, 1, 1); ExportChanFormat(5, 1, 1); ExportChanFormat(6, 1, 1); ExportChanFormat(7, 1, 1); ExportChanFormat(8, 1, 1); ExportChanFormat(9, 1, 1); ExportChanList(); ExportChanList(0,maxtime(),chnumber); 'make sure ALL channels are exported testsuccess:=FileSaveAs(savename$,0); 'export file as Datafile with new name (savename) if testsuccess<0 then interact("AN ERROR OCCURED DURING SAVING YOUR FILE - SCRIPT STOPS NOW _ NO Files were DELETED!",1023); halt; endif; testsuccess2:=fileclose(); ' close the original file Progrun(Dosloesch$,0); ' and rename it to DELETE_THIS_balbla ' Progrun(renames2r$,0); ' rename s2r file yield(1.5); ' wait till DOS has finished Progrun(savedrename$,0); ' rename saved new file to old filename yield(1.5); ' wait till DOS has finished fileopen(original$,0); ' open the new , exported file success$:=Filename$(); ' check if file was opened if LEN(success$)=0 then ' if no file was opened -> something went wrong! janein$:=input$("an error occured with the original file - do you really want to delete it?","no"); if janein$="yes" then testsuccess:=Filedelete(rename$); ' is user wants to delete original file if testsuccess>0 then ' do it interact("Backup-File was deleted",1023); endif; else message$:="The Backup-file is kept: Name: " + rename$; ' tell user that file was kept plus filename interact(message$,1023); endif; else testsuccess:=Filedelete(rename$); 'if file was opened, delete original file if testsuccess>0 then interact("Backup-File was deleted",1023); endif; endif; else ' if channelnumbers are given in dialog box ExportChanFormat(1, 1, 1); ExportChanFormat(2, 1, 1); ExportChanFormat(3, 1, 1); ExportChanFormat(4, 1, 1); ExportChanFormat(5, 1, 1); ExportChanFormat(6, 1, 1); ExportChanFormat(7, 1, 1); ExportChanFormat(8, 1, 1); ExportChanFormat(9, 1, 1); ExportChanList(); ExportChanList(0,maxtime(),chnumber$); ' here is the difference: Export only channels given in dialog box! testsuccess:=FileSaveAs(savename$,0); if testsuccess<0 then interact("AN ERROR OCCURED DURING SAVING YOUR FILE - SCRIPT STOPS NOW _ NO FILES WERE DELETED!",1023); halt; endif; testsuccess2:=fileclose(); Progrun(Dosloesch$,0); ' Progrun(renames2r$,0); yield(2.5); ' wait till DOS has finished Progrun(savedrename$,0); ' rename saved new file to old filename yield(2.5); ' wait till DOS has finished fileopen(original$,0); success$:=Filename$(); if LEN(success$)=0 then janein$:=input$("an error occured with the original file - do you really want to delete it?","no"); if janein$="yes" then testsuccess:=Filedelete(rename$); if testsuccess>0 then interact("Backup-File was deleted",1023); endif; else message$:="Backup-The file is kept: Name: " + rename$; interact(message$,1023); endif; else janein$:=input$("everything seems to be ok - do you want to delete the backup file?","no"); if janein$="yes" then testsuccess:=Filedelete(rename$); if testsuccess>0 then interact("Backup-File was deleted",1023); endif; else message$:="Backup-The file is kept: Name: " + rename$; interact(message$,1023); endif; endif; endif;