Re: [Freedos-devel] .BAT tricks (%RANDOM%, ANSI escapes in %PROMPT%)
Hi, On Tue, Jul 26, 2011 at 2:30 AM, Jim Michaels wrote: > > I seem to remember a DOS driver called NNANSI.SYS some time ago which gave > the console ANSI escape sequences. I presume you mean this (now GPL): http://almy.us/dospage.html -- Magic Quadrant for Content-Aware Data Loss Prevention Research study explores the data loss prevention market. Includes in-depth analysis on the changes within the DLP market, and the criteria used to evaluate the strengths and weaknesses of these DLP solutions. http://www.accelacomm.com/jaw/sfnl/114/51385063/ ___ Freedos-devel mailing list Freedos-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-devel
Re: [Freedos-devel] .BAT tricks (%RANDOM%, ANSI escapes in %PROMPT%)
I seem to remember a DOS driver called NNANSI.SYS some time ago which gave the console ANSI escape sequences. - Jim Michaels jmich...@yahoo.com j...@jimscomputerrepairandwebdesign.com http://JimsComputerRepairandWebDesign.com http://JesusnJim.com (my personal site, has software) --- Computer memory/disk size measurements: [KB KiB] [MB MiB] [GB GiB] [TB TiB] [10^3B=1,000B=1KB][2^10B=1,024B=1KiB] [10^6B=1,000,000B=1MB][2^20B=1,048,576B=1MiB] [10^9B=1,000,000,000B=1GB][2^30B=1,073,741,824B=1GiB] [10^12B=1,000,000,000,000B=1TB][2^40B=1,099,511,627,776B=1TiB] Note: disk size is measured in MB, GB, or TB, not in MiB, GiB, or TiB. computer memory (RAM) is measured in MiB and GiB. > >From: Rugxulo >To: freedos-devel >Sent: Monday, July 25, 2011 2:51 PM >Subject: Re: [Freedos-devel] .BAT tricks (%RANDOM%, ANSI escapes in %PROMPT%) > >Hi, > >On Thu, Jul 21, 2011 at 7:59 PM, Rugxulo wrote: >> On Thu, Jul 21, 2011 at 2:49 PM, Rugxulo wrote: >>> >>> A better way could definitely be done in a variety of languages >>> (BWBASIC? DEBUG?). > >Just for completeness, I did whip up a quick 8086 asm snippet for >DEBUG. (I actually tried doing a 7-bit ASCII executable version, but >it proved too tricky for the moment, so I've shelved that "weird" idea >for now, heh. I could've just used UBE or COMT or whatever tools >already exist, or even searched FASM's forum for inspiration, but I >guess it's not too important unless somebody didn't already have >DEBUG.) > >P.S. Timo's BAT FAQ wasn't as exhaustive as I thought. The only >interesting trick was doing something like "echo. exit | command /c >prompt set blah=$t", which still would've needed some fiddling with an >external tool (esp. one not typically included in DOSes), so I didn't >bother too hard thinking about that. But even he often uses sed or awk >(or QBASIC) for some tricks. So I still don't think it's a horrible >idea to include one (or both!) of those for FD 2.0 (or whatever). > > >@echo off >if not exist %0 %0.bat >debug < %0 >goto end >n rand4.com >rcx 20 >a 100 >mov ah,2C >int 21 >xor ax,ax >mov al,dl >and al,3 >inc ax >cmp al,0A >sbb al,69 >das >xchg ax,dx >mov ah,2 >int 21 >ret > >w >Q >:end > >-- >Storage Efficiency Calculator >This modeling tool is based on patent-pending intellectual property that >has been used successfully in hundreds of IBM storage optimization engage- >ments, worldwide. Store less, Store more with what you own, Move data to >the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/ >___ >Freedos-devel mailing list >Freedos-devel@lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/freedos-devel > > >-- Magic Quadrant for Content-Aware Data Loss Prevention Research study explores the data loss prevention market. Includes in-depth analysis on the changes within the DLP market, and the criteria used to evaluate the strengths and weaknesses of these DLP solutions. http://www.accelacomm.com/jaw/sfnl/114/51385063/___ Freedos-devel mailing list Freedos-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-devel
Re: [Freedos-devel] .BAT tricks (%RANDOM%, ANSI escapes in %PROMPT%)
Hi, On Thu, Jul 21, 2011 at 7:59 PM, Rugxulo wrote: > On Thu, Jul 21, 2011 at 2:49 PM, Rugxulo wrote: >> >> A better way could definitely be done in a variety of languages >> (BWBASIC? DEBUG?). Just for completeness, I did whip up a quick 8086 asm snippet for DEBUG. (I actually tried doing a 7-bit ASCII executable version, but it proved too tricky for the moment, so I've shelved that "weird" idea for now, heh. I could've just used UBE or COMT or whatever tools already exist, or even searched FASM's forum for inspiration, but I guess it's not too important unless somebody didn't already have DEBUG.) P.S. Timo's BAT FAQ wasn't as exhaustive as I thought. The only interesting trick was doing something like "echo. exit | command /c prompt set blah=$t", which still would've needed some fiddling with an external tool (esp. one not typically included in DOSes), so I didn't bother too hard thinking about that. But even he often uses sed or awk (or QBASIC) for some tricks. So I still don't think it's a horrible idea to include one (or both!) of those for FD 2.0 (or whatever). @echo off if not exist %0 %0.bat debug < %0 goto end n rand4.com rcx 20 a 100 mov ah,2C int 21 xor ax,ax mov al,dl and al,3 inc ax cmp al,0A sbb al,69 das xchg ax,dx mov ah,2 int 21 ret w Q :end -- Storage Efficiency Calculator This modeling tool is based on patent-pending intellectual property that has been used successfully in hundreds of IBM storage optimization engage- ments, worldwide. Store less, Store more with what you own, Move data to the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/ ___ Freedos-devel mailing list Freedos-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-devel
Re: [Freedos-devel] .BAT tricks (%RANDOM%, ANSI escapes in %PROMPT%)
Hi again, On Thu, Jul 21, 2011 at 2:49 PM, Rugxulo wrote: > > A better way could definitely be done in a variety of languages > (BWBASIC? DEBUG?). Well, I took a look at doing it with BWBASIC. There are two or three problems with that approach. First, for some reason the binary (despite claiming to use "TTY") doesn't redirect to file, so I can't use "set /e" directly there. (It must be doing direct-screen writes as even DJGPP's "redir -eo" doesn't help.) It does let you do 'environ$ "RANDOM" = str$(int(rnd * 4) + 1)', but (no surprise) that environment is gone once you exit BWBASIC, so it isn't saved. (I know there are tricks to modify the master environment, but most people don't do that.) So you have to basically "randomize timer", open a file for output, write the random number, then close. Then after generating the file, "set /e random=type rand4.txt". It's kinda kludgy, but it works. randomize timer num = int(rnd * 4) + 1 open "rand4.txt" for output as #myfile print #myfile, mid$(str$(num),2,len(str$(num))-1) close #myfile print "With FreeCOM 0.84-pre2, run this, then 'set /e random=type rand4.txt' " print "Manual output redirction to file fails with BWBASIC, sadly. :-(" print "'environ$ " + CHR$(&H22) + "RANDOM" + CHR$(&H22) ; print " = ...' loses its value at program exit. :-(" system Who knows, perhaps a recompile would fix this to be more friendly to redirection, but it's not crucial anyways. As is, I just decided to figure it out, with pre-existing binary, for my own amusement. ;-) Actually, it would probably be easier to generate MYPROMPT.BAT directly from BWBASIC instead of doing two separate (kludgy) steps. Oh well. P.S. Keep in mind a few things about BWBASIC: it's not the same as QBASIC (lacks some built-ins, e.g. LTRIM), it ignores precision suffixes (everything is the same size), and everything *except* variables is case insensitive, so "print" and "PRINT" are the same, but a$ and A$ are distinct. Oh, and it hates "?" and "'" shortcuts for PRINT and REM, respectively. Oh, and if you're having trouble finding your syntax error: "DO NUM", "RUN", "LIST". That should help. Just FYI. -- 10 Tips for Better Web Security Learn 10 ways to better secure your business today. Topics covered include: Web security, SSL, hacker attacks & Denial of Service (DoS), private keys, security Microsoft Exchange, secure Instant Messaging, and much more. http://www.accelacomm.com/jaw/sfnl/114/51426210/ ___ Freedos-devel mailing list Freedos-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-devel