中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-06 04:05
48,039 topics / 350,124 posts / today 2 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » [Closed] setlocal EnableDelayedExpansion and "!"
Printable Version  9,599 / 25
Floor1 kcdsw Posted 2006-06-11 15:31
中级用户 Posts 179 Credits 404
Today on duty, really bored. CS was beaten by others, QQ has no one to chat with. Want to write a bat but can't figure it out. Fainted on the front line.
Hope brothers can give pointers.
Floor2 namejm Posted 2006-06-12 23:48
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Since variable delay is used, why still use %m% to reference? It should be changed to !m! instead.
Floor3 namejm Posted 2006-06-13 13:31
荣誉版主 Posts 1,737 Credits 5,226 From 成都
I tested the following code, it has already added 1. What exactly do you want it to become?

Specifically, whether there is a problem with the code, because the function you want to implement is unclear, I didn't look closely, but at least it can add 1, otherwise you can give it a try.

Floor4 kcdsw Posted 2006-06-17 10:29
中级用户 Posts 179 Credits 404
Hope the experts can give an idea! Thanks
Floor5 bagpipe Posted 2006-06-17 12:17
银牌会员 Posts 425 Credits 1,144 From 北京
setlocal EnableDelayedExpansion
set m=0
for /f "tokens=* delims=" %%m in ('findstr /v /C:"730 730" cover.ps') do (
if "!m!"=="686" (pause) else echo %%m >>cover3.txt
set /a m=!m!+1
)
pause
exit
I don't know what effect the original poster wants. There is nothing wrong with this batch script
Floor6 kcdsw Posted 2006-06-17 13:28
中级用户 Posts 179 Credits 404
This is this meaning. If once there is an exclamation mark in cover.ps, because the variable delay is enabled, this exclamation mark cannot be echoed into the new file.
Floor7 bagpipe Posted 2006-06-17 15:09
银牌会员 Posts 425 Credits 1,144 From 北京
@echo off
set m=0
for /f "tokens=*" %%m in ('findstr /v /C:"730 730" 2.txt') do (
setlocal EnableDelayedExpansion
set /a m=!m!+1
if "!m!"=="686" (pause) else setlocal DISABLEDELAYEDEXPANSION&&echo %%m>>test.txt
)
echo %m%

The method is a bit crude, but this issue needs to be considered. The original poster can try this first
Floor8 kcdsw Posted 2006-06-17 15:17
中级用户 Posts 179 Credits 404
.....
F:\Print\blogcn订单\用户单\163>
setlocal EnableDelayedExpansion
set /a m=!m!+1
if "!m!" == "686" (pause) els
192.168.0.158\\BlogPrinting\\Sy
e\\CoverPage_BG.jpg) 1>>test.tx
)
Exceeded the maximum setlocal recursion depth.
Exceeded the maximum setlocal recursion depth.

This is the run record
Floor9 kcdsw Posted 2006-06-17 15:18
中级用户 Posts 179 Credits 404
And the exclamation mark is still gone
Floor10 bagpipe Posted 2006-06-17 15:20
银牌会员 Posts 425 Credits 1,144 From 北京
It seems that this problem occurs with repeated calls, but it's okay if the number of lines is small. I just tested it and didn't expect this problem. I'm thinking about it.
Floor11 bagpipe Posted 2006-06-17 15:21
银牌会员 Posts 425 Credits 1,144 From 北京
What system are you using? I tested with Windows 2000
Floor12 willsort Posted 2006-06-17 15:22
元老会员 Posts 1,512 Credits 4,432

───────────────── Moderation Record ─────────────────
Performed by: Will Sort
Operation: Move Topic: From DOS Troubleshooting & Discussion (Help Desk)
Explanation: According to topic content classification, it is more suitable to be posted in this forum section
Punishment: Deduct 6 points of rewards for posting this topic, and deduct 2 points of points for forum section violations
───────────────── Moderation Record ─────────────────


Re kcdsw:

First of all, set/a has an independent variable recognition mechanism, and there is no need to use the form of!m! for delayed variable expansion. You can directly use set /a m+=1. However, using set /a m=%m%+1 in building 3 will instead have the problem of not being able to continuously increase because it always uses the initialized variable.

Secondly, regarding the problem of! being escaped in the text, the solution is still to turn off variable delay and use call, but when passing %%m, it is no longer using command line parameters, but using environment variables. As follows:



[ Last edited by willsort on 2006-6-17 at 15:24 ]
Floor13 bagpipe Posted 2006-06-17 15:33
银牌会员 Posts 425 Credits 1,144 From 北京
Oh, I see......
Floor14 kcdsw Posted 2006-06-17 15:38
中级用户 Posts 179 Credits 404
Tears shed tears and.... continue posting

I uploaded it

The purpose is to have the line containing 730 730, and recalculate its width through the pixel data of the next line
ps: 730 730 are the length and width values, but the original photo is not a square, so the length and width ratio is wrong. I want to use this to change it to the correct one, but I accidentally lost the exclamation mark

My environment is xp sp2 (oem genuine version)

[ Last edited by kcdsw on 2006-6-17 at 15:44 ]

Attachments
163.rar (14.39 KiB)
Floor15 kcdsw Posted 2006-06-17 15:51
中级用户 Posts 179 Credits 404
F:\Print\blogcn订单\用户单\163>if "17" == "day" call setp
The syntax error is: There should not be << here.

F:\Print\blogcn订单\用户单\163>echo lineto/num num 1 sub def num 0 le{exit}if}lo
op}bd/EmptyDict <<>> def >>cover3.txt
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023