Jump to content

Need some help!


Recommended Posts

I have this script:

For $i = $int2+1 To 24
            $totalCantitate = 0
            For $j = 1 To 25
                If $ArrayMachetaPret[$i][$j] >= $PIP3  Then
                    $totalCantitate += $ArrayMachetaCantitate[$i][$j]
            ;MsgBox(0,$i&"-"&$j,$ArrayMachetaPret[$i][$j]&@CRLF&@CRLF&$PIP3)
                EndIf                           
            Next
            _ArrayAdd($ArrayCantitati,$totalCantitate)
        Next

for some values of " $ArrayMachetaPret[$i][$j] < $PIP3 " the IF condition returns " $ArrayMachetaPret[$i][$j] >= $PIP3 "

For Example: $ArrayMachetaPret[$i][$j] = 50 and $PIP3=101, it returns 50>101 witch is False.

this thing happens only when $ArrayMachetaPret[$i][$j] = 50 and when $PIP3=[101;499]

What could be the reason?

Edited by darzanmihai

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

You dont show enough code so its possible to analyze where the problem might be.

whats the length of you'r arrays ?

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

You dont show enough code so its possible to analyze where the problem might be.

whats the length of you'r arrays ?

$ArrayMachetaPret[26][26]

$ArrayMachetaPret[26][26]

$ArrayCantitati will have up to 25 elements!

I have made an example script ( by copying from my script, without modifications) that has about 350 lines....and it works perfectly....

What would be the reason?

The OfertaCantitatiCurente() Funcion contains the IF condition I mentioned in my previous post.

this is the example script

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Constants.au3>
#include <StaticConstants.au3>
#include <ComboConstants.au3>

;begining
Global $Cell[1][1]
Global $rows = 25
Global $columns = 1
Dim $ArrayMachetaPret[26][26]
Dim $ArrayMachetaCantitate[26][26]
$VarCantCump1 = 10
$VarCantCump2 = 20
$VarCantCump3 = 30
;pret maxim/minim
$PretMax1 = 200
$PretMax2 = 100
$PretMax3 = 50
;variatia de pret cumparare/vanzare
$VarPretCump1 = 10
$VarPretCump2 = 20
$VarPretCump3 = 50
;Intervale de la IBD/la IBD - > cumparare/Vanzare
$LaIBDcump1 = 6
$LaIBDcump2 = 12
;PIP pt intervale
$PIP1 = 199
$PIP2 = 99
$PIP3 = 101
$ArrayCantitati = _ArrayCreate("24")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Preluare Fisier", 600, 600, 193, 125)
$Button = GUICtrlCreateButton("Test", 100, 72, 249, 81, 0)
#Region Tabel Cantitate
$rows = 25
$columns = 1
$TabelCantitate = _Grid(0, 0, 90, 20, $rows, $columns, 0);, $color)
For $i = 1 To $rows
    GUICtrlSetData($TabelCantitate[$i][1], $i)
;GUICtrlSetData($TabelIBD[$i][1], $i - 1 & "-" & $i )
Next
;GUICtrlSetState($TabelIBD[$rows][1], $GUI_DISABLE)
GUICtrlSetData($TabelCantitate[$rows][1], "0")

#EndRegion Tabel Cantitate

GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ### Form=

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            
            $ArrayMachetaPret = OfertaDePretCumpararePret($TabelCantitate, $PretMax1, $PretMax2, $PretMax3, $VarPretCump1, $VarPretCump2, $VarPretCump3, $ArrayMachetaPret, $LaIBDcump1, $LaIBDcump2)
            $ArrayMachetaCantitate = OfertaDePretCumparareCantitate($TabelCantitate, $VarCantCump1, $VarCantCump2, $VarCantCump3, $ArrayMachetaCantitate, $LaIBDcump1, $LaIBDcump2)
            $ArrayCantitati = OfertaCantitatiCurente($ArrayMachetaPret, $ArrayMachetaCantitate, $PIP1, $PIP2, $PIP3, $LaIBDcump1, $LaIBDcump2, $ArrayCantitati)
            _ArrayDisplay($ArrayCantitati,"Result")
    ;_ArrayDisplay($ArrayMachetaPret,"Result")
    ;_ArrayDisplay($ArrayMachetaCantitate,"Result")
    EndSwitch
