Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[call if] how to using Impossible Syntax

60 views
Skip to first unread message

mokomoji

unread,
Feb 20, 2018, 3:09:08 AM2/20/18
to
source

@echo off
setlocal
cd /d %~dp0
call set z_var1=.\%~dpnx0
set z_var2=11111
echo %z_var1%
call cmd /c if exist "%%z_var1%%" (
set z_var2=222222
)
echo %z_var2%

endlocal
pause

@echo off
setlocal
cd /d %~dp0
for /f "usebackq delims=" %%f in (`dir /b`) do (
call set z_var3=%%f
echo %~nx0
call cmd /c if "%%f" equ "%~nx0" echo %%z_var3%%--------111
call cmd /c if "%%f" equ "%~nx0" (echo %%z_var3%%--------222)
call call cmd /c if "%%f" equ "%~nx0" (
call set z_var4=111111111111111111
call echo %%z_var4%%---------1
)
call echo %%z_var4%%---------2
)
call echo %%z_var4%%---------3

endlocal
pause

@echo off
setlocal
set z_var[1]=1
echo %z_var[1]%----------0
for /f "usebackq tokens=1,2 delims==" %%f in (`set z_var`) do (
call set z_var5=%%g
call echo %%f------%%g------------%%z_var5%%

call cmd /c if "%%z_var[1]%%" equ "%%z_var5%%" (
call set z_var[1]=2
call echo %%z_var[1]%%-----------2
)
call echo %%z_var[1]%%-----------3
)
call echo %%z_var[1]%%-----------4
endlocal
pause


output

.\C:\Users\mokomoji\Desktop\ddddd\DDD.C
222222
any key pause....


DDD.CMD
DDD.CMD--------111
111111111111111111---------1
111111111111111111---------2
111111111111111111---------3
any key pause....

1----------0
z_var[1]------1------------1
2-----------2
2-----------3
2-----------4
any key pause....












Message has been deleted

mokomoji

unread,
Feb 20, 2018, 3:37:35 AM2/20/18
to
Typo Fix T_T'' sorry


@echo off
setlocal
cd /d %~dp0
call set z_var1=%~dpnx0
Fix line
call set z_var1=.\%~dpnx0
call cmd /c if "%%f" equ "%~nx0" (echo %%z_var3%%--------222)


you Call If love..

joke...sorry...

npocmaka

unread,
Feb 20, 2018, 9:53:43 AM2/20/18
to

call cmd /c if "%%z_var[1]%%" equ "%%z_var5%%" (
call set z_var[1]=2
call echo %%z_var[1]%%-----------2
)


this is not correct I think. The two lines in after the opening bracket will be executed always. Both call and cmd /c are executing commands until the end of the line or redirection/conditional execution operator.



Message has been deleted
Message has been deleted

stivm...@gmail.com

unread,
Nov 20, 2018, 10:17:10 AM11/20/18
to
Hello....
0 new messages