Haha, the topic of such a heated study, I'm honoured.
Acy Forsythe, just syntax errors. I'll explain what's going wrong. Your code:
Command interpreter sees the following variables in bold/underline:
set line=
%%line
%%space
%:~0,80%What you want is what you already wrote...
Code: Select all
set line=%line%%space%
set line=%line:~0,80%
It actually has nothing to do with calls or dynamic variables.
As for my thread though, this is what's happening:
Code: Select all
call call echo:%%%%a_%%a_%a_cup%%%%%%%
It's expanding "from the inside out". First, Command Prompt expands each pair of %%s. So...
call call echo:
%%%%a_
%%a_
%a_cup%%%%%%%...becomes (match the series of colours)...
call call echo:
%%a_
%a_
pot%%%...then it does the first call...
call echo:
%%a_
%a_pot%%%...becomes (match the series of colours)...
call echo:
%a_
box%...and the last call...
call echo:
%a_box%...becomes...
echo:
crateAnd so on. If I made each variable, like a_cup=a_pot rather than a_cup=pot, I could remove the a_'s separating each expansion and just keep re-expanding the result.
Code: Select all
set a_cup=a_pot
echo:%a_cup%
set a_pot=a_box
call echo:%%%a_cup%%%
set a_box=a_crate
call call echo:%%%%%%%a_cup%%%%%%%
Because the Command Interpreter converts %% to % (that is, 2 to 1) we work backwards exponentially, by doubling the number of %s for each later expansion.
More colour-coding so you can see...
set a_cup=a_pot
echo:
%a_cup%set a_pot=a_box
call echo:
%%%a_cup%%%set a_box=a_crate
call call echo:
%%%%%%%a_cup%%%%%%%Or perhaps more accurately...
set a_cup=a_pot
echo:%a_cup%set a_pot=a_boxcall echo:%%%a_cup%%%set a_box=a_cratecall call echo:%%%%%%%a_cup%%%%%%%...hope this is getting through lol.