以下程序是 ms dos 的批处理文件,@echo off & setlocal enabledelayedexpansion::%1 -- String::%2 -- Filename::%3 -- Environment variable::%4 -- Start address::%5 -- get length::%6 -- which line that include string to get,default = 1 (first lin

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/27 17:36:12
以下程序是 ms dos 的批处理文件,@echo off & setlocal enabledelayedexpansion::%1 -- String::%2 -- Filename::%3 -- Environment variable::%4 -- Start address::%5 -- get length::%6 -- which line that include string to get,default = 1 (first lin

以下程序是 ms dos 的批处理文件,@echo off & setlocal enabledelayedexpansion::%1 -- String::%2 -- Filename::%3 -- Environment variable::%4 -- Start address::%5 -- get length::%6 -- which line that include string to get,default = 1 (first lin
以下程序是 ms dos 的批处理文件,
@echo off & setlocal enabledelayedexpansion::%1 -- String::%2 -- Filename::%3 -- Environment variable::%4 -- Start address::%5 -- get length::%6 -- which line that include string to get,default = 1 (first line include %1) ,-1 means last one if %5@==@ goto usageSet %3=Set Number_Of_Found_Word=-1if "%6"=="" ( set Expect_Found_Time=1 ) ELSE ( set Expect_Found_Time=%6 )For /F "skip=1 usebackq delims=" %%a IN (`find "%~1" %2`) Do call :set_env "%%a" %*endlocalcall out.batif exist out.bat del out.batgoto end:set_envshift::skip first line ,it is not content of target fileset /A Number_Of_Found_Word=%Number_Of_Found_Word%+1if not %Number_Of_Found_Word%==%Expect_Found_Time% if not %Expect_Found_Time%==-1 goto :eofset %3=%~0echo set %3=!%3:%4,%5!>out.batgoto :eof:usageEcho -Usage:Echo - Wjenv string filename environment_variable start_addr Length [times]Echo -Echo - Search "string" in "filename" ,Echo - and get "Length" chars from the line add offset "Start_addr"Echo - Then set to environment "environment_variable" .Echo -Echo - [times] is option argument to specified that get from which line that Echo - include "string" .Echo - 1 means first time ,-1 means last time.goto :eof:end

以下程序是 ms dos 的批处理文件,@echo off & setlocal enabledelayedexpansion::%1 -- String::%2 -- Filename::%3 -- Environment variable::%4 -- Start address::%5 -- get length::%6 -- which line that include string to get,default = 1 (first lin
@echo off & setlocal enabledelayedexpansion  //关闭显示并启用变量延迟,启用本地变量
:: %1 -- String     //字符串         //::标注  %1~%6是调用程序外部的参数
:: %2 -- Filename   //文件名
:: %3 -- Environment variable  //环境变量
:: %4 -- Start address   //开始地址
:: %5 -- get length   //获取长度
:: %6 -- which line that include string to get, default = 1 (first line include %1) ,-1 means last one   //获取字符串的行,默认为1,-1表示最后一行
  
if %5@==@ goto usage   //如果%5参数为空,就跳转到:usage处运行
Set %3=    //设置%3为空字符
Set Number_Of_Found_Word=-1    //设置Number_Of_Found_Word为-1
if "%6"=="" ( set Expect_Found_Time=1 ) ELSE ( set Expect_Found_Time=%6 )
//如果%6为空,则Expect_Found_Time=1,否则Expect_Found_Time为%6的值
For /F "skip=1 usebackq delims=" %%a IN (`find "%~1" %2`) Do call :set_env "%%a" %*
//for语句你需要好好了解一下,功能很强,需要多练.skip=1—跳过第一行进行操作,usebackq是增强型参数,没有它的话find语句只需用单引号括起来,用了之后需用`;delims是分隔符,默认是空格什么的.find "%~1" %2是遍历的数据集,在文件名为%2的文件中查找"%~1"这个字符串,如果查到了就执行do语句,这里是调用本程序的:set_env语句块,%*指从第一个参数到最后一个参数
endlocal   //结束本地变量,这个概念意思比如前面我定义了t这个变量,后来我再setlocal和endlocal里面重新定义了t,最后我还想使用先前定义的t,那么endlocal之后用的就是原来的了
call out.bat    //调用out.bat批处理
if exist out.bat del out.bat  //如果存在out.bat就删除它
goto end   //跳转到程序尾部,结束程序
 
:set_env   //名为set_env的语句块
shift   //这个命令还没用过,只知道一点概念,就不说了
:: skip first line , it is not content of target file  //注释
set /A Number_Of_Found_Word=%Number_Of_Found_Word%+1  //set /a表示进行数值运算,所以后面能用Number_Of_Found_Word=%Number_Of_Found_Word%+1,将变量Number_Of_Found_Word加1赋予自身,类似与其他语言的i++之类的
if not %Number_Of_Found_Word%==%Expect_Found_Time% if not %Expect_Found_Time%==-1 
goto :eof
//如果变量不等于Expect_Found_Time,而且Expect_Found_Time不等于-1,就结束程序
set %3=%~0    //将本程序名赋予参数%3,0表示本程序名称
echo set %3=!%3:%4,%5! >out.bat  //这里用到了变量延迟,!%3:%4,%5!的意思是截取字符串,重定向传给out.bat
goto :eof
//下面的echo就不说了,就是显示功能
:usage
Echo -Usage:
Echo -   Wjenv string filename environment_variable start_addr Length [times]
Echo -
Echo -    Search "string" in "filename" , 
Echo -    and get "Length" chars from the line add offset "Start_addr"
Echo -    Then set to environment "environment_variable" .
Echo -
Echo -    [times] is option argument to specified that get from which line that  
Echo -    include "string" .
Echo -    1 means first time , -1 means last time.
goto :eof
:end

以下程序是 ms dos 的批处理文件,@echo off & setlocal enabledelayedexpansion::%1 -- String::%2 -- Filename::%3 -- Environment variable::%4 -- Start address::%5 -- get length::%6 -- which line that include string to get,default = 1 (first lin MS-DOS是啥 以下关于操作系统说法错误的是( )1不能对计算机内存进行管理 2主要目的是使计算机系统方便使用 3MS-DOS是一种操作系统 4用户与计算机硬件之间的界面程序 ms-dos是什么英语单词的缩写? 下列选项中,具有汉字处理功能的系统软件是 【A】DOS 【B】UNIX 【C】UCDOS 【D】MS-DOS ms dos是什么 批处理文件前的@ECHO 批处理文件的@echo 下列软件中不属于操作系统的是A、MS-DOS B、OS/2 C、XENIX D、WORD 16bit ms-dos subsystem 批处理中的变量长度操作在一个批处理文件中有一个数字参数,是四位以下的整数.如何把它调整到固定位数(三位数,不到的前面补零,如果是三位数则不变)? 下列程序的功能是_____S=0i=1DOS=S+i^2i=i+2LOOP UNTIL i>999PRINT SEND dos下的scandisk和windows下的“磁盘扫描程序”有什么不同呢? DOS是啥意思? DOS的中文意思 给出以下一个算法的程序框图(如下图)该程序框图的功能是? 请问以下西班牙文的时间和日期分别是多少啊?1、dos horas veintiun minutos2、treinta y uno de diciembre de dos mil cinco3、veintiuno de diciembre de dos mil cinco 关于.bas,在线等!单位n年前的一个程序,是用basic.exe 调用cc.bas 文件,进入计算模式,是个dos程序,在命令提示下,输入basic cc 回车后即可运行程序,用VB6打开cc.bas是乱码,怎样才能获取程序的源码?N年