30 posts in this topic
Hello, I recently opened a bug report without reading the Helpfile... My bad . After @Melba23's gentle reminder, I was curious about why it was like that.
It is about SetError's behaviour. This is the example from the bug report:
Example() If @error Then ConsoleWrite("Error" & @CRLF) Else ConsoleWrite("No Error" & @CRLF) EndIf Func Example() SetError(1) Sleep(1000) EndFunc What I tried to do is set Example's (my user defined function's) @error value to 1... but the value set by SetError is cleared after calling a function, I wonder why? Why should calling to an external function effect my function's @error which is set when my function returns.
Setting the error of a UDF in advance by using SetError makes sense... but I cannot find a reason why calling a function should clear it? Please note that I am not talking about @error, I am talking about the @error set by my function when it ends/returns!
I hope someone can enlighten me, thanks for the answers in advance!
P.S I tried to explain my best but my English is not very good and I didn't feel like I did a good job explaining today, so please pardon any mistakes that I have made
Hi I am trying to read multiple sections from an ini file into an array and use the result to calculate how many records there are from the suppliers and this devided into the status records that belong to it. The problem I am having; I am able to use Ubound to calculate how many record there are in total to the option chosen from the combo box, but where I am getting stuck is the part to link the status and leverancier to each other and count them.
Hope some one can help me.
My code right now:
#include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <file.au3> #include <array.au3> $Form1 = GUICreate("Form1", 615, 437, 569, 253) $LEVCOMBO = GUICtrlCreateCombo("", 184, 112, 145, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) Global $aSections = IniReadSectionNames(@ScriptDir & "\leveranciers.ini") If (Not @Error) Then GUICtrlSetData($LEVCOMBO, _ArraytoString($aSections, "|", 1), $aSections) $LABEL = GUICtrlCreateLabel("Totaal aantal RMA aanvragen: ", 48, 200, 250, 21) $TOTALCOUNT = GUICtrlCreateLabel("", 200, 200, 100, 21) $LABEL2 = GUICtrlCreateLabel("Aantal aangevraagd: ", 48, 225, 250, 21) $TOTALAANGEVRAAGD = GUICtrlCreateLabel("", 200, 225, 100, 21) $LABEL3 = GUICtrlCreateLabel("Aantal verzonden: ", 48, 250, 250, 21) $TOTALVERZONDEN = GUICtrlCreateLabel("", 200, 250, 100, 21) $LABEL4 = GUICtrlCreateLabel("Aantal afgehandeld: ", 48, 275, 250, 21) $TOTALAFGEHANDELD = GUICtrlCreateLabel("", 200, 275, 100, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $LEVCOMBO COMBO() EndSwitch WEnd Func COMBO() Local $hINI_FILENAME = @ScriptDir & "\ini.ini" $READAANGEVRAAGDRMA = IniReadSection($hINI_FILENAME, 'LEVERANCIER') $READSTATUS = IniReadSection($hINI_FILENAME, 'STATUS') $VAR = GUICtrlRead($LEVCOMBO) $READAANGEVRAAGDRMACOUNT = _ArrayFindAll($READAANGEVRAAGDRMA, $VAR, Default, Default, Default, Default, 1) GUICtrlSetData($TOTALCOUNT,UBound($READAANGEVRAAGDRMACOUNT)) $nb = $READAANGEVRAAGDRMA Local $res[$nb+1] $res = $nb For $i = 1 to $nb $res[$i] = $READAANGEVRAAGDRMA[$i] $res[$i] = $READSTATUS[$i] Next _ArrayDisplay($res) EndFunc And the ini files that goes with it:
[STATUS] 1=Afgehandeld 3=Verzonden 4=Aangevraagd 5=Aangevraagd 6=Aangevraagd 7=Aangevraagd 8=Verzonden 9=Aangevraagd 10=Aangevraagd 11=Aangevraagd 12=Aangevraagd 13=Aangevraagd 14=Aangevraagd 15=Aangevraagd 16=Aangevraagd 17=Aangevraagd 18=Aangevraagd 19=Aangevraagd 20=Aangevraagd 21=Aangevraagd 22=Aangevraagd [LEVERANCIER] 9=Dobit B.V. 1=Dobit B.V. 10=Dobit B.V. 11=Dobit B.V. 12=Dobit B.V. 13=Dobit B.V. 14=Asus 15=Asus 16=Brother 17=Dobit B.V. 18=Dobit B.V. 19=Dobit B.V. 20=Dobit B.V. 21=Dobit B.V. 22=Asus leveranciers.ini:
[Kies een leverancier...] [Dobit B.V.] URL =http://eline.dobit.be/eline/master.php [TechData B.V.] URL = [MaxICT B.V.] URL = [Brother] URL= [Asus] URL=https://eu-rma.asus.com/pickup_europe/pickup.aspx?country=nl [HP] URL= [Lenovo] URL= [CCV] URL=
After a long time, I bring you yet another IIAGI topic . Today its about indicating(?) arrays... here is a visual example:
"This is an example for a string" 1337 ; An integer 13.37 ; Integer ["This", "is", "an", "example", "for", "an", "array"] ; All work except the Array's example :( All the examples (each separated by a line) can be passed to a function or a variable without the help of a variable except the array example... That shouldn't be like that! We can use the way (which I just demonstrated above) in many ways, here is one way I can think of now:
Local $aInitialArray = [1, 2, 3] _ArrayConcatenate($aInitialArray, [4, 5, 6])
I would love to see this implemented ... I honestly don't see reason for this NOT to be implemented .
So I made a loop beginning with while $e = 1. It opens a file and searches for a colour in the file, if the colour isn't there $e = 2 so the loop ends and restarts. Instead of that, the loop runs once and then just stops completely, even if the colour is there.
Here is what it looks like basically.
While $e = 1
$aCoord = PixelSearch ($left, $top, $right, $bottom, 0x3B5E05, 0)
If @error Then $e = 2
How do I make it so the loop restarts if the colour isn't there, but it continues normally if the colour is there?
I did look at the help file and did not see an indicator of the answer. The @error variable that inherits a value when a function produces an error; is this value overwritten as success if a function right below it is successful? It seems that I could possibly check the error value at the end of a UDF if it always maintains an error value once generated, but if its overwritten by successful functions, I would have to check every function call. I find this more relevant for browser automation. i.e. checking every time I navigate.