|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
求解:
无奈何兄,试过兄的代码,发现显示内容缺少第一行,不知何故?
Solve:
Brother Wu Nai He, I tried your code and found that the content displayed is missing the first line. I don't know why?
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-12-14 02:59 |
|
|
无奈何
荣誉版主
      
积分 1338
发帖 356
注册 2005-7-15
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
我这里没有问题啊,少了哪一行?
有点小问题,空行也会输出,修正一下。
There is no problem here. Which line is missing? There is a small problem. Blank lines will also be output. Fix it.
|

☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul
|
|
2006-12-14 03:23 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
新代码没有问题了!
请问增加if语句是什么意思?
The new code is fine!
What does adding the if statement mean?
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-12-14 03:31 |
|
|
HUNRYBECKY
银牌会员
    
积分 1179
发帖 442
注册 2006-9-9
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
Originally posted by youxi01 at 2006-12-14 01:18:
因为::在vbs中可以被认识(识别为换行),而rem却不能被vbs认识!
youxi01兄,我真不知有如此用法,但是我是把你的代码保存在BAT文件而非VBS文件中,我也曾试着保存到VBS中,但无法运行。这又是何故?
Originally posted by youxi01 at 2006-12-14 01:18:
Because :: can be recognized (identified as a line break) in VBS, while rem cannot be recognized by VBS!
Brother youxi01, I really didn't know there was such a usage, but I saved your code in a BAT file instead of a VBS file. I also tried saving it in VBS, but it couldn't run. Why is that again?
|
|
2006-12-14 03:43 |
|
|
HUNRYBECKY
银牌会员
    
积分 1179
发帖 442
注册 2006-9-9
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
Originally posted by youxi01 at 2006-12-13 08:03:
个人认为,纯粹的P很难实现,因为P很难判断变量的字节数,所以要借助于vbs。
::On Error Resume Next
echo ' > nul &cls & @echo off
echo ' > nul & ...
能否解释下在BAT中编写VBS脚本并运行的机理,一点都看不懂是怎么执行的,谢谢!
Originally posted by youxi01 at 2006-12-13 08:03:
Personally, purely P is difficult to implement because P has difficulty determining the number of bytes of variables, so it is necessary to rely on VBS.
::On Error Resume Next
echo ' > nul &cls & @echo off
echo ' > nul & ...
Can you explain the mechanism of writing and running VBS scripts in BAT? I don't understand at all how it is executed, thank you!
|
|
2006-12-14 04:03 |
|
|
无奈何
荣誉版主
      
积分 1338
发帖 356
注册 2005-7-15
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
Originally posted by ccwan at 2006-12-14 03:31:
新代码没有问题了!
请问增加if语句是什么意思?
加上这条判断语句后,空行就不会输出了。小问题是空白行(只含有空格的行)还是会输出的,只需将 if(R != "") 改为 if(R != "") 能解决空白行的问题。
Originally posted by ccwan at 2006-12-14 03:31:
The new code is okay!
What does adding the if statement mean?
After adding this judgment statement, blank lines will not be output. The small problem is that lines containing only spaces (blank lines) will still be output. Just change if(R != "") to if(R != "") to solve the problem of blank lines.
|

☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul
|
|
2006-12-14 04:03 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
谢谢。
看来有必要学学了。
Thanks.
It seems necessary to learn.
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-12-14 04:07 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
zg159兄和无奈何兄的代码精彩, 更通用. 而用文件大小判断字节数是更为省事的方法.
当时分析楼主给的三行代码, 初步得到规律写的代码自然不能计算中文字符的英文字符的字节差别. 也想用文件大小判断, 出于对生成临时文件的敏感, 故只针对1F三行代码做处理.
而除了zh159兄8F用文件大小判断字节数外还有其他方法, 不用生成临时文件. 但效率会很低, 为了扩展思路, 熟悉不同的算法, 大家可以尝试使用下面的算法实现对中文汉字和英文字符的判断.
一、用for列举出要匹配的字符, 一旦匹配成功, num+1。
二、FOR循环执行完毕, 开关如没关闭则判断其为汉字,故num+2。
三、整个嵌套循环执行完毕, 计算num的值进行空格填充。
希望大家能写出更加精彩的代码,用灵活的思路,更先进的算法,弥补P处理脚本功能上的不足, 带动本论坛的发展^_^
Brother zg159 and Brother Wunaaihe have wonderful and more general code. And using the file size to judge the number of bytes is a more convenient method.
At that time, when analyzing the three lines of code given by the owner, the code initially written according to the pattern naturally couldn't calculate the byte difference between Chinese characters and English characters. I also wanted to use the file size judgment, but out of sensitivity to generating temporary files, I only dealt with the three lines of code for 1F.
And besides Brother zh159's 8F using the file size to judge the number of bytes, there are other methods without generating temporary files. But the efficiency will be very low. In order to expand ideas and be familiar with different algorithms, everyone can try to use the following algorithm to judge Chinese characters and English characters.
1. Use for to list the characters to be matched, and once matched successfully, num+1.
2. After the FOR loop is executed, if the switch is not closed, it is judged as a Chinese character, so num+2.
3. After the entire nested loop is executed, calculate the value of num for space filling.
I hope everyone can write more wonderful code, use flexible ideas and more advanced algorithms to make up for the shortcomings of P processing script functions, and promote the development of this forum ^_^
|

