Jump to content

something wrong with the adlibenable(with script)


 Share

Recommended Posts

I am using ablibenable to capture the exception. I found it only works at first time. CaptureException function will never been called after called once.

I paste my script as following. dose any one have some idea?

; CS

Global $gTestCaseId = 1

DDT_Main()

Func DDT_Main()

local $iEndTestCaseId=3

for $iTestCaseId=$gTestCaseId to $iEndTestCaseId

Debug("--------------------------------------------------------")

Debug("Doing the " & $iTestCaseId)

AdlibEnable("CaptureException",1200) ; 20 sec

Debug("AdlibEnable")

Sleep(300000) ; each loop supposed to go to CaptureException. but only first time works, why??

AdlibDisable()

Debug("AdlibDisable");

Next

EndFunc

Func CaptureException()

Debug("entering the CaptureException.......")

AdlibDisable()

Debug("AdlibDisable from the CaptureException")

sleep(2000)

;startup again

$gTestCaseId = $gTestCaseId + 1

DDT_Main()

EndFunc

Func Debug($message)

Local $previous = ControlGetText( "Untitled - Notepad","", "Edit1")

ControlSetText( "Untitled - Notepad","", "Edit1", $previous & $message & @CRLF)

EndFunc

;CE

Link to comment
Share on other sites

Look inside CaptureException() function your are using AdlibDisable() which disable AdlibEnable().

Func CaptureException()

Debug("entering the CaptureException.......")

AdlibDisable()

Debug("AdlibDisable from the CaptureException")

sleep(2000)

;startup again

$gTestCaseId = $gTestCaseId + 1

DDT_Main()

EndFunc

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Look inside CaptureException() function your are using AdlibDisable() which disable AdlibEnable().

but in the ddt_main(), i always open it again:

AdlibEnable("CaptureException",1200) ; 20 sec

so it will always work like: enable->disable->enable>disable.......

why i want to disable and enable it is because i want to reset the timer to 0. Is there something wrong?

Link to comment
Share on other sites

  • Moderators

netnet227,

You have a serious problem in your function nesting.

You call DDT_Main(). During this function you AdlibEnable CaptureException(). This function call the main DDT_Main() function again while the original call to the function is stuck in the Sleep(300000) pause. You are stacking up DDT_Main() calls every 1.2 seconds during a 300 second pause. If you reduce the Adlib time and the pause to more reasonable sizes you can see what is happening.

I suggest you start again because I am not sure what you have is salvagable - at least I am not trying!

What is it that you want to do? Perhaps we could start again.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers

No you never finish the called function because you have DDT_Main() in the called func.

You need to use Return to exit it.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

netnet227,

You have a serious problem in your function nesting.

You call DDT_Main(). During this function you AdlibEnable CaptureException(). This function call the main DDT_Main() function again while the original call to the function is stuck in the Sleep(300000) pause. You are stacking up DDT_Main() calls every 1.2 seconds during a 300 second pause. If you reduce the Adlib time and the pause to more reasonable sizes you can see what is happening.

I suggest you start again because I am not sure what you have is salvagable - at least I am not trying!

What is it that you want to do? Perhaps we could start again.

M23

what i want to achive is:

I have test case 1 to 10. i will do it one by one, if one fails the UI will freeze. i need detect it and terminate it and start to do the next one.

what do you mean by "start again"?

If the current ddt_main could return, that will solve the problem. but how can i return/exit it?

Link to comment
Share on other sites

  • Moderators

netnet227,

When I say "start again" I mean just that - rethink your logic and start coding a new script. As it stands, your current script is hopelessly recursive and, in my opinion, stands little chance of ever running successfully. Merely scripting a "Return" from DDT_Main is unlikely to be the solution.

Why do you say the UI freeze will if the test fails? Can you not create some errorchecking code to prevent that? What are you testing that is so unforgiving?

You need to get the test as a self-contained function so you can loop through the 10 of them in a more conventional manner. Please explain in more detail what it is you are doing in your testing function and I am sure we can get something that runs smoothly.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

netnet227,

When I say "start again" I mean just that - rethink your logic and start coding a new script. As it stands, your current script is hopelessly recursive and, in my opinion, stands little chance of ever running successfully. Merely scripting a "Return" from DDT_Main is unlikely to be the solution.

Why do you say the UI freeze will if the test fails? Can you not create some errorchecking code to prevent that? What are you testing that is so unforgiving?

You need to get the test as a self-contained function so you can loop through the 10 of them in a more conventional manner. Please explain in more detail what it is you are doing in your testing function and I am sure we can get something that runs smoothly.

M23

M23,

the target is a huge and legacy system. everything will happen when running the test target. for example "memory access violation" or some business logic I failed to(and impossible to) predict. 10 is just a number i gave an example, actually, it's few hundreds at least.

also, i realized the problem with the nested function. There's ugly way to do it by writing the current test case number to a file. when exception happens, Exit the whole autoit3.exe and restart from the next number.

but i still wondering if there's good way to handle this.

Link to comment
Share on other sites

  • Moderators

netnet227,

So make each test run a separate process. Then if it freezes you should be able to detect that it is dead, kill it, and start the next one in the line. (I am assuming, given that you were originally looping through them, that each of the tests is identical apart from a few parameters that are dependent on the series number of the test.)

How to proceed? Write the test as a separate script and then use FileInstall or Zedna's Resources UDF to get it into the compiled .exe. Then write it to a temp directory and run it with suitable parameters. Your main script runs throughout and keeps tabs on the serial number of the test so it knows which one to run next.

Or have I greatly underestimated the problem?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

netnet227,

So make each test run a separate process. Then if it freezes you should be able to detect that it is dead, kill it, and start the next one in the line. (I am assuming, given that you were originally looping through them, that each of the tests is identical apart from a few parameters that are dependent on the series number of the test.)

How to proceed? Write the test as a separate script and then use FileInstall or Zedna's Resources UDF to get it into the compiled .exe. Then write it to a temp directory and run it with suitable parameters. Your main script runs throughout and keeps tabs on the serial number of the test so it knows which one to run next.

Or have I greatly underestimated the problem?

M23

M23,

Thank for your help. It's a good idea to go around the nested function issue. I will try it later.

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