Adding variables
-
- Fame ! Where are the chicks?!
- Posts: 236
- Joined: 16 May 2007, 16:00
- 16
- Location: CandyLand
- Contact:
Adding variables
is there anyway to add variables in batchs and the command prompt
96% better then all connections global
Kiss My Ass Good Bye
Kiss My Ass Good Bye
- bad_brain
- Site Owner
- Posts: 11636
- Joined: 06 Apr 2005, 16:00
- 19
- Location: In your eye floaters.
- Contact:
yeup, it's easy....to set a variable:
this gives the variable test the value 1234
to check it:
take care that a variable in batch is using %variable% and not $variable like in *nix...
Code: Select all
set test=1234
to check it:
Code: Select all
echo %test%
1234
-
- Fame ! Where are the chicks?!
- Posts: 236
- Joined: 16 May 2007, 16:00
- 16
- Location: CandyLand
- Contact:
I MENT ADD LIKE %1%+%2%bad_brain wrote:yeup, it's easy....to set a variable:this gives the variable test the value 1234Code: Select all
set test=1234
to check it:take care that a variable in batch is using %variable% and not $variable like in *nix...Code: Select all
echo %test% 1234
i know the thing is
Code: Select all
set /a 1+1
Code: Select all
set /a variable=1+1
Code: Select all
echo %variable%
2
but i cant get something like this to work
Code: Select all
set /a variable=%variable1%+%variable2%
96% better then all connections global
Kiss My Ass Good Bye
Kiss My Ass Good Bye
is this wot you mean
if its not im sure i can help i used to do alot ov batch
Code: Select all
@echo off
set first=
set /p first= whats your firsname:
set second=
set /p second= whats your second name:
echo your full name is %first% %second%
pause>null
-
- Fame ! Where are the chicks?!
- Posts: 236
- Joined: 16 May 2007, 16:00
- 16
- Location: CandyLand
- Contact:
what does that have to do with additionbubzuru wrote:is this wot you mean
if its not im sure i can help i used to do alot ov batchCode: Select all
@echo off set first= set /p first= whats your firsname: set second= set /p second= whats your second name: echo your full name is %first% %second% pause>null
96% better then all connections global
Kiss My Ass Good Bye
Kiss My Ass Good Bye
Code: Select all
set /a two=1+1
but when you use this
Code: Select all
%VARIABLE1%+%VARIABLE2%
so all in all you have to set VARIABLE1 and VARIABLE2 as Integer 's
vb code example
Code: Select all
Dim VARIABLE1 As Integer
Dim VARIABLE2 As Integer
MsgBox(VARIABLE1 + VARIABLE2)
-
- Fame ! Where are the chicks?!
- Posts: 236
- Joined: 16 May 2007, 16:00
- 16
- Location: CandyLand
- Contact:
wow you're out of it man you need helpbubzuru wrote:this will display 2 because the computer knows that 1 is a Integer so it can add them both togetherCode: Select all
set /a two=1+1
but when you use this
VARIABLE1 and VARIABLE2 are strings and two strings canot be added togetherCode: Select all
%VARIABLE1%+%VARIABLE2%
so all in all you have to set VARIABLE1 and VARIABLE2 as Integer 's
vb code example
Code: Select all
Dim VARIABLE1 As Integer Dim VARIABLE2 As Integer MsgBox(VARIABLE1 + VARIABLE2)
WERE CODING BATCH NOT VB IN BATCH STUFF WITH TWO %%s ON THE END IS CONSIDERED A VARIABLE
SOOOOO
Code: Select all
set vari1=1
set vari2=3
se /a vari3=%vari1%+%vari2%
96% better then all connections global
Kiss My Ass Good Bye
Kiss My Ass Good Bye
- bad_brain
- Site Owner
- Posts: 11636
- Joined: 06 Apr 2005, 16:00
- 19
- Location: In your eye floaters.
- Contact:
hm, works for me:
and it's what the MS page says too:
http://www.microsoft.com/resources/docu ... x?mfr=true
and it's what the MS page says too:
http://www.microsoft.com/resources/docu ... x?mfr=true