|
Answer» Hi Guys,
In Unix land I can easily format VARIABLES by using the 'typeset' operator, however I'm at a loss to know if I can achieve the same in DOS.
As an example: My variable listing count will NEVER reach +99. So I'd like to prefix numbers 1 thru 9 with a 0 (zero) to keep reporting neat. 01 02 03 ... 08 09
Is this possible in DOS ??
Cheers, Cameronyes - and no there are no simple commands, but check out the SET command, you could prepend a 0 then take the rightmost 2 digits
GrahamThanks for the response Graham.
Unfortunately that doesn't do the trick ....
Tried a number of variations with no success.
C:\>set /a var2=%VAR1:~2,2%+1 1 C:\>set var var1=01 var2=1
C:\>set /a var2=00%var1%+1 2 C:\>set var2=00%var2%
C:\>set /a var2=00%var1%+1 2 C:\>set var var1=01 var2=2
C:\>set var2=00%var2%
C:\>vbscript. Code: [Select]For i=0 To 99 WScript.Echo Right(String(2,"0") & i, 2) next Try this test : Code: [Select]for /l %%a in (1,1,15) do call :doit %%a goto :EOF
:doit set test=0%1 echo %test:~-2% GrahamMany thanks gpl,
That's done the trick. Darn my memory sucks.
Thanks also to Graham and ghostdog74 for your suggestions.
Cheers, Cameron
|