You are not logged in.
Pages: 1
For this part of another script it is also bloated. What I am trying to acheive is to make all numbers feed into this loop double digits you will see how i have achieved this, while it is not too much of a problem as there are only numbers 1-9 to deal with, it would be great if i could shorten it.
so if i set input=1, source will end up being 01
Thanks in advance for any one who can help tighten this up
Nathan
%input% gets feed into here
IF 1==%INPUT% GOTO A1
IF 2==%INPUT% GOTO A1
IF 3==%INPUT% GOTO A1
IF 4==%INPUT% GOTO A1
IF 5==%INPUT% GOTO A1
IF 6==%INPUT% GOTO A1
IF 7==%INPUT% GOTO A1
IF 8==%INPUT% GOTO A1
IF 9==%INPUT% GOTO A1
GOTO A2
:A1
SET SOURCE=0%INPUT%
GOTO A3
:A2
SET SOURCE=%INPUT%
:A3
rest of script goes here
cmd, vbs, ps, bash
autoit, python, swift
Offline
This looks like you need to get all the variables the same length
012
123
045 etc
so
SET SOURCE=0%INPUT%
then look at the syntax here:http://ss64.com/ntsyntax/varsubstring.html
to extract the last n characters
Offline
Thank you Simon Shepard that is great, I had 5 sections in my script needing to adjust those over bloated sections.
Now 2 lines can adjust them
SET SOURCE=0%SOURCE%
SET SOURCE=%SOURCE:~-2%
from
IF 1==%SOURCE% SET SOURCE=01&GOTO A1
IF 2==%SOURCE% SET SOURCE=02&GOTO A1
IF 3==%SOURCE% SET SOURCE=03&GOTO A1
IF 4==%SOURCE% SET SOURCE=04&GOTO A1
IF 5==%SOURCE% SET SOURCE=05&GOTO A1
IF 6==%SOURCE% SET SOURCE=06&GOTO A1
IF 7==%SOURCE% SET SOURCE=07&GOTO A1
IF 8==%SOURCE% SET SOURCE=08&GOTO A1
IF 9==%SOURCE% SET SOURCE=09&GOTO A1
:A1
Also
IF %LASTPC% LSS 10 SET digits=%LASTPC:~1,1%
from
IF 01==%LASTPC% SET LASTPC=1&GOTO D1
IF 02==%LASTPC% SET LASTPC=2&GOTO D1
IF 03==%LASTPC% SET LASTPC=3&GOTO D1
IF 04==%LASTPC% SET LASTPC=4&GOTO D1
IF 05==%LASTPC% SET LASTPC=5&GOTO D1
IF 06==%LASTPC% SET LASTPC=6&GOTO D1
IF 07==%LASTPC% SET LASTPC=7&GOTO D1
IF 08==%LASTPC% SET LASTPC=8&GOTO D1
IF 09==%LASTPC% SET LASTPC=9&GOTO D1
cmd, vbs, ps, bash
autoit, python, swift
Offline
Pages: 1