@echo off :: :: :: Insert a tagline into the tearline of a message! :: By: Douglas King :: :: February 15, 1994 :: This puppy first inserted a tagline into a message at about 7:00am :: on February 17, 1994! It took the <, >, /, \ and [ ] chars no prob! :: on error gosub wait echo %_env bytes free in environment. iff %_env LE 610 then echo Adjusting environment size, one moment... %comspec% //Envfree=650 /c %0& quit endiff setlocal unalias * :: quick check to make sure that 4dos 5.0 is here... if %_4ver LT 5.0 (set error=6^goto use_message) :: check the status of the system with relations to the setdos command. :: Save a copy of the SetDos info into the variable %setdos. gosub checkstate :: Now that the setdos status is nicely saved, insure that it is compatable :: with this batch file. setdos /x-58 setdos /x0 /c^ /p& /e /m1 set dunno=%@unique[%_cwds] ::Check that the current version and revision level is up to snuff :: for the processing we'll be doing. gosub checkver set offset=165 set tagline= set tagfile=%_cwds%tagline. set header=%@unique[%_cwds] set lead=... 4Tag: ::check for commandline switches gosub checkswitch :: Make sure that all the files needed to run this batch are :: present. If not, exit with an errorlevel. gosub checkfile on break goto breaker if "%auto." == "1." goto AutoMatic gosub makescreen ( Echo Yes, I surely do! ^ Echo No, that would be horrid! ) | set ans=%@select[Con,5,10,10,44,Want to Add a Tagline?] if "%@instr[0,3,%ans]" != "Yes" goto wantquit :choosetag setdos /X0 Echo Write a new tagline > %header Echo Sort Taglines >> %header Echo No Tagline Please >> %header Echo Choose a tagline from the master list >> %header iff %random != -1 then echo. >> %header set lin=%@line[%tagfile,%random] set c=%@fileopen[%header,append] set check=%@fileseek[%c,0,2] setdos /x-45678 set check=%@filewrite[%c,%lin] setdos /x0 set check=%@fileclose[%c] unset /q c check lin >& nul else goto selecttag endiff if %random != -1 keystack Down Down Down Down Down :adminmenu setdos /x-4568 set tagline=%@select[%header,3,3,22,77,Your selection please!] iff "%tagline" == "" then beep 880 1 goto choosetag endiff if "%tagline" == "Write a new tagline" goto write iff "%tagline" == "Sort Taglines" then gosub sortit goto choosetag endiff if "%tagline" == "No Tagline Please" goto wantquit if "%tagline" == "Choose a tagline from the master list" goto selecttag set tagline=%lead %tagline setdos /X0 goto DoIt :selecttag setdos /x-4568 set tagline=%@select[%tagfile,3,3,22,77,Choose your Tagline! (Esc to goto admin menu)] if "%tagline." == "." goto adminmenu screen 22 3 set tagline=%lead %tagline setdos /x0 goto DoIt :write set tagline= :writeloop gosub makescreen setdos /x-4568 scrput 10 4 white on blue Enter your New Tagline, or ---Quit to stop. on break goto wrtbreak screen 11 5 %@repeat[±,70] color bri whi on blu screen 11 5 input /C /L70 %edit %%tagline screen 0 0 *%tagline%* iff %@trim["%tagline"] == "---Quit" then gosub makescreen goto choosetag endiff gosub makescreen screen 5 10 Is this the way you want your new tagline to appear: scrput 7 5 bri whi on blu %tagline setdos /x0 ( Echo Yes, I Love It! ^ Echo No, absolutely NOT! ) | set ans=%@select[Con,9,10,14,44,Accept new Tagline?] iff "%@instr[0,3,%ans]" != "Yes" then set edit=/E goto writeloop else setdos /x-45678 set c=%@fileopen[%tagfile,append] set check=%@fileseek[%c,0,2] set check=%@filewrite[%c,%tagline] set tagline=%lead %tagline set check=%@fileclose[%c] setdos /x0 endiff on break gosub showenv ( Echo Yes, Sort away! ^ Echo No, I can't waste the time! ) | set ans=%@select[Con,11,12,16,46,Sort Taglines now?] if "%@instr[0,3,%ans]" == "Yes" gosub sortit ( Echo Yes, Use it Now! ^ Echo No, I'll pick another. ) | set ans=%@select[Con,12,14,17,48,Use Tagline now?] iff "%@instr[0,3,%ans]" != "Yes" then goto choosetag else setdos /x0 goto DoIt endiff echo Tagline write traps failed. goto generror :sortit echo on setdos /x0 sort < %tagfile > %dunno copy %dunno %tagfile >& nul copy nul %dunno >& nul echo off return :wrtbreak gosub makescreen beep 440 2 drawbox 10 6 15 74 2 White on Red Zoom Shadow scrput 12 19 bri whi on red Choose No Tagline Please to exit 4tag.btm scrput 13 15 whi on red Press any key to continue, or wait a few seconds. inkey /w15 %%ans gosub makescreen goto choosetag :makescreen cls white on blue drawbox 1 1 24 79 2 Bri Whi on Blu :: drawbox 1 1 24 79 2 Bri Whi on Blu Zoom Shadow scrput 1 28 Bri Whi on Blu µ 4Dos Tagline Manager Æ scrput 24 28 Bri Whi on Blu µ By: Douglas D. King Æ return :AutoMatic ::Fully AutoMatic Mode set random=%@random[0,%@eval[%@lines[%tagfile]-1]] set tagline=%@line[%tagfile,%random] set tagline=%lead %tagline goto doit :checkswitch set cmdl=%& set word=%@word[0,%cmdl] set count=0 :loop2 if "%word" == "" goto end2 if "%@instr[0,3,%word]" == "/T:" set tagfile=%@full[%@instr[3,100,%word]] if "%@instr[0,9,%word]" == "/TagFile:" set tagfile=%@full[%@instr[9,100,%word]] if "%@instr[0,5,%word]" == "/A" set Auto=1 if "%@instr[0,6,%word]" == "/Auto" set Auto=1 if "%@instr[0,3,%word]" == "/O:" set offset=%@eval[%@instr[3,20,%word]] if "%@instr[0,8,%word]" == "/Offset:" set offset=%@eval[%@instr[8,20,%word]] if "%@instr[0,3,%word]" == "/R" set random=1 if "%@instr[0,8,%word]" == "/Random" set random=1 if "%@instr[0,1,%word]" != "/" .AND. "%infile." == "." set infile=%@full[%word] iff "%@instr[0,5,%word]" == "/PID" then set pid=1 set lead=... endiff set count=%@inc[%count] set word=%@word[%count,%cmdl] goto loop2 :end2 if "%random" == "1" set random=%@random[0, %@eval[ %@lines[ %tagfile ] - 1 ] ] if "%random." == "." set random=-1 return echo error! please make sure all file's are closed! quit :DoIt on break gosub showenv setdos /X0 iff "%auto." == "1." then alias screen :: alias echo :: alias scrput :: alias drawbox :: endiff setdos /X-4568 If "%pid." NE "1." goto puttag screen 20 5 Please wait, Inserting Product ID code into message. screen 21 3 Completion indicator: screen 22 5 %@repeat[±,70] set total=%@lines[%infile] set cur=1 set msg=%@fileopen[%infile,read] set dunno2=%@unique[%_cwds] set out=%@fileopen[%dunno2,write] set pid2=%@char[1]PID2: 4Tag.btm 1.0 set lin=%@fileread[%msg] iff "%@ascii[%@instr[0,1,%lin]]" != "1" then set pid=2 set check=%@filewrite[%out,%pid2] endiff do While "%lin" != "**EOF**" if "%@instr[0,5,%lin]" != "@PID2" set check=%@filewrite[%out,%lin] set lin=%@fileread[%msg] screen 22 5 %@repeat[°,%@eval[%cur/(%total+1)*70]] set cur=%@inc[%cur] iff %pid eq 1 .AND. "%@instr[0,1,%lin]" NE "%@char[1]" then set check=%@filewrite[%out,%pid2] set pid=2 endiff enddo set check=%@fileclose[%msg] set check=%@fileclose[%out] setdos /x6 copy %dunno2 %infile >& nul del %dunno2 >& nul unset /q check dunno2 out drawbox 20 3 22 75 2 blue on blue fill blue :puttag screen 20 5 One moment... Inserting tagline. unalias * setdos /x-4568 set msg=%@fileopen[%infile,read] set big=%@filesize[%infile,b] ::taglines are at the end of the file... Look for the tearline at the end. iff %big GT %offset then set tst=%@fileseek[%msg, %@eval[ %big - %offset ],0] else set tst=%@fileseek[%msg,0,0] endiff :loop set pos=%@fileseek[%msg,0,1] set lin=%@fileread[%msg] if "%@instr[0,3,%lin]" EQ "---" goto found if "%lin" == "**EOF**" goto notear goto loop :found set tearline=%lin set origin=%@fileread[%msg] if %@fileclose[%msg] NE 0 goto cmsgError set msg=%@fileopen[%infile,append] set posi=%@fileseek[%msg,%pos,0] set check=%@filewrite[%msg, ] if check EQ -1 goto wmsgerror set check=%@filewrite[%msg,%tagline] if check EQ -1 goto wmsgerror set check=%@filewrite[%msg,%tearline] if check EQ -1 goto wmsgerror iff "%origin" != "**EOF**" then set check=%@filewrite[%msg,%origin] if check EQ -1 goto wmsgerror endiff if %@fileclose[%msg] NE 0 goto emsgError goto done :notear if %@fileclose[%msg] NE 0 goto cmsgError set msg=%@fileopen[%infile,append] set posi=%@fileseek[%msg,0,2] set check=%@filewrite[%msg,%tagline] if check EQ -1 goto wmsgerror if %@fileclose[%msg] NE 0 goto emsgError :done setdos /x0 gosub makescreen ( Echo But, of course! ^ Echo No, all done. ) | set ans=%@select[Con,5,10,10,44,Add ANOTHER Tagline?]% if "%@instr[0,3,%ans]" != "But" (cls^goto goodend) goto selecttag :checkfile if "%1." == "." .OR. "%1" == "/?" .OR. "%1" == "-?" .OR. "%1" == "?" (set error=3^goto use_message) setdos /x0 if not exist %infile goto bad_message if not exist %tagfile goto bad_tagfile if exist %dunno del %dunno >& nul return :checkver ver /r > %dunno set vers=%@eval[%@instr[5,3,%@line[%dunno,1]]] set revision=%@instr[14,1,%@line[%dunno,2]] echo Running under 4dos version %vers, revision: %revision echo. if %vers EQ 5 .and. "%revision" LT "C" (set error=6^goto use_message) if %vers LT 5 (set error=6^goto use_message) del %dunno >& nul unset /q dunno vers revision return :checkstate :: let people with an ansi Driver know that it'll be a few seconds iff %_ansi == 1 then cls white on black echo Please Wait a moment... Determining system configuration endiff :: we gotta put some ugly stuff on the screen, so black it out. color black on black if "%SETDOS%" == "/X0" goto setdosx0 :: check for setdos /X-3 set temp=hello set temp1=%%temp iff "%temp" != "hello" then setdos /x3 set setdos=3 endiff :: check for setdos /X-4 iff "%temp1" != "hello" then setdos /x4 set setdos=%setdos%4 endiff unset /q temp temp1 :: get a unique file name and use it in testing. Make sure to delete :: the 0 byte file this function creates. set dunno=%@unique[%_cwds] del %dunno :: check for setdos /X-5 echo Howdy! %+ copy nul %dunno iff not exist %dunno then setdos /x5 set setdos=%setdos%5 else del %dunno endiff :: check for setdos /X-6 echo hello > %dunno iff not exist %dunno then setdos /x6 set setdos=%setdos%6 else del %dunno endiff :: check for /X-7 and /X-8 setdos > %dunno set tempdos=%@line[%dunno,5] set tempdos=%@instr[10,20,%tempdos] if %tempdos != 0 set setdos=%setdos%%tempdos% if "%setdos." == "." set setdos=/X0 unset /q tempdos if "%setdos." != "/X0." set setdos=/X-%setdos :setdosx0 setdos /x0 setdos /x-58 ::Ansi set tempdos=%@instr[5,1,%@line[%dunno,0]] set setdos=/A%tempdos %setdos :: BrightBg set tempdos=%@instr[9,1,%@line[%dunno,1]] set setdos=/B%tempdos %setdos :: Compound set tempdos=%@instr[9,1,%@line[%dunno,2]] set setdos=/C%tempdos %setdos :: Description Processing set tempdos=%@substr[%@line[%dunno,3],13,1] set setdos=/D%tempdos %setdos :: Escape Character set tempdos=%@instr[7,1,%@line[%dunno,4]] set setdos=/E%tempdos %setdos :: Line Input set tempdos=%@instr[6,1%@line[%dunno,7]] set setdos=/L%tempdos %setdos :: Edit Mode set tempdos=%@instr[5,1,%@line[%dunno,8]] set setdos=/M%tempdos %setdos :: NoClobber set tempdos=%@instr[10,1,%@line[%dunno,9]] set setdos=/N%tempdos %setdos :: Parameters Character... set tempdos=%@instr[11,1,%@line[%dunno,10]] set setdos=/P%tempdos %setdos :: Rows on Screen set tempdos=%@instr[5,3,%@line[%dunno,11]] set setdos=/R%tempdos %setdos :: Cursor Shape set tempdos=%@instr[18,5,%@line[%dunno,12]] set setdos=%setdos /S%tempdos set tempdos=%@instr[14,5,%@line[%dunno,13]] set setdos=%setdos%:%tempdos :: Upper Case set tempdos=%@instr[11,1,%@line[%dunno,14]] set setdos=/U%tempdos %setdos :: Verbose set tempdos=%@instr[8,1,%@line[%dunno,15]] set setdos=/V%tempdos %setdos :: Single Step set tempdos=%@instr[11,1,%@line[%dunno,17]] set setdos=/Y%tempdos %setdos del %dunno unset /q dunno tempdos cls white on black setdos /x0 setdos /x-58 setdos %setdos return :restorestate setdos /x0 setdos /x-58 setdos %setdos return :bad_tagfile set file=tag file set var=%%tagfile set error=4 goto tagmessage :bad_message set file=message set error=5 :tagmessage cls white on black echo The %file name, "%@upper[%var]", is not valid. echo. echo Is it a valid DOS filename? echo Does this file exist? echo. echo Do you want a dos shell before returning to your message editor. echo This will give you a chance to check that the filename is echo correct. inkey /k"YyNn" /w20 Take a DOS Shell? (Y/N) %%ans iff "%ans" == "y" then set sprompt=%prompt prompt Type Exit to return to 4Tag and your message reader.$_%prompt gosub restorestate %comspec% prompt %prompt unset /q sprompt setdos /x0 setdos /x-58 setdos /x0 /c^ /p& /e /m1 echos Welcome back to 4Tag.btm. endiff echo Returning to message reader. goto goodend :use_message cls white on black text °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° ° 4Tag.btm ° ° By Douglas King, 1:163/543.1 ° ° ° °4Tag is a 4Dos 5.0 and up compatable Batch file. It is used to insert ° ° a tagline in messages written on mail readers like TimEd, GoldEd, and° ° MsgEdit. ° ° ° °To run, 4Tag must be supplied with a message to insert a tagline into. ° ° This message may or may not have a tearline. If it does not have a ° ° tearline, the tagline is simply appended onto the end of the file. ° ° If it does have a tearline, the tagline will be inserted before the ° ° tearline. ° ° ° °USAGE: ° ° 4Tag.btm MessageFile [switches] ° ° ° ° MessageFile: This file contains the message just writtin with an ° ° external editor. ° ° ° °Press any key for next page. ° °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° endtext inkey %%ans cls text °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° ° 4Tag.btm ° ° By Douglas King, 1:163/543.1 ° ° ° °USAGE: ° ° 4Tag.btm MessageFile [switches] ° ° ° ° Valid Switches are: ° ° /R /Random --- Randomly select a tagline. ° ° /A /Auto --- Run in fully automatic mode. A tagline is ° ° randomly chosen and inserted with no user input. ° ° /T: /Tagfile: --- Source file for the taglines. Default: .\tagline° ° /O: /Offset: --- Start looking for the tearline nn bytes from the ° ° end of the message. This is normally not used.° ° /PID --- Inserts a kludge line @PID2:4tag.btm 1.0 in the ° ° Message and sets the tagline to ...: instead ° ° of ...4Tag: Please note that the /PID option ° ° is much slower. Try it on for size. ° ° ° °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° endtext goto goodend :generror set error 2 echo An error occured, please use stepper.com to trace to the error. echo Also, ensure ALL files are closed. Tnx. on error rem goto goodend :cmsgerror set error=1 echo an error occured closing the first instance of %infile goto goodend :emsgerror set error=1 echo an error occured closing the second instance of %infile goto goodend :wmsgerror set error=1 echo an error occured whilst writing to %infile goto goodend :breaker echo BREAK! echo closing filehandle %msg with errorlevel %@fileclose[%msg] echo BREAK! set error=0 goto goodend :WantQuit cls echo Tagline Manager terminated at your request! set error=0 goto goodend :goodend on error echos setdos /x0 if exist %header del %header >& nul if exist %dunno del %dunno >& nul if "%error" == "" set error=0 echo Ending 4Tag.btm with Errorlevel %error. gosub restorestate quit %error :wait pause an error has occured! return :showenv set /p pause environment free: %_env, press any key. return