Archive: txt-file parsing


txt-file parsing
Hi all!
I need to execute sql query to MS SQL Date base.
Use this metod:

ExecWait '"sqlcmd" -S "$DB_server" -U "$DB_user" -P "$DB_password" -d "$DB_name" -i "$Temp\NS_Fix_IIRF\get_revision.sql" -o "$Temp\NS_Fix_IIRF\result.txt"'


Result:

STR
--------------------
0400

(обработано строк: 1)


Parsing file:

ClearErrors
FileOpen $0 "$Temp\NS_Fix_IIRF\result.txt" r
IfErrors done
${While} $1 != "0400" ;Определяем номер ревизии по результату запроса к БД
FileRead $0 $1
StrCpy "$1" "$1" 4
${EndWhile}
StrCpy "$REV" $1
FileClose $0
done:


If in file is present 0400 - all work fine. Else cycle holds infinitely.

How fix this problem?
Tnx!


ClearErrors
FileOpen $0 "$Temp\NS_Fix_IIRF\result.txt" r
IfErrors done

loop:
FileRead $0 $1
IfErrors close
StrCpy "$1" "$1" 4
${If} $1 == "0400"
StrCpy "$REV" $1
goto close
${EndIf}
goto loop

close:
FileClose $0
done:

Did you know you can execute an sql script with the following Plugin?
http://nsis.sourceforge.net/MSSQL_OLEDB_plug-in