我试图从档案中读到文字线,并增加反面,以便我最终能够模拟监督事务司的一个阵列。
因此,我能够把案文线储存在监督事务司的一个阵列中,以供进一步处理。
我目前的尝试是:
set TEXT_T="myfile.txt"
set /a c=1
FOR /F "tokens=1 usebackq" %%i in (%TEXT_T%) do (
set /a c=c+1
echo %%i, %c%
)
但是,变数c并不增加;它停留在1。
建议值得欢迎。
谢克
我试图从档案中读到文字线,并增加反面,以便我最终能够模拟监督事务司的一个阵列。
因此,我能够把案文线储存在监督事务司的一个阵列中,以供进一步处理。
我目前的尝试是:
set TEXT_T="myfile.txt"
set /a c=1
FOR /F "tokens=1 usebackq" %%i in (%TEXT_T%) do (
set /a c=c+1
echo %%i, %c%
)
但是,变数c并不增加;它停留在1。
建议值得欢迎。
谢克
贵岛法典的问题在于如何扩大变量。 发言一读,通常进行可变的扩展。 在您的情形下,将整条FOR
的路程及其组体改为,除循环变量外,所有变量均已扩大至其现值。
这意味着 页: 1 即时扩大,实际上在每一轮机中作为<代码>echo%i, 1
。
因此,你们所需要的是延迟的变数扩大。 http://www.robvanderwoude.com/variableexpansion.php“rel=“noreferer”>。
应加以扩大的变式可参考! 缩略语 但是,你需要用<条码>启动这一特征,并用“相匹配代码”重新编号。
你修改的法典将探讨这样的问题:
set TEXT_T="myfile.txt"
set /a c=1
setlocal ENABLEDELAYEDEXPANSION
FOR /F "tokens=1 usebackq" %%i in (%TEXT_T%) do (
set /a c=c+1
echo %%i, !c!
)
endlocal
我要补充的是,如果在你产生地方变量时,它们也需要利用禁忌(!)的 not子扩大。 https://stackoverflow.com/a/2919699” 上文,如果我们想建立反基产出档案名称的话。
set TEXT_T="myfile.txt"
set /a c=1
setlocal ENABLEDELAYEDEXPANSION
FOR /F "tokens=1 usebackq" %%i in (%TEXT_T%) do (
set /a c=c+1
set OUTPUT_FILE_NAME=output_!c!.txt
echo Output file is !OUTPUT_FILE_NAME!
echo %%i, !c!
)
endlocal
或者,如果不使用拖延,你可以这样做。
set /a "counter=0"
- &;
do (
statement1
statement2
call :increaseby1
)
:increaseby1
set /a "counter+=1"
set TEXT_T="myfile.txt"
set /a c=1
FOR /F "tokens=1 usebackq" %%i in (%TEXT_T%) do (
set /a c+=1
set OUTPUT_FILE_NAME=output_%c%.txt
echo Output file is %OUTPUT_FILE_NAME%
echo %%i, %c%
)
对于这一简单法典,我和Windows 7的工作是什么
set cntr=1
:begin
echo %cntr%
set /a cntr=%cntr%+1
if %cntr% EQU 1000 goto end
goto begin
:end
I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...
I have two arrays for a chess variant I am coding in java...I have a console version so far which represents the board as a 1D array (size is 32) but I am working on making a GUI for it and I want it ...
Surely there is a framework method that given an array of integers, strings etc converts them into a list that can be used in a SQL "IN" clause? e.g. int[] values = {1,2,3}; would go to "(1,2,3)"
So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...
Stuck on an array sorter. Have to sort numbers from largest to smallest. I m trying two loops (one nested in the other). Here s the code: int counter=0; // inner counter int counter2=0; // outer ...
I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...
sry for this imprecise topic name. I am querying a dataset a lot of times so using ajax request would end up in tons of http requests. For this reason I decided to use the json encode method to ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....