Jump to content

Exit Code error but only as .au3 not .exe


Dude
 Share

Recommended Posts

Hello, i have this script. If i run it as .au3 i get Exit Code: -1073741819. If i compile
this script and run it as .exe it runs without error?!

It will exit at this point:
_FileReadDbf

#include <Excel.au3>
#include <File.au3>
#include <Date.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>

;$lw="s:"
$lw = "d:"

Global $x = 1

FileDelete($lw & "\Arbeit\KV_Genehmigungen\KV-Genehmigungen_3M.ini")

$kopieren1 = FileCopy($lw & "\COSINOS\Daten\OC\DbAckermann\rezept.dbf", @TempDir & "\rezept.dbf", 1)
If $kopieren1 <> 1 Then
    MsgBox(262192, "Fehler", "Die Datei REZEPT.DBF konnte nicht kopiert werden! Bitte an die EDV wenden.", 0)
    Exit
EndIf

$aData = _FileReadDBF(@TempDir & "\rezept.dbf", 1, False) ;2 = OEM zu ANSI

msgbox(0,"test","test")

_ArraySort($aData, 0, 0, 0, 3) ;Sortieren KV Datum Absteigend 41 - 1 vorne = Absteigend

$Anzahl_Rezepte = UBound($aData)

Do
    $Kundennummer = StringStripWS($aData[$x][0], 8) ; 8 entfernt alle Leerzeichen
    $Rezeptnummer = StringStripWS($aData[$x][1], 8) ; 8 entfernt alle Leerzeichen
    $Name = StringStripWS($aData[$x][2], 3) ; 3 entfernt nur vorne und hinten
    $Versart = StringStripWS($aData[$x][3], 3) ; 3 entfernt nur vorne und hinten
    $Kasse = StringStripWS($aData[$x][20], 3) ; 3 entfernt nur vorne und hinten
    $KVDatum = StringStripWS($aData[$x][45], 3) ; 3 entfernt nur vorne und hinten
    $KVGDatum = StringStripWS($aData[$x][46], 3) ;3 entfernt nur vorne und hinten
    $Lieferdatum = StringStripWS($aData[$x][40], 3)
    $VNummer = StringStripWS($aData[$x][31], 3)
    $Aktenzeichen = StringStripWS($aData[$x][84], 3)
    $KVDatumFormat_Jahr = StringLeft($KVGDatum, 4)
    $KVDatumFormat_Monat = StringMid($KVGDatum, 5, 2)
    $KVDatumFormat_Tag = StringRight($KVGDatum, 2)
    $KVDatumkomplett = $KVDatumFormat_Jahr & "/" & $KVDatumFormat_Monat & "/" & $KVDatumFormat_Tag
    
    If $Kundennummer = "107580" Or $Kundennummer = "123440" Then
        $Testkunde = 1
    Else
        $Testkunde = 0
    EndIf
        
    If $KVDatum <> 0 And $KVGDatum <> 0 And $Testkunde = 0 Then
        If $KVDatumFormat_Jahr = @YEAR Or $KVDatumFormat_Jahr = @YEAR - 1 Then ; Nur das aktuelle Jahr und + 1
            $Datumsunterschied = _DateDiff('M', $KVDatumkomplett, _NowCalc())
            ;################# Test ##########
            Global $LVA = StringInStr($Kasse, "LVA")
            Global $Arbeitsamt = StringInStr($Kasse, "Arbeitsamt")
            Global $Bahn_See = StringInStr($Kasse, "Bahn See")
            Global $BG = StringInStr($Kasse, "BG", 1)
            Global $Unfallkasse = StringInStr($Kasse, "Unfallkasse")
            Global $OVST = StringInStr($Kasse, "OVST")
                    
            ;if $BG <> 0 Or $Unfallkasse <> 0 Or $OVST <> 0 OR $Versart = "ASKonfektion" Or $Versart = "Berufsschuhe" Or $Versart = "Arbeitsschuhe" Or $LVA <> 0 Or $Arbeitsamt <> 0 Or $Bahn_See <> 0 Then
            ;   $zeitspanne = 3 ;3 Monate
            ;Else
                $zeitspanne = 3 ;3 Monate
            ;EndIf
            ;###################
            
            If $Datumsunterschied >= $zeitspanne And $Lieferdatum = 0 Then
                IniWrite($lw & "\Arbeit\KV_Genehmigungen\KV-Genehmigungen_3M.ini", $Kundennummer & "_" & $Rezeptnummer, "Kundennummer", $Kundennummer)
                IniWrite($lw & "\Arbeit\KV_Genehmigungen\KV-Genehmigungen_3M.ini", $Kundennummer & "_" & $Rezeptnummer, "Rezeptnummer", $Rezeptnummer)
                IniWrite($lw & "\Arbeit\KV_Genehmigungen\KV-Genehmigungen_3M.ini", $Kundennummer & "_" & $Rezeptnummer, "Name", $Name)
                IniWrite($lw & "\Arbeit\KV_Genehmigungen\KV-Genehmigungen_3M.ini", $Kundennummer & "_" & $Rezeptnummer, "Versorgungsart", $Versart)
                IniWrite($lw & "\Arbeit\KV_Genehmigungen\KV-Genehmigungen_3M.ini", $Kundennummer & "_" & $Rezeptnummer, "Kasse", $Kasse)
                IniWrite($lw & "\Arbeit\KV_Genehmigungen\KV-Genehmigungen_3M.ini", $Kundennummer & "_" & $Rezeptnummer, "KVDatum", $KVDatum)
                if $VNummer = "" OR $VNummer = "0" OR $BG <> 0 OR $LVA <> 0 OR $Arbeitsamt <> 0 OR $Bahn_See <> 0 OR $Unfallkasse <> 0 OR $OVST <> 0 Then
                    IniWrite($lw & "\Arbeit\KV_Genehmigungen\KV-Genehmigungen_3M.ini", $Kundennummer & "_" & $Rezeptnummer, "Versichertennummer", $Aktenzeichen)
                Else
                    IniWrite($lw & "\Arbeit\KV_Genehmigungen\KV-Genehmigungen_3M.ini", $Kundennummer & "_" & $Rezeptnummer, "Versichertennummer", $VNummer)
                EndIf