业精于勤而荒于嬉,形成于思而毁于随。 |
|
2006-12-14 04:41 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
Originally posted by HUNRYBECKY at 2006-12-14 03:43 AM:
youxi01兄,我真不知有如此用法,但是我是把你的代码保存在BAT文件而非VBS文件中,我也曾试着保存到VBS中,但无法运行。这又是何故?
一定要保存为bat文件,因为它是针对P处理的!
Originally posted by HUNRYBECKY at 2006-12-14 03:43 AM:
Dear brother youxi01, I really didn't know there was such a usage. But I saved your code in a BAT file instead of a VBS file. I also tried saving it to VBS, but it couldn't run. Why is that?
Must be saved as a bat file because it's processed for P!
|
|
2006-12-14 04:42 |
|
|
youxi01
高级用户
   
积分 846
发帖 247
注册 2006-10-27 来自 湖南==》广东
状态 离线
|
|
2006-12-14 04:46 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 26 楼』:
使用 LLM 解释/回答一下
还是awk的效果好觉得
I think the effect of awk is really good
|
|
2006-12-14 05:37 |
|
|
cdswf
新手上路

积分 4
发帖 2
注册 2006-10-27
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
Originally posted by youxi01 at 2006-12-13 08:03 AM:
个人认为,纯粹的P很难实现,因为P很难判断变量的字节数,所以要借助于vbs。
::On Error Resume Next
echo ' > nul &cls & @echo off
echo ' > nul & ...
上面的例子是4列,如果是5列、6列怎样写?
最后怎样输出到文档?
我是菜鸟!谢谢!
Originally posted by youxi01 at 2006-12-13 08:03 AM:
Personally, I think that pure P is difficult to implement because P has difficulty determining the number of bytes of variables, so we need to rely on vbs.
::On Error Resume Next
echo ' > nul &cls & @echo off
echo ' > nul & ...
How to write if it is 5 columns, 6 columns?
How to output to a document in the end?
I'm a noob! Thanks!
|
|
2008-5-13 11:10 |
|
|
cdswf
新手上路

积分 4
发帖 2
注册 2006-10-27
状态 离线
|
『第 28 楼』:
使用 LLM 解释/回答一下
ding!顶到出答案为止!!
ding! Top until the answer comes out!
|
|
2008-5-21 10:23 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 29 楼』:
答案:
使用 LLM 解释/回答一下
因论坛处理不了TAB,请运行前将!str!后面的空格改为TAB。
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%i in (a.txt) do (
for %%a in (%%i) do call set str=!str! %%a
echo !str:~1!&set str=
)
pause>nul
Because the forum can't handle TAB, please change the space after!str! to TAB before running.
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%i in (a.txt) do (
for %%a in (%%i) do call set str=!str! %%a
echo !str:~1!&set str=
)
pause>nul
|

批处理之家新域名:www.bathome.net |
|
2008-5-21 10:48 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 30 楼』:
29 楼
使用 LLM 解释/回答一下
zw19750516 兄想简单了。
先测试以下代码
@echo off
echo aaaaaaa bbbbbbbbb
echo aaaaaaaa bbbbbbbbb
echo aaaaaaaaaaaaaaaaa bbbbbbbbb
pause
更何况是中英文混合的。。。。。。。。。。
Brother zw19750516, you're oversimplifying.
First, test the following code:
@echo off
echo aaaaaaa bbbbbbbbb
echo aaaaaaaa bbbbbbbbb
echo aaaaaaaaaaaaaaaaa bbbbbbbbb
pause
Moreover, it's a mix of Chinese and English...
|

致精致简! |
|
2008-5-21 11:46 |
|