WEnd
Func OfertaDePretCumpararePret($Tabel12, $PretMaxCumparare, $PretMaxCumparare1, $PretMaxCumparare2, $ProcentVariatiePretCumparare, $ProcentVariatiePretCumparare1, $ProcentVariatiePretCumparare2, $ArrayMacheta, $int1, $int2)
    
    $procentE = $ProcentVariatiePretCumparare / 24
    For $i = 1 To $int1;ibd-urile
        For $j = 1 To 25;25 oferte pentru fiecare IBD
            If $j = 1 Then
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][$j] = $PretMaxCumparare
                Else
                    $ArrayMacheta[$i][$j] = 0
                EndIf
            Else
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][$j] = $PretMaxCumparare - $procentE * ($j - 1) * $PretMaxCumparare / 100
                Else
                    $ArrayMacheta[$i][$j] = 0
                EndIf
            EndIf
            
        Next
    Next
    $procentE1 = $ProcentVariatiePretCumparare1 / 24
    For $i = $int1 + 1 To $int2;ibd-urile
        For $j = 1 To 25;25 oferte pentru fiecare IBD
            If $j = 1 Then
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][$j] = $PretMaxCumparare1
                Else
                    $ArrayMacheta[$i][$j] = 0
                EndIf
            Else
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][$j] = $PretMaxCumparare1 - $procentE1 * ($j - 1) * $PretMaxCumparare1 / 100
                Else
                    $ArrayMacheta[$i][$j] = 0
                EndIf
            EndIf
            
        Next
    Next
    $procentE2 = $ProcentVariatiePretCumparare2 / 24
    For $i = $int2 + 1 To 24;ibd-urile
        For $j = 1 To 25;25 oferte pentru fiecare IBD
            If $j = 1 Then
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][$j] = $PretMaxCumparare2
                Else
                    $ArrayMacheta[$i][$j] = 0
                EndIf
            Else
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][$j] = $PretMaxCumparare2 - $procentE2 * ($j - 1) * $PretMaxCumparare2 / 100
                Else
                    $ArrayMacheta[$i][$j] = 0
                EndIf
            EndIf
            
        Next
    Next
    Return $ArrayMacheta
EndFunc ;==>OfertaDePretCumpararePret

Func OfertaDePretCumparareCantitate($Tabel12, $ProcentVariatiePretCumparare, $ProcentVariatiePretCumparare1, $ProcentVariatiePretCumparare2, $ArrayMacheta, $int1, $int2)
    
    $procentE = $ProcentVariatiePretCumparare / 24
    For $i = 1 To $int1;ibd-urile
        For $j = 1 To 25;25 oferte pentru fiecare IBD
            $Xmax = GUICtrlRead($Tabel12[$i][1]) / (25 - $ProcentVariatiePretCumparare / 8)
            If $j = 1 Then
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][26 - $j] = $Xmax;GUICtrlRead($Tabel12[$i][1])
                Else
                    $ArrayMacheta[$i][26 - $j] = 0
                EndIf
            Else
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][26 - $j] = $Xmax - $procentE * ($j - 1) * $Xmax / 100
                Else
                    $ArrayMacheta[$i][26 - $j] = 0
                EndIf
            EndIf
            
        Next
    Next
    $procentE1 = $ProcentVariatiePretCumparare1 / 24
    For $i = $int1 + 1 To $int2;ibd-urile
        For $j = 1 To 25;25 oferte pentru fiecare IBD
            $Xmax1 = GUICtrlRead($Tabel12[$i][1]) / (25 - $ProcentVariatiePretCumparare1 / 8)
            If $j = 1 Then
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][26 - $j] = $Xmax1
                Else
                    $ArrayMacheta[$i][26 - $j] = 0
                EndIf
            Else
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][26 - $j] = $Xmax1 - $procentE1 * ($j - 1) * $Xmax1 / 100
                Else
                    $ArrayMacheta[$i][26 - $j] = 0
                EndIf
            EndIf
            
        Next
    Next
    $procentE2 = $ProcentVariatiePretCumparare2 / 24
    For $i = $int2 + 1 To 24;ibd-urile
        For $j = 1 To 25;25 oferte pentru fiecare IBD
            $Xmax2 = GUICtrlRead($Tabel12[$i][1]) / (25 - $ProcentVariatiePretCumparare2 / 8)
            If $j = 1 Then
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][26 - $j] = $Xmax2
                Else
                    $ArrayMacheta[$i][26 - $j] = 0
                EndIf
            Else
                If GUICtrlRead($Tabel12[$i][1]) <> 0 Then
                    $ArrayMacheta[$i][26 - $j] = $Xmax2 - $procentE2 * ($j - 1) * $Xmax2 / 100
                Else
                    $ArrayMacheta[$i][26 - $j] = 0
                EndIf
            EndIf
            
        Next
    Next
    Return $ArrayMacheta
