Jump to content

Recommended Posts

@iamtheky
Thanks for your help!
I'm having this issue:
 

Subscript used on non-accessible variable.

I read on the forum that it is caused by "maybe a not valid array", and, since I'm using a function that returns the _Excel_RangeRead() of one of my manufacturers warehouse, like this function does ( my code ):

 

Func LeggiGiacenzeSiemens()
    Local $oExcel = _Excel_Open(False)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Errore!", "Errore durante la creazione dell'oggetto Excel." & @CRLF & "Errore: " & @error & ", Informazioni: " & @extended)
        Exit
    EndIf
    Local $oWorkbook = _Excel_BookOpen($oExcel, $sFileDatabaseMagazzino, False)
    If @error Then
        MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file '" & $sFileDatabaseMagazzino & "'." & @CRLF & "Errore: " & @error)
        Exit
    EndIf
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Errore!", "Errore durante l'apertura della Cartella di Lavoro '" & @ScriptDir & $sFileDatabaseMagazzino & "'." & @CRLF & "Errore: " & @error & ", Informazioni: " & @extended)
        _Excel_Close($oExcel)
        Exit
    EndIf
    $oWorkbook.Sheets("Magazzino Siemens").Activate
    Local $aRisultatoSiemens = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:H"), 1)
    For $i = UBound($aRisultatoSiemens) - 1 To 4 Step -1
        If($aRisultatoSiemens[$i][4] = "") Then _ArrayDelete($aRisultatoSiemens, $i)
    Next
    _Excel_Close($oExcel)
    Return $aRisultatoSiemens
EndFunc ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LeggiGiacenzeSiemens()

I don't know why I have this kind of error... :blink:
I tested a lot of times, and it worked a lot of times, but know, seems dead... 
You can find all the materials I am using ( know I am making some changes ) in the #1 post.
Thank you! :) 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Do you see the error checking on Excel Open? 

Do you see the lack of error checking on Excel_RangeRead? 

Do you see the lack of debugging in the loop to maybe If its not array don't run the loop and msgbox the contents of $aRisultattoSiemens.

 

You must do the most basic of error checking and debugging, or we will berate you while helping...it's in our nature.

 

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

@iamtheky
You're right, sorry! :D
And, thanks to your suggestion, I've found the error: ( but still doesn't fixed )

Func LeggiGiacenzeSiemens()
    Local $oExcel = _Excel_Open(False)
    If @error Then ; Error Checking!
        MsgBox($MB_SYSTEMMODAL, "Errore!", "Errore durante la creazione dell'oggetto Excel." & @CRLF & "Errore: " & @error & ", Informazioni: " & @extended)
        Exit
    EndIf
    Local $oWorkbook = _Excel_BookOpen($oExcel, $sFileDatabaseMagazzino, False)
    If @error Then ; Error Checking!
        MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file '" & $sFileDatabaseMagazzino & "'." & @CRLF & "Errore: " & @error)
        Exit
    EndIf
    $oWorkbook.Sheets("Magazzino Siemens").Activate
    Local $aRisultatoSiemens = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:I"), 1)
    If(@error) Then ; Error Checking!
        MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura del foglio 'Magazzino Siemens'." & @CRLF & "Errore: " & @error & "Dettagli: " & @extended) ; >>>>> Error '5' here! Added extended too...
    EndIf
    For $i = UBound($aRisultatoSiemens) - 1 To 4 Step -1
        If($aRisultatoSiemens[$i][4] = "") Then
            _ArrayDelete($aRisultatoSiemens, $i)
            If (@error) Then ; Error Checking!
                MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'eliminazione dell'elemento " & $i & "." & @CRLF & "Errore: " & @error)
            EndIf
        EndIf
    Next
    _Excel_Close($oExcel)
    Return $aRisultatoSiemens
EndFunc ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LeggiGiacenzeSiemens()

Know I'm seeing how to fix it!
Error is set to 5, Extended is set to -2147352571.
What is that?! :blink:

EDIT:

Strangely, Excel see over 65536 rows in my Excel file, while I just have 58 "non empty". I managed to do the reading setting the $bForceFunc to True.

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Then build a loop for the range read and only read row $i

Do that in reasonable chunks and filewrite them, that way when it fails you know which chunk.

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Now I'm having a problem with "Concatenate two 2D arrays which have two different size ( the second array has 1 column more than the first array ).
How can I do it? Have I to insert a "dummy" column that I will never use, to concatenate arrays?
Thanks guys ^^ :) 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

yup or see what arrayadd does when you try to add the smaller one to the bigger one?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

@iamtheky
I'm proceeding in this way:
 

