China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-20 19:24
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Batch processing to display consecutive letters? View 4,622 Replies 20
Original Poster Posted 2007-01-09 17:32 ·  中国 湖南 长沙 电信
初级用户
★★
Credits 182
Posts 75
Joined 2006-10-11 00:10
19-year member
UID 65220
Gender Male
Status Offline
For example, if I enter "af", it displays:

a
b
c
d
e
f

Each letter occupies one line. I wonder if it can be achieved..
Floor 2 Posted 2007-01-09 17:38 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
I think it should not work, unless characters can be converted into numbers to run, and then numbers are converted back to letters after running. This is the same principle as the post I previously posted about ASCII code and conversion between letters and numbers.
Floor 3 Posted 2007-01-09 18:12 ·  美国 弗吉尼亚州 华盛顿县 Microsoft
高级用户
★★
Credits 783
Posts 268
Joined 2006-12-26 17:18
19-year member
UID 74627
Gender Male
Status Offline
Floor 4 Posted 2007-01-10 00:18 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The following is the translated content:

The demonstration code is as follows (no fault tolerance detection is done):

@echo off
set str=a b c d e f g h i j k l m n o p q r s t u v w x y z
:begin
cls
set flag=0
set var=
set input=
set /p input= Please enter the letter range (such as af):
for %%i in (%str%) do call :pickup %%i

:end
pause
goto begin

:pickup
if /i "%1"=="%input:~0,1%" set flag=1
if /i "%1"=="%input:~-1%" set flag=2
if %flag% equ 1 echo %1
if %flag% equ 2 echo %1&goto end
goto :eof
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
ccwan +5 2007-01-10 01:08
redtek +5 2007-01-10 01:13
online365 +2 2007-01-10 07:55
PPdos +2 2007-01-10 09:11
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 5 Posted 2007-01-10 02:09 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
Let's play too^_^

@echo off
setlocal enabledelayedexpansion

set str=a b c d e f g h i j k l m n o p q r s t u v w x y z
for %%i in (%str%) do set/a dec+=1 & set %%i=!dec! & set str!dec!=%%i
set en=
set /p en=Please enter the letter range (such as af):
set/a num1=!%en:~0,1%!,num2=!%en:~-1%!
for /l %%i in (%num1%,1,%num2%) do echo !str%%i!

pause>nul
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
namejm +4 2007-01-10 02:29
ccwan +5 2007-01-10 03:01
redtek +5 2007-01-10 08:04
PPdos +2 2007-01-10 09:12
Floor 6 Posted 2007-01-10 02:21 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
There is another one that is easier to understand:


@echo off
setlocal enabledelayedexpansion

set str=a b c d e f g h i j k l m n o p q r s t u v w x y z
set en=
set /p en=Please enter the letter range (such as af):
set str1=%en:~0,1%
set str2=%en:~-1%
for %%i in (%str%) do if %%i geq !str1! if %%i leq !str2! echo %%i
pause>nul
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
namejm +2 2007-01-10 02:29
online365 +2 2007-01-10 07:55
redtek +5 2007-01-10 08:04
PPdos +2 2007-01-10 09:12
Floor 7 Posted 2007-01-10 07:55 ·  中国 湖南 长沙 电信
初级用户
★★
Credits 182
Posts 75
Joined 2006-10-11 00:10
19-year member
UID 65220
Gender Male
Status Offline
Thank you, both.. ^_^
Floor 8 Posted 2007-01-10 09:05 ·  美国 弗吉尼亚州 华盛顿县 Microsoft
高级用户
★★
Credits 783
Posts 268
Joined 2006-12-26 17:18
19-year member
UID 74627
Gender Male
Status Offline
@echo off
:begin
set /p a="Old rules, hee hee :"
set str=a b c d e f g h i j k l m n o p q r s t u v w x y z
for %%i in (%str%) do echo %%i|findstr [%a:~0,1%-%a:~-1%]
goto:begin
Floor 9 Posted 2007-01-10 09:31 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Then I'll come to another paragraph:


@echo off
:begin
cls
set str=a b c d e f g h i j k l m n o p q r s t u v w x y z
set input=
set /p input= Please enter the letter range (such as af):
call set str=%%str:%input:~0,1%=-☆%input:~0,1%%%
call set str=%%str:%input:~-1%=%input:~-1%☆%%
for /f "tokens=2 delims=☆" %%i in ("%str%") do set str=%%i
for %%i in (%str%) do echo %%i
pause
goto begin


Simplify it further.

[ Last edited by namejm on 2007-1-9 at 08:35 PM ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 10 Posted 2007-01-10 22:38 ·  中国 辽宁 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
Join in the fun

m="a;b;c;d;e;f;g;h;i;j;k;l;m;n;o;p;q;r;s;t;u;v;w;x;y;z"
s=split(m,";")
b=inputbox("Please enter the letter range (e.g., af):","System Prompt")
l=0
for i=0 to 25
if s(i)=left(b,1) then
l=1
end if
if l=1 then
h=h&vbcrlf&s(i)
end if
if s(i)=right(b,1) then exit for
next
msgbox h
Floor 11 Posted 2007-01-11 02:26 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
Originally posted by jmz573515 at 2007-1-10 10:38 PM:
Join in the fun

m="a;b;c;d;e;f;g;h;i;j;k;l;m;n;o;p;q;r;s;t;u;v;w;x;y;z"
s=split(m,";")
b=inputbox("Please enter the letter range (such as af):","System Prompt")
l= ...

If it's VBS, there's no need to be so complicated! Just use a simple for loop to get it done
Floor 12 Posted 2007-01-11 02:57 ·  中国 辽宁 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
I also hope the friend on the 11th floor can give some guidance. I'm just a beginner in VBS and don't know much about it. Thanks!
Floor 13 Posted 2007-02-04 08:52 ·  中国 安徽 芜湖 电信
高级用户
★★
Credits 537
Posts 219
Joined 2006-10-31 21:08
19-year member
UID 69036
Gender Male
From 芜湖
Status Offline
Today I finally understood the code on the 5th floor of the boss.
江湖远
碧空长
路茫茫

一个人漫无目的的奔跑,风,刺骨的冷....
Floor 14 Posted 2007-02-04 10:41 ·  中国 甘肃 兰州 城关区 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Can the ASCII code be useful?
Floor 15 Posted 2007-02-04 10:57 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Used to process ASCII code?
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Forum Jump: