trescon

Compare Number

9 posts in this topic

Good evening, I have to make a comparison between two variables, if one read it contains so even numbers represented:

"125487" or "14758"

while the other variable always contains the numbers, however, if I read the variable I see them like this:

45784 or 23658

I tried to do the conftonto with "==" but I did not verify the equality.

How do I compare the two variables.

Thank You

---------------------------

Buonasera, io devo fare un confronto tra due variabili, una se la leggo contiene dei numeri cosi rappresentati :

"125487" oppure "14758"

mentre l'altra variabile contiene sempre dei numeri però  se leggo la variabile li vedo cosi :

45784  oppure 23658

Ho provato a fare il conftonto con "==" ma non mi verifica l'uguaglianza.

Come posso fare per confrontare le due variabili.       


Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Share this post


Link to post
Share on other sites



Use "=" to compare.

$var1 = 123456
$var2 = "234567"
$var3 = "123456"

If $var1 = $var2 Then MsgBox(0, "", "$var1 = $var2")
If $var2 = $var3 Then MsgBox(0, "", "$var2 = $var3")
If $var1 = $var3 Then MsgBox(0, "", "$var1 = $var3")

Thanks for the answer, but I used "==" because in Autoit Support say that the "=" is used to assign a value to compare while using "==".
I tried it anyway before using "==" to use the "=" but I'm not comparing.
I see it because if the variables are equal I should increment a counter.

Any other ideas ??

Thank You

-----------------

Grazie per la risposta, ma io ho usato "==" perchè nel Autoit Help dicono che il carattere "=" serve per assegnare un valore mentre per confrontare si usa "==".
Io ho provato comunque prima di usare "==" ad usare il "=" ma comunque non mi fa il confronto.
Lo vedo perchè se le variabili sono uguali mi dovrebbe incrementare un contatore.

Altre idee ??


Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Share this post


Link to post
Share on other sites

So why are you questioning an valid answer and ask for other ideas?

Read the helpfile text again when it comes to = and == .

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

So why are you questioning an valid answer and ask for other ideas?

Read the helpfile text again when it comes to = and == .

Jos

 

Hi Jos, I do not question the answer of jguinch, I only say that making a comparison like this:
if ($ products [$ i] [1]) = $ Codice_Stringhe_Scomposte [$ f] Then
$ h = $h + 1
Etc. Etc.
Or if ($ products [$ i] [1]) == $ Codice_Stringhe_Scomposte [$ f] Then
$ h = $h + 1
Etc. Etc.

and verifying that the variables $ and $ Codice_Stringhe_Scomposte products are populated and the variables $ i and $ f are properly increase by two eyelashes for / next nested ..... the comparison of results.
Checking hand files from which are taken the Array, I found at least three matches, however the special software created by me I do not find anything, and then I increase the variable $ h.
Surely there is a mistake, but I do not understand that.
Thank you

-------------------

Salve Jos, io non metto in discussione la risposta di jguinch , dico solo che facendo un confronto di questo tipo :
if ($prodotti[$i][1]) = $Codice_Stringhe_Scomposte[$f] Then
            $h=$h+1
Etc. Etc.
Oppure      if ($prodotti[$i][1]) == $Codice_Stringhe_Scomposte[$f] Then
            $h=$h+1
Etc. Etc.

e verificando che le variabili $prodotti e $Codice_Stringhe_Scomposte siano popolate e le variabili $i e $f vengano correttamente incrementare da due cigli for/next nidificati..... il confronto non da risultato.
Verificando a mano i file dai quali sono presi gli Array , ho trovato almeno 3 corrispondenze, invece il programmino da me creato non mi trova nulla e quindi non mi incrementa la variabile $h.
Sicuramente c'è un errore , ma non capisco quale.
Grazie

 

Edited by trescon

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Can't follow, so please post a reproducer script that actually runs and shows your issue, so we can actually understand and help. :)

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Can't follow, so please post a reproducer script that actually runs and shows your issue, so we can actually understand and help. :)

Jos

OK, here's the script.

I state that are very poor as competence and that the script is a test and then apply the routine to a more comprehensive program.
Let me know where to find errors but not bury me the same.
Thank you

#include <array.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Dim $Dati[200], $aItems[10], $prodotti[200][15] , $AumDim[100],$Giacenze_Scomposte[6000][17],$aItems[6000],$Giacenze[6000],$Codice_Stringhe_Scomposte [10000],$h,$Codice[10000],$Marca[10000],$Modello[10000],$Descrizione[10000],$Settore[10000],$Aumentato[10000]
_FileReadToArray("C:/Procedure/Archivi/Cove/Variazioni_Listini.csv", $Dati) ; Csv file is in same directory as this script

ConsoleWrite($Dati[0] & @CRLF)

ConsoleWrite($Dati[1] & @CRLF) ;### Debug Console
For $a = 1 To $Dati[0]
    $aItems = StringSplit($Dati[$a], ";", 2)
    For $b = 0 To UBound($aItems) - 1
        $prodotti[$a - 1][$b] = $aItems[$b]
        ConsoleWrite($prodotti[$a][$b] & @CRLF)
    Next
Next
ConsoleWrite(UBound($aItems) & @CRLF)

ReDim $prodotti[$Dati[0]][UBound($aItems)]

_FileWriteFromArray("C:/Procedure/Archivi/Cove/Ftp/Prodotti.txt", $prodotti)

_ArrayDisplay($prodotti, "Variazione Listini")

ConsoleWrite("a"&$prodotti[2][0] & @CRLF)
ConsoleWrite("b"&$prodotti[2][1] & @CRLF)
ConsoleWrite($prodotti[2][2] & @CRLF)
ConsoleWrite($prodotti[2][3] & @CRLF)
ConsoleWrite($prodotti[2][4] & @CRLF)
ConsoleWrite($prodotti[2][5] & @CRLF)
ConsoleWrite($prodotti[2][6] & @CRLF)
ConsoleWrite($prodotti[2][7] & @CRLF)
ConsoleWrite($prodotti[2][8] & @CRLF)

For $c = 1 to $Dati[0]-1
    if $prodotti[$c][7] > String(0) then
        $AumDim[$c] = "Aumentato"
        ;$prodotti[$c][9]= "Red"
    ElseIf     $prodotti[$c][7] <= String(0) then
        $AumDim[$c] = "Diminuito"
        ;$prodotti[$c][10]= "Green"

    EndIf
next

_ArrayDisplay($AumDim, "Variazioni");visualizza variazioni


_FileReadToArray("C:/Procedure/Archivi/Cove/Ftp/Giacenze.txt", $Giacenze);Legge il file delle Giacenze nostre in Cove
;_ArrayDisplay($Dati,"pippo")

ConsoleWrite($Giacenze[0] & @crlf) ;### Debug Console
                for $d = 1 to $Giacenze[0];UBound($Dati)
                    $bItems = StringSplit($Giacenze[$d], "|")
                    for $e = 1 to $bItems[0]
                    ;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aItems = ' & $aItems[$b] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
                    $Giacenze_Scomposte [$d][$e] = $bItems[$e]
                    next
                Next


_ArrayDisplay($Giacenze_Scomposte, "Giacenze Magazzino"); visualizza giacenze magazzino

; fin qui funziona regolare
#Region ** Tolto il prefisso GROUP al codice
For $g=1 to $Giacenze[0]
    if StringLeft(StringMid($Giacenze_Scomposte[$g][8],1,4),4)= "GRUP" then
        $Codice_Stringhe_Scomposte [$g]= StringLeft(StringMid($Giacenze_Scomposte[$g][8],5,11),6)
        ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Codice_Stringhe_Scomposte [$g] = ' & $Codice_Stringhe_Scomposte [$g] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    EndIf
Next
#EndRegion

    ;MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & 'UBound($Dati)-1' & @CRLF & @CRLF & 'Return:' & @CRLF & UBound($Dati)-1) ;### Debug MSGBOX
    ;MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & 'UBound($Giacenze)' & @CRLF & @CRLF & 'Return:' & @CRLF & UBound($Giacenze)) ;### Debug MSGBOX

            MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & '$prodotti[2-1][1]' & @CRLF & @CRLF & 'Return:' & @CRLF & $prodotti[2-1][1]) ;### Debug MSGBOX
            MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & '$Codice_Stringhe_Scomposte[2]' & @CRLF & @CRLF & 'Return:' & @CRLF & $Codice_Stringhe_Scomposte[2]) ;### Debug MSGBOX


For $i = 1 to UBound($Dati)-1 ; variabile verificata
    For $f = 1 to UBound($Giacenze) ; variabile verificata
        if ($prodotti[$i-1][1]) = $Codice_Stringhe_Scomposte[$f] Then
            $h=$h+1
            ConsoleWrite("$h : "& $h &" || "& number($prodotti[$i][1])&" ")
            $codice[$h]=$Codice_Stringhe_Scomposte[$f]
            $Marca[$h]=$Giacenze_Scomposte[$f][10]
            $Modello[$h]=$Prodotti[$i-1][3]
            $Descrizione[$h]=$Prodotti[$i-1][2]
            $Settore[$h]=$Giacenze_Scomposte[$f][9]
                if $prodotti[$i-1][7] > String(0) then
                    $Aumentato[$h] = "Aumentato"
                                                            ;$prodotti[$i][9]= "Red"
                ElseIf     $prodotti[$i-1][7] <= String(0) then
                    $Aumentato[$h] = "Diminuito"
                                                            ;$prodotti[$c][10]= "Green"
                Endif
        EndIf
    Next
Next
    ConsoleWrite("il valore di $h è : "& $h & @CRLF)
    ConsoleWrite("$i :"&$i&"|"&"$f :"&$f&"|"&"$h : " & $h)

For $m = 1 to $h
    ConsoleWrite($codice[$m] & "|" & $Marca[$m] & "|" & $Modello[$m] & "|" & $Descrizione[$m] & "|" & $Settore[$m] & "|" & $Aumentato[$m])
Next
;
;vzsdggx

 


 

 The files can not send them, they contain sensitive data

 

Edited by trescon

Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

You do realize that this will not run when I hit f5...right?
Why not narrow this down to a minimal number of scriptlines to simply demonstrate your comparing problem?

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

OK, understood the message and realized my error.
As soon as I enter a summary of the procedure that gives me a problem.
Thank you for taking the time,


Thank You

Alberto

---------------------------------------------------

I am translate with Google.

Share this post


Link to post
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