Func LeggiTutteLeGiacenze()
    Local $oExcel = _Excel_Open(False)
    If(@error) Then ; Error Checking!
        MsgBox($MB_SYSTEMMODAL, "Errore!", "Errore durante la creazione dell'oggetto Excel." & @CRLF & "Errore: " & @error & @CRLF & "Dettagli errore: " & @extended)
        Exit
    EndIf
    Local $oWorkbook = _Excel_BookOpen($oExcel, $sFileDatabaseMagazzino, False)
    If(@error) Then ; Error Checking!
        MsgBox($MB_SYSTEMMODAL, "Errore!", "Errore durante l'apertura della Cartella di Lavoro '" & @ScriptDir & $sFileDatabaseMagazzino & "'." & @CRLF & "Errore: " & @error & ", Dettagli errore: " & @extended)
        _Excel_Close($oExcel)
        Exit
    EndIf
    $oWorkbook.Sheets("Magazzino Rockwell").Activate
    Local $aRisultatoRockwell = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:J"), 1, True)
    If(@error) Then ; Error Checking!
        MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura del foglio 'Magazzino Siemens'." & @CRLF & "Errore: " & @error & @CRLF & "Dettagli errore: " & @extended)
    EndIf
    For $i = UBound($aRisultatoRockwell) - 1 To 4 Step -1
        If($aRisultatoRockwell[$i][4] = "") Then
            _ArrayDelete($aRisultatoRockwell, $i)
            If(@error) Then ; Error Checking!
                MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'eliminazione dell'elemento " & $i & "." & @CRLF & "Errore: " & @error)
            EndIf
        EndIf
    Next
    $oWorkbook.Sheets("Magazzino Siemens").Activate
    Local $aRisultatoSiemens = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:I"), 1, True)
    If(@error) Then ; Error Checking!
        MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura del foglio 'Magazzino Siemens'." & @CRLF & "Errore: " & @error & @CRLF & "Dettagli errore: " & @extended)
    EndIf
    For $i = UBound($aRisultatoSiemens) - 1 To 4 Step -1
        If($aRisultatoSiemens[$i][4] = "") Then
            _ArrayDelete($aRisultatoSiemens, $i)
            If(@error) Then ; Error Checking!
                MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'eliminazione dell'elemento " & $i & "." & @CRLF & "Errore: " & @error)
            EndIf
        EndIf
    Next
    _Excel_Close($oExcel)
    If(@error) Then ; Error Checking!
        MsgBox($MB_ICONERROR, "Errore!", "Errore durante la chiusura dell'oggetto Excel." & @CRLF & "Errore: " & @error)
    EndIf
    _ArrayConcatenate($aRisultatoSiemens, $aRisultatoRockwell, 4)
    If(@error) Then ; Error Checking!
        MsgBox($MB_ICONERROR, "Errore!", "Errore durante la concatenazione dei due Array!" & @CRLF & "Errore: " & @error)
    EndIf
    Local $aRisultato = $aRisultatoSiemens
    Return $aRisultato
EndFunc ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LeggiTutteLeGiancenze()

$aRisultatoRockwell has a column more than the $aRisultatoSiemens.
So, here is the problem => Error checking: Error 5, which means:
 

$aArrayTarget and $aArraySource column number mismatch (2D only)

:) 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Good morning guys!
How are you? Hope you're fine :)
I'm still working on this project, and I'm encountering an issue that stucked me, and I' trying to solve this...
I've attached my actual file I'm working on, and I get stucked when I click on "AggiungiProdotto button" ( folder with a green + ), and I insert a product that there isn't in the database. When I create the GUI to insert a new product, then I come back on the AggiungiProdotto GUI, and I close it, the, If i try to recreate it, it doesn't. Can someone help me out please? Thanks :) 

Gestione_Magazzino_SYS.au3

EDIT:
And why this function, when I scan a barcode with my barcode scanner, fires exactly 20 times ConsoleWrite(...) ?
 

Func My_WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    ; $hWnd : not necessary
    ; $iMsg : not necessary
    ; $iwParam : High-order Word => Notification code, xxN_xxxx, where N stands for "Notification". => $EN_UPDATE
    ;            Low-order Word => Specifies if the notification code is from a control. => If(_WinAPI_LoWord(...) = some input...
    ; $ilParam : Is the "handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL".
    ;            $ilParam = GUICtrlGetHandle(some input)
    ; So, to identify the WM_COMMAND from a control, what we need is:
    ;   - High-order Word of the $iwParam, that identifies the notification code that has been sent;
    ;   - Low-order Word of the $iwParam, that identifies who is sending the notification code;
    ;   - $ilParam, that identifies, if Low-Order Word of $iwParam is a control, the handle of the control which is sending the notification code.

    Local $iIDFrom = _WinAPI_LoWord($iwParam)           ; Integer that specifies from which the event is sent: in this case, a control from a GUI;
    Local $iNotificationCode = _WinAPI_HiWord($iwParam) ; Integer that specifies which notification code has been sent: in this case, $EN_UPDATE;
    If($iIDFrom = $input_Utilizzato) Then
        If($iNotificationCode = $EN_UPDATE) Then
            If($ilParam = $hInputPreleva) Then
                ;PrelevaProdotto()
                ConsoleWrite("Preleva!" & @CRLF)
            ElseIf($ilParam = $hInputAggiungi) Then
                ;AggiungiProdotto()
                ConsoleWrite("Aggiungi!" & @CRLF)
            EndIf
        EndIf
    EndIf
EndFunc

I tried to study how to "manage" these notification codes, but I didn't find so much...
Can someone please explain to me ( or give to me ) a deteilad guide on which are these events, the notification codes, the command and so on? Thanks :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

1 hour ago, Juvigy said:

I dont see any error , and the line it is triggered. Try to run it via Scite and post the error msg and on which line of code it occur !

Hey @Juvigy!
I didn't mean that there was an error :) I was meaning: 
"In the case there is an error, should I prompt it to the user or not? And how to manage the error(s)?
Now I'm waiting for the response of water :) 

EDIT: wrong post :D 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

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

×
×
  • Create New...