EndFunc ;==>OfertaDePretCumparareCantitate

Func OfertaCantitatiCurente($ArrayMachetaPret, $ArrayMachetaCantitate, $PIP1, $PIP2, $PIP3, $int1, $int2, $ArrayCantitati)
    For $i = 1 To $int1;ibd-urile
        $totalCantitate = 0
        For $j = 1 To 25;25 oferte pentru fiecare IBD
            If $ArrayMachetaPret[$i][$j] >= $PIP1 Then
                $totalCantitate += $ArrayMachetaCantitate[$i][$j]
            EndIf
        Next
        _ArrayAdd($ArrayCantitati, $totalCantitate)
    Next
    For $i = $int1 + 1 To $int2;ibd-urile
        $totalCantitate = 0
        For $j = 1 To 25;25 oferte pentru fiecare IBD
            If $ArrayMachetaPret[$i][$j] >= $PIP2 Then
                $totalCantitate += $ArrayMachetaCantitate[$i][$j]
            EndIf
        Next
        _ArrayAdd($ArrayCantitati, $totalCantitate)
    Next
    For $i = $int2 + 1 To 24;ibd-urile
        $totalCantitate = 0
        For $j = 1 To 25;25 oferte pentru fiecare IBD
            If $ArrayMachetaPret[$i][$j] >= $PIP3 Then
                $totalCantitate += $ArrayMachetaCantitate[$i][$j]
        ;MsgBox(0,$i&"-"&$j,$ArrayMachetaPret[$i][$j]&@CRLF&@CRLF&$PIP3)
            EndIf
        Next
        _ArrayAdd($ArrayCantitati, $totalCantitate)
    Next
    $t = 0
    For $i = 1 To 24
        $t += $ArrayCantitati[$i]
    Next
    _ArrayAdd($ArrayCantitati, $t)
    Return $ArrayCantitati

EndFunc ;==>OfertaCantitatiCurente

Func _Grid($StartX, $StartY, $cellWidth, $cellHeight, $rows, $columns, $ind)
    Local $tempX, $tempY
    ReDim $Cell[$rows + 1][$columns + 1]
    $tempX += $StartX
    $tempY += $StartY
    For $i = 1 To $rows
        For $j = 1 To $columns
            If $ind = 0 Then
                $Cell[$i][$j] = GUICtrlCreateInput("", $tempX, $tempY, $cellWidth, $cellHeight)
            ElseIf $ind = 1 Then
                If $i = 2 Then
                    $Cell[$i][$j] = GUICtrlCreateCombo("", $tempX, $tempY, $cellWidth, $cellHeight,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL,$WS_VSCROLL))
                Else
                    $Cell[$i][$j] = GUICtrlCreateInput("", $tempX, $tempY, $cellWidth, $cellHeight)
                EndIf
            EndIf
            $tempX += $cellWidth
        Next
        $tempX = $StartX
        $tempY += $cellHeight
    Next
    $Cell[0][0] = UBound($Cell) - 1
    Return $Cell
