中国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-10-24 06:22
47,815 topics / 349,928 posts / today 1 new / 48,287 members
DOS批处理 & 脚本技术(批处理室) » How to get multiple values separated by | in a line of a file in a FOR loop?
Printable Version  4,646 / 20
Floor16 tomorrower Posted 2006-09-28 05:12
初级用户 Posts 10 Credits 28
Originally posted by NaturalJ0 at 2006-9-27 20:58:
The parentheses in that line were typed wrong. `>a.sql` should be together with ECHO.



This is also incorrect:
for /f "tokens=2,3* delims=|" %%i in (txip1.txt)

do ( echo 'update dzhd_t_txfjxx set v_ip=%%k where c_jgbh=%%i and c_txdm=%%j ;' >a.sql)



The prompt is:

E:\ftp>sql.bat
The command syntax is incorrect.

E:\ftp>for /f "tokens=2,3* delims=|" %i in (txip1.txt)
Floor17 tomorrower Posted 2006-09-28 05:13
初级用户 Posts 10 Credits 28
Originally posted by piziliu2004 at 2006-9-28 04:20:
The code I just wrote for you. Hehe. Interested to take a look
Function splitfile(strFile)
Const ForReading = 1,ForWriting=2
Dim i, retstring
Set fso = CreateObject("Scripting.FileSystemObject" ...


Thank you for your enthusiastic help!
But my level is really not good, can you explain it?
Floor18 pengfei Posted 2006-09-28 05:42
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
Originally posted by tomorrower at 2006-9-28 05:12:

This is also incorrect:
for /f "tokens=2,3* delims=|" %%i in (txip1.txt)

do ( echo 'update dzhd_t_txfjxx set v_ip=%%k where c_jgbh=%%i and c_txdm=%%j ;' >a.sql)



The prompt is:
...


The problem with the code on the first floor is indeed that the redirection is not within the execution range of the FOR statement.

And the modified code here is also incorrect. It is recommended to look at for /?!

The code is modified as follows:
@echo off
for /f "tokens=2,3* delims=|" %%i in (txip1.txt) do (
echo 'update dzhd_t_txfjxx set v_ip=%%k where c_jgbh=%%i and c_txdm=%%j ;' >>a.sql
)
pause

Just found out after posting the thread that the original intention of the landlord is not that the sentence >a.sql is to overwrite. The landlord may want to append >>a.sql

[ Last edited by pengfei on 2006-9-28 at 05:48 ]
Floor19 jieok3375 Posted 2006-10-16 00:41
中级用户 Posts 130 Credits 282 From 广东
Learning
Floor20 mydoslg Posted 2006-10-16 17:08
初级用户 Posts 15 Credits 39
Your tokens shouldn't be 2, 3. Otherwise, change %i.
Floor21 bd123456789 Posted 2007-07-05 09:52
中级用户 Posts 216 Credits 360
Hehe, if the token is more than 62, like 100, then what should be done?
Prev  1 2
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023