home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1991-10-02 | 41.8 KB | 1,179 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. a=Version() CP="CmdPost" CPDIR=DirHome() crlf=strcat(num2char(13),num2char(10)) cpini="WWW-PROD.INI" tab=num2char(9) Editor=inireadpvt(CP,"Editor","Notepad.exe",cpini) CopyMoveDefault="" ; 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) ; Setup Print menu item...Kill it if no text printer :PRINTSETUP MenuChange("FilePrint", (inireadpvt(CP,"TextPrinter","",cpini)=="NONE") *@DISABLE) ; 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. ; ; multiple startups ignored. if IsRunning() then goto goombye a=inireadpvt(CP,"AutoStart","YES",cpini) if a!="YES" then goto goombye ;if Display(3,"Auto Startup","Hit any key to bypass WIN.INI%crlf%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 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,crlf,crlf,"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,crlf,crlf,"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("") g=DirItemize("") b=0 if strlen(g)!=0 then b=AskYesNo("!!! Warning !!! ",strcat("Delete files from these directories too?",crlf,g)) if b!=0 then f=strcat(g," ",f) terminate(strlen(f)==0,"delete","No files specified") if !IsKeyDown(@SHIFT) then if askyesno("Delete",f)==@NO then exit 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.",crlf,"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,crlf,crlf,"to"),TextPrinter) FileCopy(s,a,@FALSE) _File &Info a=FileItemize("") terminate(a=="","File Stats","No Files Selected") 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 Drives NextDrive="C" ;ASSUMES C is your first hard drive. TotalSize=0 DriveReport="" ErrorMode(@off) :COUNTSPACE ; Start with do C drive a=DiskFree(NextDrive)/1024 TotalSize=a+TotalSize DriveReport=strcat(DriveReport,NextDrive," = ",a,"K","@") :TRYNEXT NextDrive=num2char(char2num(NextDrive)+1) if NextDrive=="Z" then goto DATOTAL if LogDisk(NextDrive) then goto COUNTSPACE goto TRYNEXT :DATOTAL 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","") b=FileLocate(a) terminate(b=="",a,"File Not Located") if AskYesNo(b,"File Located.%crlf%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," ") 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,crlf,b,crlf,c,crlf,"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,crlf,b,crlf,c,crlf,"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 DialogBox("View/Modify Attributes","cp_attr2.dlg") If OldHD!=HD then b=AskYesNo("Attribute Changer","Note: Changing Hidden attribute is unusual%crlf%Continue?") if b==@NO then goto REDO If OldSy!=SY then b=AskYesNo("Attribute Changer","Note: Changing System attribute is unusual%crlf%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 DialogBox("Attribute Changer","cp_attr1.dlg") If HD!=3 then b=AskYesNo("Attribute Changer","Note: Selecting Hidden attribute is unusual%crlf%Continue?") if b==@NO then goto REDO If SY!=3 then b=AskYesNo("Attribute Changer","Note: Selecting System attribute is unusual%crlf%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("")))) _&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(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(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%crlf%containing possibly 10 zillion files and subdirs.%crlf%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???!!!??? %crlf%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,crlf,crlf,"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,crlf,crlf,"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 %crlf% 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%",crlf,"diskette in Drive %DR% with command:",crlf,"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(FilePath(FileLocate("WIN.INI"))) 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) if a==1 then goto runner if a==4 then goto posit a=Display(3,"%a% CmdPost Windows exist","Hit any key to just position%crlf%existing windows") if a==1 then goto posit :runner DirChange(CPDIR) run("cmdpost.exe","") exit :posit 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 &Help Cardfile run("cardfile.exe","%CPDIR%cp_help.crd") Get &Question 'n' Answer Cardfile run("cardfile.exe","%CPDIR%cp_quest.crd") 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?%crlf%Current answer=%c%%crlf%Enter desired answer") if a!=b then iniwritepvt(CP,"SysHide",b,cpini) IntControl(5,b,0,0,0) ;Controls system/hidden show flag SetDisplay("","","") Set Blanker/Clock Options a=inireadpvt(CP,"BlankTime",5,cpini) b1="Enter screen blanker delay time" b2="or 0 to disable blanker" b3="or negative time to disable clock" b4="or 9999 to eliminate it altogether" b1=strcat(b1,crlf,b2,crlf,b3,crlf,b4) a=AskLine("Screen Blanker",b1,a) iniwritepvt(CP,"BlankTime",a,cpini) ErrorMode(@OFF) WinClose("CmdPost Clock") ErrorMode(@CANCEL) if a!=9999 then run("%CPDIR%CP_BLNK.EXE",a) 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,crlf,b2,crlf,crlf,b3,crlf,b4,crlf,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,crlf,b2,crlf,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,crlf,b2,crlf,b3) Message("Information Reset",b1) Auto Run= and Load= Options a=strupper(inireadpvt(CP,"AutoStart","YES",cpini)) b=AskYesNo("Auto Startup from WIN.INI","Auto start from WIN.INI RUN= and LOAD= lines?%crlf%Current answer=%a%%crlf%Enter desired answer") 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?%crlf%Current answer=%a%%crlf%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%crlf%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(FilePath(FileLocate("WIN.INI"))) a=FileItemize("*.INI") a=ItemSelect("Select INI file to edit",a," ") terminate(a=="","Edit","No file selected") ;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) Run System Confi&guration Editor run("sysedit.exe","") ;takes care of itself Run Windows Setup a=FilePath(Filelocate("system.ini")) DirChange(a) 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 run("%CPDIR%cp_info.exe","")