computing
  • 0

Solved Setting Parameters Using Tab Delimited Text File/Batch

  • 0

I am trying to set a parameter using tab delimited text files. I have never done this so as far as troubleshooting it, I am stuck. The code I came up with doesn’t return anyting, and I can’t find any hints or examples as to how to do this anywhere I search. My code is as follows

for /f “tokens=6 delims=” %%i in (%Server%%ParamS:~0,3%\%ParamS:~0,5%\%ParamS%\Support\%Param%.txt) do (
set ParamD=%%i
)
Echo. %ParamD%
Pause

The line of text I am trying to use for ParamD will always be on the first row, directly after the 6th tab.

I don’t know what I’m doing wrong, can someone please help?

Share

1 Answer

  1. The “delims=” is killing it. Run without that clause:
    for /f “tokens=6” %%i in (%Server%%ParamS:~0,3%\%ParamS:~0,5%\%ParamS%\Support\%Param%.txt) do (
    set ParamD=%%i
    )
    This will default to delims as tabs and spaces. (“delims=” means no delimiters in effect). Note that spaces in the data might still kill you since those and tabs are counted equally. If that happens, you need to specify the TAB only. A sample of the data-file would help to resolve.
    ps: I recommend always run tests with cascading complexity. Run initial tests with bare minimum (both code AND data),, then work up from there, and use LOTS of echos and pauses to examine variable values and code-location.

    message edited by nbrane

    • 0