中国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-09-23 22:09
47,812 topics / 349,917 posts / today 0 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » [Help] How to align text with bat?
Printable Version  6,191 / 30
Floor16 ccwan Posted 2006-12-14 02:59
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
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?
Floor17 无奈何 Posted 2006-12-14 03:23
荣誉版主 Posts 356 Credits 1,338
There is no problem here. Which line is missing? There is a small problem. Blank lines will also be output. Fix it.
Floor18 ccwan Posted 2006-12-14 03:31
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
The new code is fine!
What does adding the if statement mean?
Floor19 HUNRYBECKY Posted 2006-12-14 03:43
银牌会员 Posts 442 Credits 1,179
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?
Floor20 HUNRYBECKY Posted 2006-12-14 04:03
银牌会员 Posts 442 Credits 1,179
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.
Floor21 无奈何 Posted 2006-12-14 04:03
荣誉版主 Posts 356 Credits 1,338
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.
Floor22 ccwan Posted 2006-12-14 04:07
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Thanks.
It seems necessary to learn.
Floor23 pengfei Posted 2006-12-14 04:41
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
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 ^_^
Floor24 youxi01 Posted 2006-12-14 04:42
高级用户 Posts 247 Credits 846 From 湖南==》广东
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!
Floor25 youxi01 Posted 2006-12-14 04:46
高级用户 Posts 247 Credits 846 From 湖南==》广东
Originally posted by HUNRYBECKY at 2006-12-14 04:03 AM:

Can you explain the mechanism of writing and running VBS scripts in BAT? I don't understand at all how it executes. Thanks!


In P processing, lines starting with :: are ignored (considered as explanatory statements), but when it runs as VBS, it can be recognized; at the same time, in VBS, content after ' is considered as comment content......

Refer to: http://www.cn-dos.net/forum/viewthread.php?tid=25333&fpage=1&highlight=%E8%AF%86%E8%B4%A7&page=1
Floor26 vkill Posted 2006-12-14 05:37
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
I think the effect of awk is really good
Floor27 cdswf Posted 2008-05-13 11:10
新手上路 Posts 2 Credits 4
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.
Floor28 cdswf Posted 2008-05-21 10:23
新手上路 Posts 2 Credits 4
ding! Top until the answer comes out!
Floor29 bat-zw Posted 2008-05-21 10:48
金牌会员 Posts 1,276 Credits 3,105
Because the forum can't handle TAB, please change the space after!str! to TAB before running.
Floor30 26933062 Posted 2008-05-21 11:46
银牌会员 Posts 879 Credits 2,268
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...
Prev  1 2 3  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023