Jump to content

FileSelectz Folder pops up on interrupt, why?


Recommended Posts

Hello I have a kind of anomaly (at least to me) in my code.

I start my functions with a True/False variable which is changed by a button click (activating the function on a While sleep(50) If $variablerun then....Wend loop)

I have a button that should interrupt the functions by setting every function start variable to false, also in the actual functions there are checks whatever their run variable is still true or not. 

However it occured to me if I interrupt my running script with said button in a specific point,a FileSelectFolder from elsewhere in the code pops up, actually there is only one FileSelectFolder in my script, it is in the function I use to open a specific program (asking the user where it is in his PC, then open it) So it isn't like just the FileSelectFolder, but the entire Function starts to run. I have no ide why. I try to post all relevant code, but if you need something else pls feel free to ask.

Func UD_uszi_belepes() ;function that starts to run
    
    Local $StartFileSelectFolder = FileSelectFolder("Adja meg az UD_uszi.exe MAPPÁJÁT!", "")
    Run($StartFileSelectFolder & "\UD_uszi.exe")
    Sleep(3000)
    WinActivate("UD ÜSZI")
    ControlSetText("TLoginForm", "UD ÜSZI", "TEdit2", "BALAZSGE")
    Send("{TAB}BALAZSGE")
    Sleep(50)
    Send("{ENTER}")
    Global $UD_uszi_belepesRun = False
EndFunc   ;==>UD_uszi_belepes

;example action for the specific point of interrupt that starts the function above

Func KP_VJ_vasarlas() 
    WinActivate("UD Üszi - verzió")
    Local $handle = WinGetHandle("UD Üszi - verzió")
    If $KP_VJ_vasarlasRun = False Then
        Return
    EndIf
    ControlClick($handle, "", "[CLASSNN:TAdvBitBtn13; TEXT:Teszt - Útdíj fizetés adhoc előkészítés]")
    WinWaitActive("Útdíj fizetés adatok")
    If $KP_VJ_vasarlasRun = False Then
        Return
    EndIf
    Local $handle2 = WinGetHandle("Útdíj fizetés adatok")
    WinMove($handle2, "", 541, 210)
    ControlClick($handle2, "", "[CLASSNN:TAdvBitBtn4]")
    Sleep(200)
    ControlClick($handle2, "", "[CLASSNN:TAdvBitBtn3]")
    Sleep(2000) ;SPECIFIC INTERRUPT PART (where it starts the other function if I stop it by this If)
    If $KP_VJ_vasarlasRun = False Then
        Return
    EndIf

;button functions used to "call" the real ones (others are the same too)

Func UD_uszi_belepesRun()
    $UD_uszi_belepesRun = True
EndFunc   ;==>UD_uszi_belepesRun

While 1 ;üres járat a GUIformnak  + Run flagek kezelése
    Sleep(50)
    If $fTestRun Then
        Test()
    EndIf
    If $fExitRun Then
        _Exit()
    EndIf
    If $UD_uszi_belepesRun Then
        UD_uszi_belepes()
    EndIf
    If $UD_uszi_kilepesRun Then
        UD_uszi_kilepes()
    EndIf
    If $KP_VJ_vasarlasRun Then
        KP_VJ_vasarlas()
    EndIf ;....................

;interrupt function

Func Interrupt_beta()
    ; Szakítás jelző If EndIfhez sleep ás winkill fileselect folderhez?
    $fTestRun = False
    $fExitRun = False
    $UD_uszi_belepesRun = False
    $UD_uszi_kilepesRun = False
    $KP_VJ_vasarlasRun = False
;Otherfunction runs = false as well, nothing else

EndFunc   ;==>Interrupt_beta

I hope I copied every important code snippets, pls help me, I just dont understand why is this happening, and also unable to solve it (still trying to somehow circumnavigate it too)

Link to comment
Share on other sites

