I am just find magic of batch and have a idea that if I could make a stack system,then I would be able to make something into assembly like function.
but there`s a problem,I don`t know part of my code how to implement,it is dereference
:pop
set zpop=%zstack%zbase%% ::this line should be interpret twice
set zstack%zbase%=
set /A zbase=%zbase%-1
set
goto start
yes,that line is necessary to be interpret more than once, and I think this problem is important because if I have a ability to dereference twice, I would be able to dereference any value for any countable time I want if it is existed.
below is in case of a need of full code shown:
setlocal EnableDelayedExpansion
:start
set zgoto=start
REM given a target label
set /P target=
if %target%==push (
REM given a push value
set /P zpush=
)
goto %target%
:constructor
set zpush=start
set /A zbase=0
set zstack%zbase%=start
set
goto start
:destructor
for /L %num in (%zbase%,-1,0) do (
set zstack%num%=
)
set zbase=
set
goto start
:push
set /A zbase=%zbase%+1
set zstack%zbase%=%zpush%
set
goto %zgoto%
:pop
set zpop=%zstack%zbase%%
set zstack%zbase%=
set /A zbase=%zbase%-1
set
goto start ::change to "goto %zpop%" after this is complete
:end
pause
endlocal
exit
REM call:
:: set zpush=label_name_after_these_line
:: set zgoto=function_name
:: goto push
REM ret:
:: goto pop