home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1992-03-19 | 46.2 KB | 1,312 lines
; Define addon menu USER menus should go into CMDUSER.CPM...by convention... #NextFile CMDUSER.CPM ; CmdPost menu initialization code ; Initialize a few variables here. Sounds(0) ;Turn sounds off awhile a=Version() CP="CmdPost" CPDIR=DirHome() cr=strcat(num2char(13),num2char(10)) crlf=cr cpini="WWW-PROD.INI" tab=num2char(9) Editor=inireadpvt(CP,"Editor","Notepad.exe",cpini) CopyMoveDefault="" if (NetGetCaps(2)==0) then MenuChange("FileNetwork",@DISABLE) ; Setting up the View menu item here. a=inireadpvt(CP,"ViewSetup","NO",cpini) if a=="NO" then goto DEFSETUP ViewShortLong=inireadpvt(CP,"ViewShortLong","SHORT",cpini) if ViewShortLong=="SHORT" then MenuChange("ViewShort",@CHECK) if ViewShortLong=="LONG" then MenuChange("ViewLong",@CHECK) ViewBy=inireadpvt(CP,"ViewBy","NAME",cpini) if ViewBy=="NAME" then MenuChange("ViewByName",@CHECK) if ViewBy=="DATE" then MenuChange("ViewByDate",@CHECK) if ViewBy=="SIZE" then MenuChange("ViewBySize",@CHECK) if ViewBy=="KIND" then MenuChange("ViewByKind",@CHECK) if ViewBy=="UNSORTED" then MenuChange("ViewUnsorted",@CHECK) ViewWhat=inireadpvt(CP,"ViewWhat","ALL",cpini) if ViewWhat=="ALL" then MenuChange("ViewAll",@CHECK) if ViewWhat=="PARTIAL" then MenuChange("ViewPartial",@CHECK) if ViewWhat=="PROGRAMS" then MenuChange("ViewPrograms",@CHECK) SD3="*.*" if ViewWhat=="PROGRAMS" then SD3="*.EXE *.COM *.BAT *.PIF" if ViewWhat=="PARTIAL" then SD3=inireadpvt(CP,"Partial","*.*",cpini) SetDisplay(ViewShortLong,ViewBy,SD3) drop(ViewShortLong,ViewBy,ViewWhat,SD3) goto PRINTSETUP :DEFSETUP SetDisplay("SHORT","NAME","*.*") MenuChange("ViewAll",@CHECK) MenuChange("ViewByName",@CHECK) MenuChange("ViewShort",@CHECK) ; Start clock/blanker - Win 3.0 only if (WinVersion(@MAJOR)==3 && WinVersion(@MINOR)>=10) then goto PRINTSETUP ; Setup Screen Blank Time. Get time from win.ini a=inireadpvt(CP,"BlankTime",5,cpini) if a!=9999 then run("%CPDIR%cp_blnk.exe",a) ; ; <0....blanking with no clock ; ; 0... no blanking, but have a clock ; ; >0... blanking and clock ; ; 9999 Don't even run it. ; Setup Print menu item...Kill it if no text printer :PRINTSETUP MenuChange("FilePrint", (inireadpvt(CP,"TextPrinter","",cpini)=="NONE") *@DISABLE) if IsRunning() then goto goombye a=inireadpvt(CP,"AutoStart","NO",cpini) if a!="YES" then goto goombye ;if Display(3,"Auto Startup","Hit any key to bypass WIN.INI%CR%Run= and Load= processing") then goto goombye a=iniread("windows","load","") b=ItemCount(a," ") d=0 :woop1 if d==b then goto dorun d=d+1 c=ItemExtract(d,a," ") Runicon(c,"") goto woop1 :dorun a=iniread("windows","run","") b=ItemCount(a," ") d=0 :woop2 if d==b then goto goombye d=d+1 c=ItemExtract(d,a," ") Run(c,"") goto woop2 :goombye Sounds(1) ;Sounds on drop(a,b,c,d) ; And the main menu starts. &File &Run... r=CurrentFile() if !IsKeyDown(@SHIFT) then r=askline("RUN","Enter file to run",r) r=strcat(strtrim(r)," ") i=strindex(r," ",0,@FWDSCAN) a=strsub(r,1,i-1) b=strtrim(strsub(r,i,strlen(r)-i+1)) run("%a%","%b%") drop(a,b,r,i) &Load... r=CurrentFile() if !IsKeyDown(@SHIFT) then l=askline("LOAD","Enter file to load",CurrentFile()) l=strcat(strtrim(l)," ") i=strindex(l," ",0,@FWDSCAN) a=strsub(r,1,i-1) b=strtrim(strsub(r,i,strlen(r)-i+1)) runicon("%a%","%b%") drop(a,b,i,l) Bro&wse... \ {F3} l=CurrentFile() ;if !IsKeyDown(@SHIFT) then l=strtrim(askline("Browse","Enter file to browse",l)) run("%CPDIR%browser.exe",l) drop(a,l) &Edit... \ {F4} l=CurrentFile() ;if !IsKeyDown(@SHIFT) then l=askline("Edit","Enter file to edit",l) if l=="" || l==" " then goto NULL a=strscan(l,".\",0,@BACKSCAN) if a==0 then l=strcat(l,".") if a==0 then goto NULL if strsub(l,a,1)!="." then l=strcat(l,".") :NULL run(Editor,strtrim(l)) drop(a,b,l) &Copy... \ {F8} r=OtherDir() if r!=DirGet() then goto NEXT if CopyMoveDefault!="" then r=CopyMoveDefault :NEXT s=strcat(DirItemize("")," ",FileItemize("")) terminate(strlen(s)==1,"Copy Error","No files selected") if !IsKeyDown(@SHIFT) then r=strtrim(askline("Copy",StrCat(s,CR,CR,"to"),r)) terminate(r=="","Copy Error","Cannot copy to null file name") q=strindex(r,"\",0,@FWDSCAN) ; Directory Name in there?? CopyMoveDefault=r if q==0 then SetDisplay("","","") ;Nope. Set flag to update directory FileCopy(s,r,@TRUE) OtherUpdate() drop(r,s,q) &Move/Rename... \ {F7} r=OtherDir() if r!=DirGet() then goto NEXT if CopyMoveDefault!="" then r=CopyMoveDefault :NEXT s=strcat(DirItemize("")," ",FileItemize("")) terminate(strlen(s)==1,"Move Error","No files selected") if !IsKeyDown(@SHIFT) then r=strtrim(askline("Move",StrCat(s,CR,CR,"to"),r)) terminate(r=="","Move Error","Cannot move to null file name") SetDisplay("","","") ;Set flag to update directory CopyMoveDefault=r FileMove(s,r,@TRUE) OtherUpdate() drop(r,s) &Delete File... \ {DEL} f=FileItemize("") if IsKeyDown(@SHIFT) then goto doit g=FileSize(f) i=ItemCount(f," ") terminate(strlen(f)==0,"delete","No files specified") if askyesno("Delete %i% files: %g% bytes ",f)==@NO then exit :doit SetDisplay("","","") ;Set flag to update directory FileDelete(f) OtherUpdate() ; Well if the "other" CmdPost Window points to the ; same directory, it *IS* nice... drop(f,g,b) &Print... s=FileItemize("") terminate(strlen(s)==0,"Print Error","No files selected") TextPrinter=inireadpvt(CP,"TextPrinter","ASK",cpini) if TextPrinter!="ASK" then goto NOASK1 r=AskYesNo("Attention",strcat("This print routine only works with standard printers.",CR,"Do you have a standard (NON-Postscript) printer?")) if r==@YES then goto ASK1 iniwritepvt(CP,"TextPrinter","NONE",cpini) MenuChange("FilePrint",@DISABLE) Exit :ASK1 TextPrinter="NONE|LPT1|LPT2|LPT3" TextPrinter=ItemSelect("Choose the STD text printer",TextPrinter,"|") terminate(strlen(TextPrinter)==0,"Error","Nothing chosen") iniwritepvt(CP,"TextPrinter",TextPrinter,cpini) :NOASK1 Terminate(TextPrinter=="NONE","ERROR","No Text Printers on system") a=AskLine("Print",strcat(s,CR,CR,"to"),TextPrinter) FileCopy(s,a,@FALSE) _File &Info a=FileItemize("") if a=="" then a=FileItemize("*.*") tot=FileSize(a) c=ItemCount(a," ") n=0 b="" :loop if n==c then goto show n=n+1 a1=StrFix(ItemExtract(n,a," ")," ",14) a2=FileSize(a1) a3=FileTimeGet(a1) a4=FileAttrGet(a1) b=strcat(b,a1,tab,a2,tab,a3,tab,a4,"|") goto loop :show ItemSelect("Total Size=%tot%",b,"|") :cancel drop(a,tot,c,n,a1,a2,a3,a4,b) &Freespace on Local Drives Drive=DiskScan(2) ; 2 is the code for local hard drives Dmax=strlen(Drive) DIndex=1 TotalSize=0 DriveReport="" :COUNTSPACE NextDrive=StrSub(Drive,Dindex,1) a=DiskFree(NextDrive)/1024 TotalSize=a+TotalSize DriveReport=strcat(DriveReport,NextDrive," = ",a,"K","@") DIndex=Dindex+3 ;each entry is 3 bytes long if DIndex<=Dmax then goto COUNTSPACE ItemSelect("Total Space Available = %TotalSize%K",DriveReport,"@") Drop(xxx,TotalSize,DriveReport,NextDrive,LastDrive) _E&xit Windows \ ^X EndSession() |Find file On DOS Path a=AskLine("Locate file in path","Enter file name to locate",CurrentFile()) b=FileLocate(a) terminate(b=="",a,"File Not Located") if AskYesNo(b,"File Located.%CR%Change to that directory?")==@NO then exit DirChange(FilePath(b)) SetDisplay("","","") On Current Drive Mask=Askline("Find File on drive","Enter file name to locate","*.bak") FileList="" tot=0 totdir=0 DirChange("\") LocalList=FileItemize(Mask) if LocalList=="" then goto skip11 tot = FileSize(LocalList) totdir=1 LocalList=strcat(" ",strsub(LocalList,1,strlen(LocalList)-1)) locdir=DirGet() LocalList=strreplace(LocalList," "," %locdir%") FileList=LocalList Drop(LocalList) :Skip11 level=1 dir1=DirGet() sub1 = DirItemize("*.*") numdir1 = ItemCount(sub1, " ") index1 = 0 :loop If index%level% == numdir%level% Then Goto upalevel index%level% = index%level% + 1 DirChange(StrCat(dir%level%, ItemExtract(index%level%, sub%level%, " "))) LocDir = DirGet() LocalList=FileItemize(Mask) if LocalList=="" then goto skip22 totdir=totdir+1 tot = tot + FileSize(LocalList) LocalList=strcat(" ",strsub(LocalList,1,strlen(LocalList)-1)) LocalList=strreplace(LocalList," "," %locdir%") FileList=Strcat(FileList,LocalList) drop(LocalList) :skip22 level = level + 1 dir%level%=LocDir sub%level% = DirItemize("*.*") numdir%level% = ItemCount(sub%level%, " ") index%level% = 0 goto loop :upalevel drop(dir%level%,sub%level%,index%level%,numdir%level%) level=level-1 if level!=0 then goto loop :done ; ----------- ; Termination ; ----------- If StrLen(tot) < 9 Then tot = StrCat(StrFill("", 9 - StrLen(tot)), tot) tot = StrCat(StrSub(tot,1,3),",",StrSub(tot,4,3),",",StrSub(tot,7,3)) tot = StrTrim(tot) If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1) tot = StrTrim(tot) If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1) tot = StrTrim(tot) if FileList!="" then FileList=Strsub(FileList,2,strlen(FileList)-1) level=ItemCount(FileList," ") SelectedFile=ItemSelect("%totdir% SubDirs. %level% Files. %tot% bytes.",FileList," ") if SelectedFile=="" then goto GOOMBYE DirChange(FilePath(SelectedFile)) SetDisplay("","","") :GOOMBYE drop(tot,level,totdir,FileList,SelectedFile) _&Hilite Files By Names a=AskLine("Hilite Files","Enter types of files to hilite",strcat("*.",FileExtension(CurrentFile()))) FileHilite(a,@TRUE) By Attribute :askagain a="Enter an attribute to hilite. R A S or H" b="Use CAPS to hilite if attribute is set," c="Use lowercase to hilite if not set." a=strcat(a,CR,b,CR,c,CR,"Enter only one character. R A S or H") drop(b,c) a=AskLine("Hilite by Attribute",a,"A") if strlen(a)!=1 then goto askagain case=2 if (a=='R' || a=='A' || a=='S' || a=='H') then case=1 if (a=='r' || a=='a' || a=='s' || a=='h') then case=0 a=strupper(a) if case==2 then goto askagain d=FileItemize("*.*") e=ItemCount(d," ") f=0 :loop f=f+1 if f>e then exit q=ItemExtract(f,d," ") g=FileAttrGet(q) h=strscan(g,a,1,@FWDSCAN) if h>0 then h=1 ;display(3,"%a% %h%","%q% %g%: if case==h then filehilite(q,@TRUE) ;beep goto loop &Unhilite Files By Name a=AskLine("Unhilite Files","Enter types of files to unhilite",strcat("*.",FileExtension(CurrentFile()))) FileHilite(a,@FALSE) By Attribute :askagain a="Enter an attribute to hilite. R A S or H" b="Use CAPS to hilite if attribute is set," c="Use lowercase to hilite if not set." a=strcat(a,CR,b,CR,c,CR,"Enter only one character. R A S or H") drop(b,c) a=AskLine("Hilite by Attribute",a,"A") if strlen(a)!=1 then goto askagain case=2 if (a=='R' || a=='A' || a=='S' || a=='H') then case=1 if (a=='r' || a=='a' || a=='s' || a=='h') then case=0 a=strupper(a) if case==2 then goto askagain d=FileItemize("*.*") e=ItemCount(d," ") f=0 :loop f=f+1 if f>e then exit q=ItemExtract(f,d," ") g=FileAttrGet(q) h=strscan(g,a,1,@FWDSCAN) if h>0 then h=1 ;display(3,"%a% %h%","%q% %g%: if case==h then filehilite(q,@FALSE) ;beep goto loop _File Attributes View/Modify current file DaFile=CurrentFile() :REDO attr=FileAttrGet(DaFile) RD=2 AR=2 SY=2 HD=2 if strsub(attr,1,1)=="R" then RD=1 if strsub(attr,2,1)=="A" then AR=1 if strsub(attr,3,1)=="S" then SY=1 if strsub(attr,4,1)=="H" then HD=1 OldHD=HD OldSY=SY b=@YES DialogBox("View/Modify Attributes","cp_attr2.dlg") If OldHD!=HD then b=AskYesNo("Attribute Changer","Note: Changing Hidden attribute is unusual%CR%Continue?") if b==@NO then goto REDO If OldSy!=SY then b=AskYesNo("Attribute Changer","Note: Changing System attribute is unusual%CR%Continue?") if b==@NO then goto REDO attr="" if RD==1 then attr="R" if RD==2 then attr='r' if AR==1 then attr=strcat(attr,"A") if AR==2 then attr=strcat(attr,"a") if HD==1 then attr=strcat(attr,"H") if HD==2 then attr=strcat(attr,"h") if SY==1 then attr=strcat(attr,"S") if SY==2 then attr=strcat(attr,"s") FileAttrSet(DaFile,attr) SetDisplay("","","") Change hilited files a=FileItemize("") terminate(a=="","Attribute Changer","No files Hilited") string=a if strlen(string)<35 then goto REDO string=strcat(strfix(string," ",35)," ...") :REDO RD=3 AR=3 SY=3 HD=3 b=@YES DialogBox("Attribute Changer","cp_attr1.dlg") If HD!=3 then b=AskYesNo("Attribute Changer","Note: Changing Hidden attribute is unusual%CR%Continue?") if b==@NO then goto REDO If SY!=3 then b=AskYesNo("Attribute Changer","Note: Changing System attribute is unusual%CR%Continue?") if b==@NO then goto REDO attr="" if RD==1 then attr="R" if RD==2 then attr='r' if AR==1 then attr=strcat(attr,"A") if AR==2 then attr=strcat(attr,"a") if HD==1 then attr=strcat(attr,"H") if HD==2 then attr=strcat(attr,"h") if SY==1 then attr=strcat(attr,"S") if SY==2 then attr=strcat(attr,"s") FileAttrSet(a,attr) SetDisplay("","","") _Floppy Space A: message(strcat("Drive A ",DiskFree("A")),strcat("Selected Files ",FileSize(FileItemize("")))) B: message(strcat("Drive B ",DiskFree("B")),strcat("Selected Files ",FileSize(FileItemize("")))) _&Network Connect Drive to Net AvailDrive=DiskScan(0) DrvLen=strlen(AvailDrive) if DrvLen==0 then goto NOMORE AvailDrive=Strsub(AvailDrive,DrvLen-2,2) NetPath=NetBrowse(0) pswd=AskPassword("Enter password for",NetPath) NetAddCon(NetPath,pswd,AvailDrive) exit :NOMORE Message("Connect Drive to Net","No drives avail for assignment") Disconnect AvailDrive=DiskScan(4) a=Itemcount(AvailDrive," ") if a==0 then exit i=1 DisList="" :loop b=ItemExtract(i,AvailDrive," ") DisList=strcat(b,num2char(9),NetGetCon(b),"|") i=i+1 if i<a then goto loop AvailDrive=ItemSelect("Disconnect",DisList,"|") NetCancelCon(AvailDrive,0) Net Dialog NetDialog() _&Extensions... a=strtrim(CurrentFile()) i=strindex(a,".",0,@FWDSCAN) terminate(i==0,"Association Error","Associated files must have an extension") b=FileExtension(a) c=iniread("extensions",b,"???.EXE ^.%b%") d=askline("Associate","%b% files are associated with",c) terminate(c==d,"","") iniwrite("extensions",b,d) &Dir Create Director&y... a=askline("Create Directory","Enter directory to create",DirGet()) terminate(a=="","Create Error","Cannot create directory with null name") DirMake(strtrim(a)) SetDisplay("","","") drop(a) &Rename Directory... a=DirItemize("") terminate(ItemCount(a," ")!=1,"Rename Error","Zero or more than one dir specified") b=strtrim(AskLine("Rename Directory","Enter new directory name for %a%",a)) terminate(a==b || b=="","Rename Error","Illegal name change specified") DirRename(strtrim(a),b) SetDisplay("","","") OtherUpdate() drop(a,b) &Kill Directory... f=DirItemize("") terminate(strlen(f)==0,"Delete Directory","No directory specified") ;terminate(@no==askyesno("Delete Directory",f),"Delete Directory","Directory not deleted") DirRemove(strtrim(f)) SetDisplay("","","") OtherUpdate() ; Well if the "other" CmdPost Window points to the ; same directory, it *is* nice drop(f) &Change Directory... a=DirGet() b=strindex(a,':',1,@fwdscan) c=strtrim(askline("Change Directory","Enter directory name",strsub(a,b+1,strlen(a)-b-1))) terminate(c=="","Directory Error","Directory with null name does not exist") DirChange(c) SetDisplay("","","") drop(a,b,c) _&Nuke ENTIRE file/dir structure files=FileItemize("") numfile=ItemCount(files, " ") totdir=0 dir1=DirGet() sub1 = DirItemize("") numdir1=Itemcount(sub1, " ") if (numfile+numdir1)==0 then goto noselect Pause("WARNING: Are you Sure :WARNING", "You are about to delete all kinds of stuff%CR%containing possibly 10 zillion files and subdirs.%CR%Continue?") if AskYesNo("WARNING: Are you REALLY Sure :WARNING","Shall we stop now and not delete anything?")==@YES then goto quitnow if AskYesNo("WARNING: Are you Sure :WARNING","CONTINUE???!!!??? %CR%Are you sure you can find your backups???")==@NO then goto nobackup if numfile > 0 then FileDelete(files) ;Whap top level files... If numdir1 == 0 Then Goto didit level=1 index1=0 :loop If index%level% == numdir%level% Then Goto upalevel index%level% = index%level% + 1 DirChange(StrCat(dir%level%, ItemExtract(index%level%, sub%level%, " "))) totdir=totdir+1 Errormode(@off) FileDelete("*.*") Errormode(@cancel) level = level + 1 dir%level% = DirGet() sub%level% = DirItemize("*.*") numdir%level% = ItemCount(sub%level%, " ") index%level% = 0 goto loop :upalevel a=strlen(dir%level%) ;7.0S-- bug workaround if a>3 then dir%level%=strsub(dir%level%,1,a-1) ;ditto DirChange(dir%level%) DirRemove(sub%level%) drop(dir%level%,sub%level%,index%level%,numdir%level%) level=level-1 if level!=0 then goto loop :didit SetDisplay("","","") OtherUpdate() Display(4,"Operation Complete","Files in %totdir% subdirectories deleted") goto done :noselect Message("Sorry", "You must highlight target files/directories first.") goto done :nobackup Message("Well Then","We better not play around with nuclear devices") goto done :quitnow Message("Good Thinking","A wise move. Nothing deleted") :done drop(files,numfile,dir1,numdir1,totdir) &Duplicate ENTIRE file/dir structure Other0=OtherDir() totdir=0 files=FileItemize("") numfile=ItemCount(files, " ") dir1=DirGet() OrigDir=strsub(dir1,1,1) ;7.0s-- bug workaround sub1 = DirItemize("") numdir1=Itemcount(sub1, " ") if (numfile+numdir1)==0 then goto noselect Other0=AskLine("Replicate structure",strcat(sub1,' ',files,CR,CR,"to"),Other0) terminate(Other0=="" || Other0==" ","Copy Error","Cannot copy to null file name") a=strsub(Other0,strlen(Other0),1) if (a!=":" && a!="\") then Other0=strcat(Other0,"\") if numfile > 0 then FileCopy(files,Other0,@FALSE) ;Copy top level files... If numdir1 == 0 Then Goto didit level=1 index1=0 ; debug(1) :loop If index%level% == numdir%level% Then Goto upalevel index%level% = index%level% + 1 DirChange(StrCat(dir%level%, ItemExtract(index%level%, sub%level%, " "))) totdir=totdir+1 a=level-1 Other%level%=StrCat(Other%a%,ItemExtract(index%level%, sub%level%, " "),"\") Errormode(@off) DirMake(Other%level%) LogDisk(Origdir) ;7.0s-- bug workaround FileCopy("*.*",Other%level%,@FALSE) Errormode(@cancel) level = level + 1 dir%level% = DirGet() sub%level% = DirItemize("*.*") numdir%level% = ItemCount(sub%level%, " ") index%level% = 0 goto loop :upalevel a=strlen(dir%level%) ;7.0S-- Workaround if a>3 then dir%level%=strsub(dir%level%,1,a-1) ;7.0S-- Workaround DirChange(dir%level%) drop(dir%level%,sub%level%,index%level%,Other%level%) level=level-1 if level!=0 then goto loop :didit SetDisplay("","","") OtherUpdate() Display(4,"Duplicate Structure Complete","%totdir% directories duplicated") goto done :noselect Message("Sorry", "You must highlight source files/directories first.") :done drop(files,numfile,dir1,numdir1,Other0) &Move ENTIRE file/dir structure Other0=OtherDir() totdir=0 files=FileItemize("") numfile=ItemCount(files, " ") dir1=DirGet() OrigDir=strsub(dir1,1,1) ;7.0s-- bug workaround sub1 = DirItemize("") numdir1=Itemcount(sub1, " ") if (numfile+numdir1)==0 then goto noselect Other0=AskLine("Move structure",strcat(sub1,' ',files,CR,CR,"to"),Other0) terminate(Other0=="" || Other0==" ","Move Error","Cannot move to null name") a=strsub(Other0,strlen(Other0),1) if (a!=":" && a!="\") then Other0=strcat(Other0,"\") if numfile > 0 then FileMove(files,Other0,@FALSE) ;Copy top level files... If numdir1 == 0 Then Goto didit level=1 index1=0 ; debug(1) :loop If index%level% == numdir%level% Then Goto upalevel index%level% = index%level% + 1 DirChange(StrCat(dir%level%, ItemExtract(index%level%, sub%level%, " "))) totdir=totdir+1 a=level-1 Other%level%=StrCat(Other%a%,ItemExtract(index%level%, sub%level%, " "),"\") Errormode(@off) DirMake(Other%level%) LogDisk(Origdir) ;7.0s-- bug workaround FileMove("*.*",Other%level%,@FALSE) Errormode(@cancel) level = level + 1 dir%level% = DirGet() sub%level% = DirItemize("*.*") numdir%level% = ItemCount(sub%level%, " ") index%level% = 0 goto loop :upalevel a=strlen(dir%level%) ;7.0S-- Workaround if a>3 then dir%level%=strsub(dir%level%,1,a-1) ;7.0S-- Workaround DirChange(dir%level%) DirRemove(sub%level%) drop(dir%level%,sub%level%,index%level%,Other%level%) level=level-1 if level!=0 then goto loop :didit SetDisplay("","","") OtherUpdate() Display(4,"Move Structure Complete","%totdir% directories moved") goto done :noselect Message("Sorry", "You must highlight source files/directories first.") :done drop(files,numfile,dir1,numdir1,Other0) &Size of ENTIRE file/dir structure tot = FileSize(FileItemize("")) totdir=0 level=1 dir1=DirGet() sub1 = DirItemize("") numdir1 = ItemCount(sub1, " ") index1 = 0 :loop If index%level% == numdir%level% Then Goto upalevel index%level% = index%level% + 1 DirChange(StrCat(dir%level%, ItemExtract(index%level%, sub%level%, " "))) totdir=totdir+1 tot = tot + FileSize(FileItemize("*.*")) level = level + 1 dir%level% = DirGet() sub%level% = DirItemize("*.*") numdir%level% = ItemCount(sub%level%, " ") index%level% = 0 goto loop :upalevel drop(dir%level%,sub%level%,index%level%,numdir%level%) level=level-1 if level!=0 then goto loop :done ; ----------- ; Termination ; ----------- If StrLen(tot) < 9 Then tot = StrCat(StrFill("", 9 - StrLen(tot)), tot) tot = StrCat(StrSub(tot,1,3),",",StrSub(tot,4,3),",",StrSub(tot,7,3)) tot = StrTrim(tot) If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1) tot = StrTrim(tot) If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1) tot = StrTrim(tot) Message("%totdir% Subdirecctories included", "Total size %tot% bytes.") drop(tot,level,totdir) _&Format Diskette... ; A wonderful example of variable substitution D1="1) 5.25 High Density (1.2M)" D2="2) 5.25 Standard (360K)" D3="3) 3.5 High Density (1.44M)" D4="4) 3.5 Standard (720K)" D0="0) None" DriveA=inireadpvt(CP,"DriveA","ASK",cpini) DriveB=inireadpvt(CP,"DriveB","ASK",cpini) if DriveA!="ASK" & DriveB!="ASK" then goto DOFORMAT DC="%D1%|%D2%|%D3%|%D4%|%D0%" Message("Attention","Command Post needs to learn what kind of floppies %CR% the system has. Please select accordingly.") :ASKA a=ItemSelect("Select type of Drive A",DC,"|") if a!="" then goto OKDRIVEA Message("You MUST select an option for A.","Please retry") goto ASKA :OKDRIVEA DriveA=strsub(a,1,1) iniwritepvt(CP,"DriveA",DriveA,cpini) :ASKB a=ItemSelect("Select type of Drive B",DC,"|") if a!="" then goto OKDRIVEB Message("You MUST select an option for B.","Please retry") goto ASKB :OKDRIVEB DriveB=strsub(a,1,1) iniwritepvt(CP,"DriveB",DriveB,cpini) :DOFORMAT A0="" A1="1) A: 5.25 HD (1.2M)|2) A: 5.25 DD (360K)" A2="2) A: 5.25 DD (360K)" A3="3) A: 3.5 HD (1.44M)|4) A: 3.5 Std (720K)" A4="4) A: 3.5 Standard (720K)" B0="" B1="5) B: 5.25 HD (1.2M)|6) B: 5.25 DD (360K)" B2="6) B: 5.25 Standard (360K)" B3="7) B: 3.5 HD (1.44M)|8) B: 3.5 DD (720K)" B4="8) B: 3.5 DD (720K)" FF=strcat(A%DriveA%,"|",B%DriveB%) drop(A0,A1,A2,A3,A4,B0,B1,B2,B3,B4) FF=ItemSelect("Choose Format Type Desired",FF,"|") terminate(FF=="","Format","No parameters selected") FF=strsub(FF,1,1) ; FF will be 1 thru 8 (with luck) DR=strsub("AB",(FF>4)+1,1) ; DR is desired drive FF=FF-((FF>4)*4) ; FF is 1 thru 4 F11="" F12="/4" F22="" F33="" F34="/n:9 /t:80" F44="" DC=Drive%DR% ; get drive type FC=F%DC%%FF% FC="%DR%: %FC%" DC=strsub(D%FF%,4,strlen(d%FF%)-3) Pause("Attention",strcat("Preparing to format %DC%",CR,"diskette in Drive %DR% with command:",CR,"FORMAT %FC%")) comspec=environment("COMSPEC") run(comspec,"/c format.com %FC%") drop(D0,D1,D2,D3,D4,DC,xxx,DriveA,DriveB) drop(FF,DR,F11,F12,F22,F33,F34,F44,DC,FC,comspec) _Directory &Tree run("%CPDIR%cp_tree.exe","") &View &Short SetDisplay("SHORT","","") MenuChange("ViewShort",@CHECK) MenuChange("ViewLong",@UNCHECK) iniwritepvt(CP,"ViewShortLong","SHORT",cpini) &Long SetDisplay("LONG","","") MenuChange("ViewShort",@UNCHECK) MenuChange("ViewLong",@CHECK) iniwritepvt(CP,"ViewShortLong","LONG",cpini) _&All SetDisplay("","","*.*") MenuChange("ViewAll",@CHECK) MenuChange("ViewPartial",@UNCHECK) MenuChange("ViewPrograms",@UNCHECK) iniwritepvt(CP,"ViewWhat","ALL",cpini) &Partial... a=inireadpvt(CP,"Partial","*.*",cpini) a=AskLine("View Partial","Enter types of files desired",a) iniwritepvt(CP,"Partial",a,cpini) SetDisplay("","",a) MenuChange("ViewAll",@UNCHECK) MenuChange("ViewPartial",@CHECK) MenuChange("ViewPrograms",@UNCHECK) iniwritepvt(CP,"ViewWhat","PARTIAL",cpini) P&rograms SetDisplay("","","*.EXE *.COM *.BAT *.PIF") MenuChange("ViewAll",@UNCHECK) MenuChange("ViewPartial",@UNCHECK) MenuChange("ViewPrograms",@CHECK) iniwritepvt(CP,"ViewWhat","PROGRAMS",cpini) _By &Name SetDisplay("","NAME","") MenuChange("ViewByName",@CHECK) MenuChange("ViewByDate",@UNCHECK) MenuChange("ViewBySize",@UNCHECK) MenuChange("ViewByKind",@UNCHECK) MenuChange("ViewUnsorted",@UNCHECK) iniwritepvt(CP,"ViewBy","NAME",cpini) By &Date SetDisplay("","DATE","") MenuChange("ViewByName",@UNCHECK) MenuChange("ViewByDate",@CHECK) MenuChange("ViewBySize",@UNCHECK) MenuChange("ViewByKind",@UNCHECK) MenuChange("ViewUnsorted",@UNCHECK) iniwritepvt(CP,"ViewBy","DATE",cpini) By Si&ze SetDisplay("","SIZE","") MenuChange("ViewByName",@UNCHECK) MenuChange("ViewByDate",@UNCHECK) MenuChange("ViewBySize",@CHECK) MenuChange("ViewByKind",@UNCHECK) MenuChange("ViewUnsorted",@UNCHECK) iniwritepvt(CP,"ViewBy","SIZE",cpini) By &Kind SetDisplay("","KIND","") MenuChange("ViewByName",@UNCHECK) MenuChange("ViewByDate",@UNCHECK) MenuChange("ViewBySize",@UNCHECK) MenuChange("ViewByKind",@CHECK) MenuChange("ViewUnsorted",@UNCHECK) iniwritepvt(CP,"ViewBy","KIND",cpini) &Unsorted SetDisplay("","UNSORTED","") MenuChange("ViewByName",@UNCHECK) MenuChange("ViewByDate",@UNCHECK) MenuChange("ViewBySize",@UNCHECK) MenuChange("ViewByKind",@UNCHECK) MenuChange("ViewUnsorted",@CHECK) iniwritepvt(CP,"ViewBy","UNSORTED",cpini) |&1 Stack winarrange(1) &2 Arrange winarrange(2) &3 Arrange in Rows winarrange(3) &4 Arrange in Columns winarrange(4) _&5 (w/o CP) Stack winiconize("") winarrange(1) &6 (w/o CP) Arrange winiconize("") winarrange(2) &7 (w/o CP) Arrange in Rows winiconize("") winarrange(3) &8 (w/o CP) Arrange in Cols winiconize("") winarrange(4) _Change &Wallpaper DirChange(DirWindows(0)) a=FileItemize("*.BMP") a=strcat("-None- ",a) a=ItemSelect("Select New Wallpaper",a," ") terminate(a=="","Wallpaper","No wallpaper selected") if a=="-None-" then Wallpaper("",0) if a=="-None-" then exit tile=@FALSE if FileSize(a)<40000 then tile=@TRUE ;if bmp size less than 40K, assume tile, else center Wallpaper(a,tile) drop(a,tile) &Main &Command Post (More Windows) a=IntControl(2,0,0,0,0) ; retrieves number of open CmdPost Windows if a==4 then goto posit DirChange(CPDIR) run("cmdpost.exe","") exit :posit IntControl(6,0,0,0,0) ;Repositions all open cp windows Command &Post (Show All Windows) IntControl(6,0,0,0,0) ;Repositions all open cp windows Control &Panel errormode(@off) terminate(winactivate("Control Panel"),"","") errormode(@cancel) run("control.exe","") C&lipboard errormode(@off) terminate(winactivate("Clipboard"),"","") ;Already Running errormode(@cancel) run("Clipbrd.exe","") &DOS Prompt run(Environment("COMSPEC"),"") _Get WIL &Help run("winhelp.exe","%CPDIR%wil.hlp") _Preferences Show System/Hidden Files a=strupper(inireadpvt(CP,"SysHide","0",cpini)) c="YES" if a==0 then c="NO" b=AskYesNo("System/Hidden Files","Show System and Hidden files?%CR%Current answer=%c%%CR%Enter desired answer") if a!=b then iniwritepvt(CP,"SysHide",b,cpini) IntControl(5,b,0,0,0) ;Controls system/hidden show flag SetDisplay("","","") Save CmdPost Window Positions c=IntControl(2,0,0,0,0) ;This guy returns # of CP Windows open b1="Do you wish to save the current CmdPost" b2="window positions for future startups?" b3="Note: You can save positions of combinations" b4="of 1, 2, 3, and 4 window positions." b5="Now saving window positions for %c% windows" b1=strcat(b1,CR,b2,CR,CR,b3,CR,b4,CR,b5) drop(b2,b3,b4,b5) a=AskYesNo("CmdPost Window Positions",b1) if a==@YES then IntControl(3,0,0,0,0) ;This causes all cp's to write exit ;their position information Printer Options iniwritepvt(CP,"TextPrinter","ASK",cpini) MenuChange("FilePrint",@ENABLE) b1="CmdPost's saved information reset." b2="You will be prompted to re-enter the" b3="necessary information when it is required." b1=strcat(b1,CR,b2,CR,b3) Message("Information Reset",b1) Floppy Options iniwritepvt(CP,"DriveA","ASK",cpini) iniwritepvt(CP,"DriveB","ASK",cpini) b1="CmdPost's saved information reset." b2="You will be prompted to re-enter the" b3="necessary information when it is required." b1=strcat(b1,CR,b2,CR,b3) Message("Information Reset",b1) Auto Run= and Load= Options a=strupper(inireadpvt(CP,"AutoStart","NO",cpini)) b=AskYesNo("Auto Startup from WIN.INI","Auto start from WIN.INI RUN= and LOAD= lines?%CR%Current answer=%a%%CR%Enter desired answer") if b==@YES then b=AskYesNo("Auto Startup from WIN.INI","Generally this option is set only%CR%when you make CmdPost your shell.%CR%Continue?") if b==@NO then b="NO" if b==@YES then b="YES" if a!=b then iniwritepvt(CP,"AutoStart",b,cpini) CmdPost Window Titles Window 1 c=strcat("Command Post ",version()," #") a=1 Title%a%=inireadpvt(CP,"Title%a%","%c%%a%",cpini) b=AskLine("CmdPost Title #%a%","Enter name of #%a% CmdPost window.",Title%a%) iniwritepvt(CP,"Title%a%",b,cpini) if WinExist(Title%a%) then WinTitle(Title%a%,b) Window 2 c=strcat("Command Post ",version()," #") a=2 Title%a%=inireadpvt(CP,"Title%a%","%c%%a%",cpini) b=AskLine("CmdPost Title #%a%","Enter name of #%a% CmdPost window.",Title%a%) iniwritepvt(CP,"Title%a%",b,cpini) if WinExist(Title%a%) then WinTitle(Title%a%,b) Window 3 c=strcat("Command Post ",version()," #") a=3 Title%a%=inireadpvt(CP,"Title%a%","%c%%a%",cpini) b=AskLine("CmdPost Title #%a%","Enter name of #%a% CmdPost window.",Title%a%) iniwritepvt(CP,"Title%a%",b,cpini) if WinExist(Title%a%) then WinTitle(Title%a%,b) Window 4 c=strcat("Command Post ",version()," #") a=4 Title%a%=inireadpvt(CP,"Title%a%","%c%%a%",cpini) b=AskLine("CmdPost Title #%a%","Enter name of #%a% CmdPost window.",Title%a%) iniwritepvt(CP,"Title%a%",b,cpini) if WinExist(Title%a%) then WinTitle(Title%a%,b) View Startup Options a=strupper(inireadpvt(CP,"ViewSetup","NO",cpini)) b=AskYesNo("Remember View options","Should View menu options be remembered?%CR%Current answer=%a%%CR%Enter desired answer") if b==@NO then b="NO" if b==@YES then b="YES" if a!=b then iniwritepvt(CP,"ViewSetup",b,cpini) Editor Options Editor=strtrim(strupper(AskLine("Editor Selection","Enter desired editor",Editor))) iniwritepvt(CP,"Editor",Editor,cpini) File Refresh On IniWritePvt(CP,"AutoUpdate",1,cpini) MenuChange("MainPreferencesFileRefreshOn",@CHECK) MenuChange("MainPreferencesFileRefreshOff",@UNCHECK) Off IniWritePvt(CP,"AutoUpdate",0,cpini) MenuChange("MainPreferencesFileRefreshOn",@UNCHECK) MenuChange("MainPreferencesFileRefreshOff",@CHECK) Default startup program a=IniRead("Extensions","*","Browser.exe") a=AskLine("Default startup program","Enter program to run for file when%CR%file extension is not defined",a) iniwrite("Extensions","*",a) _Run "Managers" P&rogram Manager errormode(@off) terminate(winactivate("Program Manager"),"","") ;Already Running errormode(@cancel) run("Progman.exe","") &File Manager errormode(@off) terminate(winactivate("File Manager"),"","") ;Already Running errormode(@cancel) run("winfile.exe","") Print &Manager run("printman.exe","") ; takes care of itself _Edit Configurations &Edit CmdPost menus CMDPOST.CPM DirChange(FilePath(FileLocate("%CPDIR%CMDPOST.CPM"))) a="CMDPOST.CPM" ;it it already running??? Find it... b=WinItemize() bup=StrUpper(b) c=ItemCount(bup,tab) d=0 :woop if c==d then goto doit d=d+1 e=itemextract(d,bup,tab) if strindex(e,a,0,@FWDSCAN)==0 then goto woop e=itemextract(d,b,tab) WinActivate(e) goto goombye :doit bup=strcat( FileRoot(a),".BAK") FileCopy(a,bup,@FALSE); run(Editor,a) :goombye drop(a,b,c,d,e,bup) CMDUSER.CPM DirChange(FilePath(FileLocate("%CPDIR%CMDPOST.CPM"))) a="CMDUSER.CPM" ;it it already running??? Find it... b=WinItemize() bup=StrUpper(b) c=ItemCount(bup,tab) d=0 :woop if c==d then goto doit d=d+1 e=itemextract(d,bup,tab) if strindex(e,a,0,@FWDSCAN)==0 then goto woop e=itemextract(d,b,tab) WinActivate(e) goto goombye :doit bup=strcat( FileRoot(a),".BAK") FileCopy(a,bup,@FALSE); run(Editor,a) :goombye drop(a,b,c,d,e,bup) Edit &INI files DirChange(DirWindows(0)) canned="BYEBYE" IniFiles="" :UP1 canned="byebye" If IniFiles!="" then goto inied IniFiles=FileItemize("*.INI") :inied TheFile=ItemSelect("Choose Desired INI file",IniFiles," ") if TheFile=="" then goto newini Sections="" :UP2 canned="up1" if Sections!="" then goto sected Sections=IniItemizePvt("",TheFile) :SECTED Section=ItemSelect("%TheFile% - Choose Section",Sections,TAB) if Section=="" then goto AddSect KeyValues="" :UP3 canned="up2" if KeyValues!="" then goto looped Keys=IniItemizePvt(Section,TheFile) KeyMax=ItemCount(Keys,TAB) KeyIndex=0 :Loop if KeyIndex==KeyMax then goto looped KeyIndex=KeyIndex+1 ThisKey=ItemExtract(KeyIndex,Keys,TAB) ThisValue=IniReadPvt(Section,ThisKey,"???",TheFile) KeyValues=strcat(KeyValues,ThisKey,"= ",ThisValue,TAB) goto Loop :looped Key=ItemSelect("%TheFile% [%Section%] - Choose Keyword",KeyValues,TAB) if Key=="" then goto AddKey Key=ItemExtract(1,Key,"=") Value=IniReadPvt(Section,Key,"???",TheFile) goto entkey :newini canned="UP1" TheFile=Askline("Making NEW INI file","Enter new INI file name","*.INI") if (TheFile=="*.INI" || TheFile=="") then goto newini IniFIles="" goto AddSectNewIni :AddSect canned="up2" :AddSectNewIni Section=AskLine("Add New Section to INI File","Enter new section name for%CR% %TheFile%%CR% [?????]","") Sections="" goto AddKeyNewSect :AddKey canned="up3" :AddKeyNewSect Key=AskLine("Add New Keyword to INI File","Enter new key name for%CR% %TheFile%%CR% [%Section%]","") Value="(Undefined)" KeyValues="" goto EntKeyNewKey :ENTKEY canned="up3" :EntKeyNewkey NewValue=AskLine("Modify INI File Keyword","%TheFile%%CR% [%Section%]%CR% %Key% = %Value%",Value) if NewValue!=Value then iniwritepvt(Section,Key,NewValue,TheFile) KeyValues="" goto up3 :CANCEL goto %Canned% :BYEBYE exit Run System Confi&guration Editor run("sysedit.exe","") ;takes care of itself Run Windows Setup DirChange(DirWindows(0)) run("setup.exe","") drop(a) Restart Windows NO! Wait Display(4,"OK","I'll wait") Really! Doit! IntControl(66,0,0,0,0) _PIF Edi&t... a=strupper(FileExtension(CurrentFile())) if a!="PIF" then goto PIF2 run("pifedit.exe",CurrentFile()) exit :PIF2 if IsKeyDown(@SHIFT)==@YES then DirChange(FilePath(FileLocate("_default.pif"))) a=FileItemize("*.PIF") if a=="" then DirChange(FilePath(FileLocate("_default.pif"))) if a=="" then a=FileItemize("*.PIF") a=ItemSelect("Choose a PIF File to edit",a," ") run("pifedit.exe",a) exit _&System Information wintype="retail" if WinMetrics(22) then wintype="debug" wc=WinConfig() if !(wc&1) then mode="Real" if wc&16 then mode="Standard" if wc&32 then mode="Enhanced" if wc&2 then cpu=286 if wc&4 then cpu=386 if wc&8 then cpu=486 if wc&64 then cpu=8086 if wc&128 then cpu=80186 Sysinfo=strcat(cpu,' ',mode,' ',wintype,' Windows ',WinVersion(1),'.',WinVersion(0),CR) math="No math" if wc&1024 then math="Math" mouse="No Mouse" if WinMetrics(19) then mouse="Mouse" Sysinfo=strcat(sysinfo,math," co-processor. ",mouse,' available.',CR) sysinfo=strcat(sysinfo,WinMetrics(0),'x',WinMetrics(1)," video resolution. ",WinMetrics(-1)," colors.",CR) ErrorMode(@OFF) LastError() PlayMedia("Status WaveForm Ready") ErrorMode(@CANCEL) if LastError()!=1193 then sysinfo=strcat(sysinfo,"Windows multimedia extensions present.",CR) bug=NetGetCaps(2) if bug==0 then math="No n" if bug!=0 then math="N" if bug==256 then math="Microsoft n" if bug==512 then math="Lan Manager n" if bug==768 then math="Novell NetWare n" if bug==1024 then math="Banyan Vines n" if bug==1280 then math="10 Net n" sysinfo=strcat(sysinfo,math,"etwork installed.",CR) bug=WinResources(0)/1024 ; Compute memory avail math=strlen(bug) if math>3 then bug=strcat(strsub(bug,1,math-3),',',strsub(bug,math-2,3)) sysinfo=strcat(sysinfo,CR,bug," KB Free Memory",CR) sysinfo=strcat(sysinfo,WinResources(2),"%% System Resources Free (",WinResources(3),"%% GDI, ",WinResources(4),"%% User)",CR) sysinfo=strcat(sysinfo,"DOS ",DosVersion(1),'.',DosVersion(0)," using ",environment("COMSPEC"),CR) disks=DiskScan(1) if disks!="" then sysinfo=strcat(sysinfo,"Floppies ",disks,CR) disks=DiskScan(2) if disks!="" then sysinfo=strcat(sysinfo,"Hard Disks ",disks,CR) disks=DiskScan(4) if disks!="" then sysinfo=strcat(sysinfo,"Network Disks ",disks,CR) sysinfo=strcat(sysinfo,"Windows Directory ",DirWindows(0),CR) sysinfo=strcat(sysinfo,"System Directory ",DirWindows(1),CR) ver=Version() Message("Command Post %ver% SysInfo",Sysinfo)