0

Having some difficulty with the delayedexpansion in cmd.

This might be a stupid question but is there any way of summing within a function (ie without 'set') or using ! within ! (or something to the same effect); for example could ~%%n+%y% in the case below be treated as the sum of its parts by use of brackets or should I just come at it from a different angle?

for /l %%n in (10 1 36) do (
for /f %%a in ("!alpha:~%%n+%y%,1!") do (
set "code=!code:%%n=%%a!"))

Any help would be greatly appreciated. Thanks

LotPings
  • 1,015
  • 7
  • 12

1 Answers1

0
  • The only way to do (signed 32 bit integer) math in batch is with the set /a command.
  • you can force another type of DelayedExpansion with a pseudo call with echo and set (unfortunately not if) and doubling the percent signs around regular variables.

Looks like you want to scramble/crypt text in the var code by Alphabetical Disorder. IMO your approach won't work this way, because you would also change already modfied chars.

See this link new functions: :chr, :asc, :asciiMap to assist you in your task.

LotPings
  • 1,015
  • 7
  • 12
  • cheers, i thought that might be the case.I have tried a call function but that doesn't seem to work either. You're right it was (part of) the first wheel of an enigma machine but it only encrypts one letter per run so i'm not too worried about it changing modified characters. Anyway thanks again – user519110 Apr 13 '19 at 12:47
  • See addaed link in my answer. – LotPings Apr 13 '19 at 12:55
  • cheers for the link. This is my first time using cmd or anything like it so it all looked a little Chinese to me but I've found an (ugly) workaround and you saved me from banging my head against that brick all any longer. – user519110 Apr 13 '19 at 15:16