;~              EndIf
            EndIf
        EndIf
    EndIf
    $x = $x + 1
Until $x = $Anzahl_Rezepte

Exit

Func _FileReadDBF($sFileName, $nFlags = 0, $lDeleted = True)
    Local $hFile = FileOpen($sFileName, 16)
    Local $pReadBuffer = DllStructCreate("byte[32]") ; Header size
    DllStructSetData($pReadBuffer, 1, FileRead($hFile, 32))
    $pDBFHeader = DllStructCreate("byte;byte;byte;byte;int;short;short;byte[20]", DllStructGetPtr($pReadBuffer)) ; Header struct
    $nRecords = DllStructGetData($pDBFHeader, 5) ; Get number of records
    $nDataPos = DllStructGetData($pDBFHeader, 6) ; Get data start position
    $nRecordSize = DllStructGetData($pDBFHeader, 7) ; Get record size (included deleted flag)
    $nFields = Floor($nDataPos / 32) - 1
    $nDataGap = $nDataPos - ($nFields + 1) * 32

    Local $aData[$nRecords + 1][$nFields]
    Local $sRecordStruct = "byte;" ; Struct string, based on fields size and type, first byte - deleted mark

    For $i = 0 To $nFields - 1
        DllStructSetData($pReadBuffer, 1, FileRead($hFile, 32))
        $pField = DllStructCreate("char[11];byte;int;byte;byte[15]", DllStructGetPtr($pReadBuffer)) ; Field structure
        $aData[0][$i] = DllStructGetData($pField, 1) ; Name of field
        ; Create struct based on field size and type (now unfinished, treat all types as string)
        Switch DllStructGetData($pField, 2)
            Case Asc("C") Or Asc("D") ;or Else
                $sRecordStruct &= "char[" & DllStructGetData($pField, 4) & "];"
        EndSwitch
    Next

    $sRecordStruct = StringTrimRight($sRecordStruct, 1) ; Trim last ";"

    FileRead($hFile, $nDataGap) ; Skip ending marker, it's size may vary

    $pReadBuffer = DllStructCreate("byte[" & $nRecordSize & "]") ; New buffer, now based on record size

    Local $nRow = 1, $cDeleted

    For $i = 1 To $nRecords
        DllStructSetData($pReadBuffer, 1, FileRead($hFile, DllStructGetSize($pReadBuffer)))
        $pRecord = DllStructCreate($sRecordStruct, DllStructGetPtr($pReadBuffer))

        $cDeleted = Chr(DllStructGetData($pRecord, 1))

        If $lDeleted Or $cDeleted <> '*' Then
            For $j = 0 To $nFields - 1
                $aData[$nRow][$j] = DllStructGetData($pRecord, $j + 2)
                If BitAND($nFlags, 1) Then $aData[$nRow][$j] = _Ascii2Ansi($aData[$nRow][$j])
                If BitAND($nFlags, 2) Then $aData[$nRow][$j] = StringStripWS($aData[$nRow][$j], 3)
            Next

            $nRow += 1
        EndIf
    Next
    FileClose($hFile)
    Return $aData
EndFunc   ;==>_FileReadDBF

Func _Ascii2Ansi($sText)
    Local $src = DllStructCreate("char[" & StringLen($sText) + 1 & "]")
    Local $dst = DllStructCreate("char[" & StringLen($sText) + 1 & "]")
    DllStructSetData($src, 1, $sText)
    DllCall("user32.dll", "int", "OemToCharA", "ptr", DllStructGetPtr($src), "ptr", DllStructGetPtr($dst))
    Return DllStructGetData($dst, 1)
EndFunc   ;==>_Ascii2Ansi

 

Link to comment
Share on other sites

  • Moderators

The error is a file access error if I remember correctly.

Are you running either one in admin mode?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...