PBX の電話長距離交換情報を含むテキスト ファイルがあります。入力ファイルには次が含まれます。
sourceNPA,srcNNX,DestinationNPA,destNNX
954,327,954,201
954,327,954,202
954,327,954,203
954,327,954,210
954,327,954,212
954,327,954,213
954,327,954,214
etc...
会社のポリシー上の理由から (私がコーダーではないという理由だけでなく)、VBS または Windows バッチ以外は使用できません。これらを手動で行うことが期待されていますが、範囲に変換する必要があるのは 43000 以上です。
指定されたテキスト ファイルの各行を読み取る必要があります。dNPA と dNXX (各行の最後の 2 つの引数) が連続しているかどうかを確認し、連続している場合は範囲を決定して、入力リストが出力で次のように読み取られるようにします。
954,327,954,201,203
954,327,954,210,210
954,327,954,212,214
etc...
配列の使用法を調べて、一時ファイルに 1 行を読み取ろうとしましたが、これにはトリックが必要です。
私はいじくり回してきましたが、それを示すことはほとんどありません:
@echo off
setlocal enabledelayedexpansion
set lineNumber=1
if exist outputFile.txt del outputFile.txt
for /f "tokens=1-6 delims=,;" %%a in (inputFile.txt) do call :process %%a %%b %%c %%d
:EOF
:process
set line!linenumber!SrcNPA=%1
set line!linenumber!SrcNNX=%2
set line!linenumber!destNPA=%3
set line!linenumber!destNNX=%4
REM then intended to compare the values but I'm stuck
REM I want to compare the last arugment of each line to the same
REM same argument in the next line read, and if its sequential
REM then set the start the range and when the comaparison is no longer
REM consecutive set the top of the range andn then write that range to output
set /a lineNumber+=1