Page 1 of 1

How to catch empty value (TOO) in FOR loop?

Posted: 30 Aug 2008 08:23
by budhax
Hello,

From this file: in.sh droped on my script below, (indentation are tabs characters)

Code: Select all

#Comment
U1
   V11
      W111
      W112


I would get this output (and catch empty values too):
[U1] [] []
[] [V11] []
[] [] [W111]
[] [] [W112]


My script jump over empty value, and outputs this:

Code: Select all

[U1] [] []
[ "V11] [] []
[ "" "W111] [] []
[ "" "W112] [] []


How to catch empty values too? Thanks

Code: Select all

@ECHO OFF
@SETLOCAL ENABLEDELAYEDEXPANSION
CD /D "%~DP1"
IF "%~1"==""            (SET ErrU=1&GOTO:FinE)
IF /i NOT "%~x1"==".SH" (SET ErrE=1&GOTO:FinE)

ECHO.---------------------------
ECHO.Calcule en cours.
ECHO.Patientez ...
ECHO.

SET FNi=%~nx1
SET FNo=%~n1_.SH
FOR /f "SKIP=1 Delims=" %%f in ('TYPE "%FNi%"') DO (
   SET Li=%%f
   SET Li=!Li:   =" "!
   ::ECHO.[!Li!]
   FOR /f "Tokens=1-3 Delims=" %%u in ("!Li!") DO (ECHO.[%%~u] [%%~v] [%%~w])
)
GOTO:FinN


:FinE
COLOR 0C
IF DEFINED ErrF (ECHO.***  ERREUR: Fichier Absent!)
IF DEFINED ErrE (ECHO.***  ERREUR: De L'Extention!)
IF DEFINED ErrU (ECHO.***  USAGE : DRAG and DROP.!)
:FinN
ENDLOCAL&ECHO.&ECHO.Press To END ......&Pause>Nul&EXIT /b::_____________________

Posted: 31 Aug 2008 20:38
by carlitos.dll
The author has been removed this message.