1.

Solve : Multiply a variable by 10?

Answer»

@up
is the %class% set before becouse it looks like you are seting %alliance% and trying to match %class%yes this code would come right after the class is set.Seems like you didn't pick up on my post:
Code: [SELECT]set /a lifetemp=%life%*10
set life=%lifetemp%oh yeah.i tired it. nothing. MAYBE my computers just retarded. sometimes batch files do get a little messed up on it but its usually fine after I restart it. it didn't help this time.It is a BUG somewhere else.

Code: [Select]rem assignment code
set /a life=40
set /a life=%life%*10
echo %life%

gave me 400.

there is likely a bug elsewhere in your code- causing your variables to have unexpected values when you arrive at the arithmetic.

I have a proposed change:

Code: [Select]:allianceselect
CLS
ECHO Choose your alliance:
ECHO.
ECHO 1) Good
ECHO 2) Evil
ECHO.
set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
ECHO class is:
echo %class%
pause
IF '%class%'=='1' SET alliancename=Good
IF '%class%'=='2' SET alliancename=Evil
IF '%class%'=='1' SET /A life=10 * %life%
IF '%class%'=='2' SET /A armor=10 * %armor%

DEL *.life
DEL *.armor
ECHO life>%life%.life
ECHO armor>%armor%.armor
GOTO lobby


this will ascertain wether your %class% variable even has a VALUE when you try to use it.i've got it. thanks for the code, but it didnt much help. well, actually it did help me realize my error. im surprised it took even me this long to figure out this dumb mistake lol.

new code:
Code: [Select]set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
IF '%alliance%'=='1' SET alliancename=Good
IF '%alliance%'=='2' SET alliancename=Evil
IF '%alliance%'=='1' SET /A life=10 * %life%
IF '%alliance%'=='2' SET /A armor=10 * %armor%
old code:
Code: [Select]set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
IF '%class%'=='1' SET alliancename=Good
IF '%class%'=='2' SET alliancename=Evil
IF '%class%'=='1' SET /A life=10 * %life%
IF '%class%'=='2' SET /A armor=10 * %armor%
just in case anyone's curious.lol. and after all that work to multiply by 2... I mean, 10.lol yeah. i copy and pasted that code in there 5 times and it didn't work once!

lol.erm... multiplying a number by 2 five times isn't the same as multiplying by 10 anyways.I know. but neither statement made sense. I thought I'd poke a little more fun at that.Quote from: gamerx365 on November 24, 2008, 02:53:20 PM

i've got it. thanks for the code, but it didnt much help. well, actually it did help me realize my error. im surprised it took even me this long to figure out this dumb mistake lol.

new code:
Code: [Select]set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
IF '%alliance%'=='1' SET alliancename=Good
IF '%alliance%'=='2' SET alliancename=Evil
IF '%alliance%'=='1' SET /A life=10 * %life%
IF '%alliance%'=='2' SET /A armor=10 * %armor%
old code:
Code: [Select]set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
IF '%class%'=='1' SET alliancename=Good
IF '%class%'=='2' SET alliancename=Evil
IF '%class%'=='1' SET /A life=10 * %life%
IF '%class%'=='2' SET /A armor=10 * %armor%
just in case anyone's curious.

that was what i mean in last post
Quote
is the %class% set before becouse it looks like you are seting %alliance% and trying to match %class%
yes class was set before. the problem was it was being set as 3... lol. thats why i was so confused.


Discussion

No Comment Found