Is this possible in batch files under DOS.
many thanks.
regards, Chris
In a word, no. BATCH is for "batching" commands, not for
arithmetic so if you need this latter you'll have to use some
other language either in its own right or as a helper.
DOS 6.22 came with Quickbasic (QBASIC.EXE) but earlier versions
had different dialects -- perhaps that ould do what you want?
What exactly _do_ you want to achieve?
Pete
--
"We have not inherited the earth from our ancestors,
we have borrowed it from our descendants."
If you are using MSDOS version W2k/XP then use "set /a"
(type "set /?" for help).
For MSDOS version 6/Win9x you need an external program or
include some assembler instructions within you batch program:
highest priority
() : parenthesis
! ~ - : logical not, binary not, minus sign
* / \ : multiplication, division, modulo
+ - : add, sub
<< >> : left shift, right shift
< > <= >= : less, greater, less equal, greater equal
== != : equal, nor equal
& : binary AND
^ : binary XOR
| : binary OR
&& : logical AND (input: FALSE = 0; TRUE=all other
|| : logical OR result: FALSE = 0; TRUE= 1)
lowest priority
If the characters < > & ^ | are used, you must enclose the
expression in "".
examples:
calc 3+4*5
calc "4*(3+(8>>2) ^ 7"
calc "(4&&3) ^ (5&4)"
calc "((3>=1)+8)\5"
-------------------------------------------------------------------------
@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>calc.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>calc.com
echo y?sexCd`z?J_L?@o@}`guN?_E~[=H??_CIvJGDGAKs?F_{E@{ruLnsaskj>>calc.com
echo F=?@}ICszECW~MsFEBQpepGCIACN?bBAgQtg{OFEDKXjoKt`{OFEDKOj?K>>calc.com
echo t}{SFEDKFj@Ktl{OFEEKjEAseJNVCuNGvx{Oo{O?EKqPeokOIQjLA@ep?g>>calc.com
echo jnt?~OHeNCyeQf????Ut?CjA}~~?QGDt@CQve=?GjbtA~OveEsjJYvFBVz>>calc.com
echo HeCcCITGCqEHNi{??MCI{A}NCNn_}?Eq[{AR}CNWGq?GNj{??uCE{A}Nos>>calc.com
echo lSt{{OKqPGsCwOQqdH={?Aq]sdZjO[t}{OLqPGsCwORqOH={?AqHsdEjP[>>calc.com
echo {SqAGt=CNCw?@ZDMqvjb`{T?{qsLIteCwcqAfsCCjWqq[qcGs]{S{{]OqI>>calc.com
echo t`Cwg?qRs`Oj_K{pqAIshC{kqACs?C@ahJUGExBM?MwNIAANMbJ@OPlJeH>>calc.com
echo CnBMDJeHCh?MeHtPDnNwDHeH}_j~StHFpeQDHeQFCNlbe@lPe=v1YDHQ}G>>calc.com
echo j~StHFpeQDHeQFCNlbe@TPe=v1YTHQ}ojzH}H~eGtPeg@[jDHqH}a}eGtP>>calc.com
echo egh[jDHqh?UyMtBCLFex_Re=LFexDHeH}BjzNtHFLFexgRe=LFexDHeH~o>>calc.com
echo hvBh?MeZtPNgxK?IKADFeL????Yh?[Fe~v?@D?h??o}~O=MtHFgxepDFeL>>calc.com
echo ??@?e~?s}Yj~FtHFgxepjZ}=H}N~eFtP=gx[CjO~tH}1xeFCDsgv}xjzHt>>calc.com
echo HFgxepwDNgkj~nBh?MeHtPeg`[hDHq?~AktChRpeHCHegfshD{h?}zHtCC>>calc.com
echo gHepDHeH}eh~Ch?MeWtP?DFB?????HepnCNWHe~FCNlbh~g=?~nltChRHe>>calc.com
echo PCDN?be~b\NlHK~[Du~NhvGh?MeItThiH}?=ZnskyRGBEcEhVk[}=zpHCw>>calc.com
echo CJeHeZo[x?H[veDslrWJQpepuveL?Co`MoAReSGQt?H[ZGlrMBsPs[GaqH>>calc.com
echo ?xzPhkL?@orB`[_sdDrdqTsktT?I=?????0x>>calc.com
calc 3+4*5 >_.bat
call _.bat
echo 3+4*5 = %result%
calc "4*(3+(8>>2)) ^ 7">_.bat
call _.bat
echo "4*(3+(8>>2)) ^ 7" = %result%
calc "(4&&3) ^ (5&4)">_.bat
call _.bat
echo "(4&&3) ^ (5&4)" = %result%
calc "((3>=1)+8)\5">_.bat
call _.bat
echo "((3>=1)+8)\5" = %result%
>Greetings, it's been a while since I've programmed in DOS and now find
>myself needed to write a batch file to iperform some operations (like
>adding dividing, etc).
>
>Is this possible in batch files under DOS.
>
You posted from an XP machine - alt.msdos.batch.nt would be the
appropriate place for XP batch questions.
To answer the question anyway. In XP, *integer* arithmetic is
possible with SET /A. Results are *truncated*, not rounded.
--
T.E.D. (tda...@gearbox.maem.umr.edu) Remove "gearbox.maem" to get real address - that one is dead
and of course there's always 4DOS - which will add numbers and do a lot,
lot, lot more for DOS.
4DOS is now free to use (no longer being sold by JPSoft).
Find the last version (7.50 build 130) developed by JPSoft at
www.jpsoft.com/download.htm under the "Older Unsupported (FREE)
Products" banner.
Martin
Happily, build 130 is no longer the last build: http://4dos.hit.bg/
--
Charles Dye ras...@highfiber.com
> [trimmed for space]
> DOS 6.22 came with Quickbasic (QBASIC.EXE) but earlier versions
> had different dialects -- perhaps that ould do what you want?
Just to be pedantic, QuickBasic and QBasic (which shipped with MSDOS 5
and 6) are slightly different languages. QBASIC.EXE was an interpreter
for QBasic. QuickBasic was (is) a compiled language capable of
creating standalone executables with more capabilities and larger
program and data spaces than QBasic. The confusion of names is common,
and Microsoft did no one any favors with the names. You had to buy
QuickBasic. (Copies on the internet are bootleg and illegal.) QBasic
may still be available for free download from Microsoft's website.
--
Paul Bartlett
Being even more pendantic, it's QuickBASIC.
> The confusion of names is common,
> and Microsoft did no one any favors with the names.
And perhaps someone can confirm if the rumor I heard is true...
The form "QBasic" was chosen (unwisely, as you point out) because it's a
"smaller version" of QuickBASIC. That is, they dropped the "uick" and used
lowercase for the "asic" to make the name... smaller.
- Bill
> "Paul Bartlett" <bart...@panix.com> wrote in message
> news:Pine.NEB.4.64.07...@panix2.panix.com...
>> Just to be pedantic, QuickBasic and QBasic (which shipped with
>> MSDOS 5 and 6) are slightly different languages.
>
> Being even more pendantic, it's QuickBASIC.
Actually it seems to be both. I bought the compiler at retail from a
large computer store in the set with both manuals bound in one cover.
The cover is clearly and unmistakably, both front and back, printed
'QuickBasic' not 'QuickBASIC'. I have it next to me as I type. On the
other hand, inside the cover it is 'QuickBASIC' not 'QuickBasic'.
Leave it to Microsoft.
>> The confusion of names is common,
>> and Microsoft did no one any favors with the names.
>
> And perhaps someone can confirm if the rumor I heard is true...
> [...]
That I have no information about.
--
Paul Bartlett
Son of a ...
I didn't even have to pull mine down off the shelf. I can see that it's
"QuickBasic" on the binding from here.
And the OTHER Microsoft book on it (I bought it separately) calls it
"QuickBASIC."
My comment was based on starting it up and seeing it identify itself as
"QuickBASIC" on the help screens and looking at this second book. I somehow
managed to not notice the other book (right beside the one I did pull down)
last night.
Thanks for pointing out this oddity. Well, if it was anyone but Microsoft,
I'd call it an oddity. For MS, it's sort of business as usual.
- Bill