EndFunc ;==>_Grid
Edited by darzanmihai

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

I have this script:

For $i = $int2+1 To 24
            $totalCantitate = 0
            For $j = 1 To 25
                If $ArrayMachetaPret[$i][$j] >= $PIP3  Then
                    $totalCantitate += $ArrayMachetaCantitate[$i][$j]
        ;MsgBox(0,$i&"-"&$j,$ArrayMachetaPret[$i][$j]&@CRLF&@CRLF&$PIP3)
                EndIf                           
            Next
            _ArrayAdd($ArrayCantitati,$totalCantitate)
        Next

for some values of " $ArrayMachetaPret[$i][$j] < $PIP3 " the IF condition returns " $ArrayMachetaPret[$i][$j] >= $PIP3 "

For Example: $ArrayMachetaPret[$i][$j] = 50 and $PIP3=101, it returns 50>101 witch is False.

this thing happens only when $ArrayMachetaPret[$i][$j] = 50 and when $PIP3=[101;499]

What could be the reason?

Impossible. Just before your check (or just after, if you prefer), write the following line:

Consolewrite("$ArrayMachetaPret[$i][$j] = " & $ArrayMachetaPret[$i][$j] & "  $PIP3 = " & $PIP3 & @LF)
and then check your output.
Link to comment
Share on other sites

Impossible. Just before your check (or just after, if you prefer), write the following line:

Consolewrite("$ArrayMachetaPret[$i][$j] = " & $ArrayMachetaPret[$i][$j] & "  $PIP3 = " & $PIP3 & @LF)
and then check your output.

whell, this is what I did:

For $i = 1 To $int1;ibd-urile
            $totalCantitate = 0
            For $j = 1 To 25;25 oferte pentru fiecare IBD
                If $ArrayMachetaPret[$i][$j] >= $PIP1  Then
                    $totalCantitate += $ArrayMachetaCantitate[$i][$j]
                    Consolewrite("$ArrayMachetaPret["&$i&"]["&$j&"] = " & $ArrayMachetaPret[$i][$j] & "  $PIP1 = " & $PIP1 & "   >="&@LF)
                Else 
                    $totalCantitate += 0
                    Consolewrite("$ArrayMachetaPret["&$i&"]["&$j&"] = " & $ArrayMachetaPret[$i][$j] & "  $PIP1 = " & $PIP1 & "   <"&@LF)
                EndIf                           
            Next
            _ArrayAdd($ArrayCantitati,$totalCantitate)
        Next

And this is a part of what I got into the console:

$ArrayMachetaPret[24][24] = 35.625 $PIP3 = 8 >=

$ArrayMachetaPret[24][25] = 35 $PIP3 = 8 >=

$ArrayMachetaPret[1][1] = 200 $PIP1 = 3 <

$ArrayMachetaPret[1][2] = 199.166666666667 $PIP1 = 3 >=

$ArrayMachetaPret[1][3] = 198.333333333333 $PIP1 = 3 >=

...so, I got 200<3 ....I do not understand why.

I noticed that this is how it does for $i = 1

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

Try

If $ArrayMachetaPret[$i][$j]+0 >= $PIP1+0  Then

Thank you so much!

Now it works like a charm....I could have never thought of that! Stil I do not understand why it has done that, but I'm glad it works fine now!

Thx again!

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

Thank you so much!

Now it works like a charm....I could have never thought of that! Stil I do not understand why it has done that, but I'm glad it works fine now!

Thx again!

Why ? Maybe at least one of your variables is a string instead a number. Indeed "200" < "3".

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...