No wonder, There is a missing EndFunc for example at KP_VJ_vasarlas() . I just showed the code snippets where the problem could reside, these snippets never were intended to run alone. Also the code is built to interact with a specific program my company developed for internal use, and so I'm not allowed to post the entire code. (The full script is almost 3000lines now, and still under development) Thanks for the comment anyway. Should I try to write a "special" code from these fragments to see if it shows the same bug I described, and if it does post it here?

Link to comment
Share on other sites

My point is there is nothing as in the posted code that calls the function, your posted code does not reproduce the issue you are having. The problem is most likely somewhere else in your code.

Edit: Its also a bad idea to decleare a global vaiable inside a Function, better do it at the top of your script.

    Global $UD_uszi_belepesRun = False
Edited by Geir1983
Link to comment
Share on other sites

The function is called by the 

Func UD_uszi_belepesRun()
    $UD_uszi_belepesRun = True
EndFunc

which is called by a button click (i developed that in ISN Studio) 

I see sir, and you have a valid point, I start to arrive to the same conclusion as you, as everything else seems to work fine. So the bottom point is, by reading this you cant pinpoint any obvius problem I could have made, correct? (thanks for helping me :) ) Right know I have a "possible culprit" a function that doesn't use this flag system, I try to work there a bit, maybe if i connect it to this system that somehow solves the problem 

Link to comment
Share on other sites

Well, some of your functions might run several times, I only see the "Interrupt_beta" function setting run-flags to false, but the one you describe as a problem sets its own flag to false as the last statement. Its hard to say what your problem rely is from the posted code as this code does not make any sense in its current form. I think you should declare the variable outside the function, it could generate problems as is?

Link to comment
Share on other sites

Tha variabels (the flags that initiate running, I hope you meant that) are declared at the start of the code as global variabels, all of them false, buttonclick can change them to True, and interrupt change it back, or at the end of the function it changes back as well.

I use these 

If $KP_VJ_vasarlasRun = False Then
        Return
    EndIf

to check if interrupt has been initiated (as in that point the only possible way to change its value is the interrupt) and exit/stop the function

Edited by SorryButImaNewbie
Link to comment
Share on other sites

Is the $UD_uszi_belepesRun also declared at the start of your script? Then you have declared it twice, remove the declaration in the function.

(KP_VJ_vasarlas() does not set its own flag to false at the end of the function)

Func UD_uszi_belepes() ;function that starts to run
    
    Local $StartFileSelectFolder = FileSelectFolder("Adja meg az UD_uszi.exe MAPPÁJÁT!", "")
    Run($StartFileSelectFolder & "\UD_uszi.exe")
    Sleep(3000)
    WinActivate("UD ÜSZI")
    ControlSetText("TLoginForm", "UD ÜSZI", "TEdit2", "BALAZSGE")
    Send("{TAB}BALAZSGE")
    Sleep(50)
    Send("{ENTER}")
    $UD_uszi_belepesRun = False ; Remove The Global from this line
EndFunc   ;==>UD_uszi_belepes
Link to comment
Share on other sites

 

My point is there is nothing as in the posted code that calls the function, your posted code does not reproduce the issue you are having. The problem is most likely somewhere else in your code.

Edit: Its also a bad idea to decleare a global vaiable inside a Function, better do it at the top of your script.

    Global $UD_uszi_belepesRun = False

actually as I said in post #7 all the Global variables are first declared before the "actual" script (with the arrays, includes, Opt) have no idea why is the Global in there. I just deleted it and started testing, so far I was unable to replicate said bug. If this saved me I will build a small altar for your honor mate :D 

Link to comment
Share on other sites

Did as you told, can you shed somelight on why could this cause problems? I understand that it isnt recomended also it is against the basic syntax and against the recomendation of the help file, but I dont know why and how can it cause problems (sorry I'm fresh to AutoIt kinda pushed to deep water, a programmer above me quited his job and I have to develope now, but never used this language, learning it from the forum and from the help)

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