Func _SQLite_SQLiteExe($sDatabaseFile, $sInput, ByRef $sOutput, $sSQLiteExeFilename = -1, $bDebug = False) If $sSQLiteExeFilename = -1 Or $sSQLiteExeFilename = Default Then $sSQLiteExeFilename = "sqlite3.exe" If Not FileExists($sSQLiteExeFilename) Then Local $sInlineVersion = "_" & Call('__SQLite_Inline_Version') If @error Then $sInlineVersion = "" ; no valid SQLite version define so use any version Local $sSQLiteExe_FilePath = @TempDir & "\" $sSQLiteExeFilename = __SQLite_Download_SQLite3File($sSQLiteExe_FilePath, "sqlite3", $sInlineVersion, ".exe", True) MsgBox(0,"","download") If @error Then Return SetError(2, 0, $SQLITE_MISUSE) ; Can't Found sqlite3.exe $sSQLiteExeFilename = $sSQLiteExe_FilePath & $sSQLiteExeFilename EndIf EndIf If Not FileExists($sDatabaseFile) Then Local $hNewFile = FileOpen($sDatabaseFile, $FO_OVERWRITE + $FO_CREATEPATH) If $hNewFile = -1 Then Return SetError(1, 0, $SQLITE_CANTOPEN) ; Can't Create new Database EndIf FileClose($hNewFile) EndIf Local $sInputFile = _TempFile(), $sOutputFile = _TempFile(), $iRval = $SQLITE_OK Local $hInputFile = FileOpen($sInputFile, $FO_OVERWRITE) If $hInputFile > -1 Then $sInput = ".output stdout" & @CRLF & $sInput FileWrite($hInputFile, $sInput) FileClose($hInputFile) Local $sCmd = @ComSpec & " /c " & FileGetShortName($sSQLiteExeFilename) & ' "' _ & FileGetShortName($sDatabaseFile) _ & '" > "' & FileGetShortName($sOutputFile) _ & '" < "' & FileGetShortName($sInputFile) & '"' Local $nErrorLevel = RunWait($sCmd, @WorkingDir,@SW_HIDE) MsgBox(0,"",@error) ;error=0 $nErrorLevel=1 If $bDebug = True Then Local $nErrorTemp = @error If @error Then __SQLite_Print('@@ Debug(_SQLite_SQLiteExe) : $sCmd = ' & $sCmd & @CRLF & '>ErrorLevel: ' & $nErrorLevel & @CRLF) SetError($nErrorTemp) EndIf MsgBox(0,"",$nErrorLevel) If @error = 1 Or $nErrorLevel = 1 Then $iRval = $SQLITE_MISUSE ; SQLite.exe not found Else $sOutput = FileRead($sOutputFile, FileGetSize($sOutputFile)) If StringInStr($sOutput, "SQL error:", 1) > 0 Or StringInStr($sOutput, "Incomplete SQL:", 1) > 0 Then $iRval = $SQLITE_ERROR ;MsgBox(0,"",$iRval); SQL error / Incomplete SQL EndIf EndIf Else $iRval = $SQLITE_CANTOPEN ; Can't open Input File EndIf If FileExists($sInputFile) Then FileDelete($sInputFile) Switch $iRval Case $SQLITE_MISUSE SetError(2) ;MsgBox(0,"",$sSQLiteExeFilename) Case $SQLITE_ERROR SetError(3) Case $SQLITE_CANTOPEN SetError(4) EndSwitch Return $iRval EndFunc ;==>_SQLite_SQLiteExe
I test the UDF _SQLite_SQLiteExe in help file the result is" Can't Found sqlite3.exe" . I find the reason is @error=0 but $nErrorLevel=1which return from RunWait(). why??