assign values + do calculations + echo result

Microsoft Windows xp professional w/serv...
December 8, 2010 at 07:22:29
Specs: Macintosh
Hi scripting guru,
I would like to use batch or vbs do the following things

read values from a source file then assign each one of them to variables
do modulus operation (%) for each variable
if the remainder is zero echo "OK" else echo "Not OK"

example:
source file:
1
2
3
etc...

read source file and assign 1 to variable A
read source file and assign 2 to variable B
read source file and assign 3 to variable C
etc.....

If an integer % Variable A==0 echo OK
else not OK
If an integer % Variable B==0 echo OK
else not OK
If an integer % Variable C==0 echo OK
else not OK
etc...

Help me.....pls....
Thanks in advanced!!


See More: assign values + do calculations + echo result

Report •

#1
December 8, 2010 at 10:22:51
Not obvious how you'd run a bat on a mac, but in NT:

===================================
@echo off & setLocal EnableDELAYedeXpansion

set /a M=3
for /f "tokens=* delims= " %%a in (somefile) do (
set /a A=%%a%%!M! & if !A! equ 0 (echo OK) else (echo NOT)
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
December 9, 2010 at 04:05:08
you are the man, it works like a charm!!!
thank you very much!!!

Report •
Related Solutions


Ask Question