Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
start <name of batch prog>exit
set /a var=%random%%%4if %var% equ 0 set one=I like it cause of that to.if %var% equ 1 set one=eww, are you shurr?if %var% equ 2 set one=Wow, never thought of that.if %var% equ 3 set one=Are you shurr?echo %one%pausegoto %one%
Code: [Select]goto %one%
goto %one%
set /a var=%random%%%4if %var% equ 0 set one=I like it cause of that to.if %var% equ 1 set one=eww, are you shurr?if %var% equ 2 set one=Wow, never thought of that.if %var% equ 3 set one=Are you shurr?echo %one%pauselabel %one%goto one
set one=twoif errorlevel 0 goto %one%goto :eof:twoecho %one%
set one=twoif errorlevel 0 goto %one%goto :eof:%one%echo %one%
label %one%
From testing, I discovered you can in fact expand a label name go to it:
You cannot however expand a variable as part of a label:
So you can, I now see. I was always taught that self-modifying code is a bad idea, however.
the word 'sure' is spelt thus.
Quotethe word 'sure' is spelt thus.Thus Spake Zarathrustra
what that didn't work for me , when it got to the random part it just crashes on me.
set /a var=%random% %%4 ^ ^ ^ needs a space here
What happened? You need to tell us more. Just saying "it didn't work" is not good enough if you want us to help you.By the way, could you spell 'sure' properly please?