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-25 21:16
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to implement option content where the numbers are obtained from a text file View 3,244 Replies 8
Original Poster Posted 2006-12-13 09:46 ·  中国 北京 鹏博士BGP
初级用户
Credits 114
Posts 47
Joined 2006-11-20 04:17
19-year member
UID 71105
Gender Male
Status Offline
echo ╭────────╮
echo ╭─────┤ Options ├─────────╮
echo │ ╰────────╯ │
echo │ 1. ++++++++ │
echo │ │
echo │ 2. fdfdfd │
echo │ │
echo │ 3. gfgfg │
echo │ │
echo ╰──────────────────────────╯
echo.

How to implement the option content, where the numbers are obtained from a text file in the same directory,

The text file format:

1. ++++++++
2. fdfdfd
3. gfgfg
Floor 2 Posted 2006-12-13 10:08 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
It can be achieved, but after reading, it is not necessarily guaranteed to be a rectangular box.
Floor 3 Posted 2006-12-13 11:30 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
```
@echo %dbg% off && setlocal enabledelayedexpansion

:: Total length: 60
:: Menu offset: 18
:: Extraction: ~0,59 (last character filled with "│" character)
:: Formula: fill with │


set "space= "
set "vol= │ "
echo ╭────────╮
echo ╭─────┤ Options ├─────────╮
echo │ ╰────────╯ │

for /f "tokens=1* delims=" %%i in (menu.txt) do (
set a=%vol%%%i%space%
echo !a:~0,59!│
echo │ │
)
echo │ │
echo │ │
echo │ │
echo ╰────────────────────────╯
echo.

```

The pasted format looks messy. The completed source code and menu file are compressed into an attachment and uploaded, which is convenient for the landlord to debug: )
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
lxmxn +5 2006-12-14 00:51
ccwan +5 2006-12-14 00:52
a9319751 +3 2006-12-14 01:06
hxuan999 +2 2006-12-14 02:33
Attachments
menu.rar (506 bytes, Credits to download 1 pts, Downloads: 47)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 4 Posted 2006-12-14 00:51 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Brother Redtek wrote wonderfully. Add points~~
Floor 5 Posted 2006-12-14 00:53 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Protest! I am too restricted in adding points.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 6 Posted 2006-12-14 02:32 ·  中国 浙江 宁波 鹏博士宽带
荣誉版主
★★★
Credits 1,338
Posts 356
Joined 2005-07-15 12:09
20-year member
UID 40733
Gender Male
Status Offline
RE redtek 兄
When posting, selecting the font "SimSun" can achieve monospacing display.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +5 2006-12-14 21:43
  ☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul

Floor 7 Posted 2006-12-14 05:07 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
Originally posted by redtek at 2006-12-13 11:30:

@echo %dbg% off && setlocal enabledelayedexpansion

:: Total length: 60
:: Menu offset: 18
:: Extraction: ~0,59 (complement the last character with "│" character)
:: Formula ...


It is suggested that you modify the code further. When testing your code, if the content in the original menu memu.txt is used, the menu is not messy. But if I modify the content in menu.txt, the menu changes. The key is that the final "|" character is misaligned. If the following functions can be realized, it will be great:
1. Let users freely customize the content in memu.txt,
2. Save the user-defined menu items to variables to realize jumping to the corresponding menu program.
Floor 8 Posted 2006-12-14 05:24 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
For the content containing Chinese characters, using the above method will result in the final "|" character being misaligned. So it is best to calculate the number of bytes.

[ Last edited by zh159 on 2006-12-13 at 04:25 PM ]
Floor 9 Posted 2008-06-01 10:14 ·  中国 山东 济南 联通
新手上路
Credits 2
Posts 1
Joined 2008-05-31 16:32
18-year member
UID 120204
Gender Male
Status Offline
Nice
Forum Jump: