I am trying to throw an error (user defined and not the netLogo runtime error ) if one button is pressed before the other.
I have three buttons " SETUP" , "CONFIGURE", " SIMULATE" . I want to throw an error if SIMULATE is clicked before CONFIGEURE.
I know there is a primitive available " user-message" as mentioned by Sir.Seth Tisue in my other question, but do not know how to include it for my situaton.
Make a global configured?. Have configure set it to true. Then in simulate, put:
if configured? != true [
user-message "You must press configure first"
stop
]
Related
So in my app i have a button and when i click on it, it will save some text into my clipboard, then i can past it by ctrl+v somewhere.
And i am trying to write cypress test for this. Problem is, when i click on that button i got cypress error:
I can´t figured out. Element is clearly viewed on page. I tryied to wait few second before clicking and it didn´t help.
Is there a way how to test it?
Thank you for your answers.
Your application has thrown an error, not cypress. To avoid this, you will want to add this either to your test file or /support/index.js. This code was pulled from this example. Remember cy. requires a test or a hook to work, while Cypress. does not.
// inspect the caught error
cy.on('uncaught:exception', (e) => {
if (e.message.includes('Things went bad')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
// on any other error message the test fails
})
You can catch exceptions globally by writing this under cypress/support/index.js
Cypress.on('uncaught:exception', (err, runnable) => {
return false
})
Trying to automate away a warning window when connecting to a remote desktop.
MsgBox inside the If shows I have the handle.
Both the check box and connect are buttons. Instance 1 for the check box. Instance 11 for Connect.
I tried with ControlClick.
Also with GUI button check
Does anyone know what I am doing wrong here? Or of an alternative method to doing the same thing?
Remove the text parameter in the first instance. Did you obtain the controls and are confident they are accurate? If so you're looking for:
$g_hWnd1 = WinWait("Remote Desktop Connection", "", 5) ;Wait for popup
If IsHWnd($g_hWnd1) = 1 Then ;if handle is found
MsgBox(0, "", "First warning handle found", 5) ;notify
Sleep(2500) ;sleep
$g_hCheckBox = ControlGetHandle($g_hWnd1, "", "[CLASS:Button; INSTANCE:1]") ;stores checkbox in variable
_GUICtrlButton_SetCheck($g_hCheckBox, True) ;checks checkbox
ControlClick($g_hWnd1, "", "[CLASS:Button; INSTANCE:11]") ;selects Connect
EndIf
There is data validation in my MS Word user form which returns the focus to the textbox where the user entered something incorrect. Now I am trying to accommodate the user's change of mind: instead of correcting the entry, I want him to be able to exit the form (click the Exit command button), in which case the entry would be discarded. I suppose that a solution would start with not using the text box's exit event. I little help from someone who knows the answer would save me a lot of testing time, perhaps to find out that I can't do it.
Does anyone know?
I understand that you are handling the Exit event of the Textbox, setting the Cancel output parameter if the data is not valid.
There's a tricky but simple solution that permits to keep that working and still have an Exit button. It permits to activate the handler of the Exit button without requiring the focus to leave the Textbox. This way you can unload the Form safely in this handler.
Try this it works pretty smoothly:
1- Set the property TakeFocusOnClick of the Exit command button to False. You can do that at design time in the property-sheet, or at run-time i.e. at UserForm_Activate
2- just unload the form when the Exit button is clicked:
Private Sub ExitButton_Click()
Unload Me
End Sub
#A.S.H provided the key to the solution below. His point is that it is possible to call another event procedure while Cancel is active in the Exit procedure of a control. That other procedure can be used to rectify the condition in the first control which is triggering the Cancel, thereby enabling an orderly exit. The all-enabling condition is that the control on whose click event the rectifying procedure is to run must not take the focus when clicked (meaning it can run without triggering an exit from the control stuck on Cancel). I have added code to the exit procedure to set CmdExit.TakeFocusOnClick = False when a Cancel condition arises there. Now, ...
Private Sub CmdExit_Click()
' 12 May 2017
' if CmdExit can't take the focus it can't be the ActiveControl
If Not ActiveControl Is CmdExit Then
Select Case ActiveControl.Name
Case "Cbx107"
Cbx107.Value = ""
Case "Tbx53"
Tbx53.Value = "0"
End Select
With CmdExit
If Not .TakeFocusOnClick Then
.TakeFocusOnClick = True
.SetFocus
End If
End With
End If
' now CmdExit is the ActiveControl
MsgMe "Cmd Exit: ActiveControl = " & ActiveControl.Name
Me.Hide
End Sub
I sometimes get following exception:
[Mach] exception: 0x%x, count: %d, code: 0x%llx 0x%llx
[Mach] Skipping registered port - it is invalid
[Mach] Skipping registered port - mask does not match
signal %d, info %p, uapVoid %p
I do not have any idea what these exceptions are about. Can somebody throw any light on this?
try enabling the interception of generic exceptions:
in the left side of xcode, select "breakpoint navigator", on the bottom of left side click on "+", select "add exception breakpoint", a new item named "all exception" added in the breakpoint list. after click again on "+", select "add symbolic breakpoint", and write [NSException raise] inside text area named "symbol".
Now try again run your project.
I'm trying to trigger an error on purpose and then continue my script.
Error number -2700
triggers an "Unkown Error" error but it also ends the script with the returning value of -2700 instead of 0.
Also, I don't want the script to end after the error but to continue when you press the "OK" button.
The reason I want to do this is so that I won't have to make an Error dialog in every language myself.
Help?
(The comments mess up my code, that's why I post a new answer)
"For each language" sounds strange. Normally, you programme in a particular language and you'd write an error handling routine. In AppleScript this would be
try
-- your script here
on error errMsg number errNum
errorHandler(errMsg,errNum)
end try
on errorHandler (errMsg,errNum)
display dialog errMsg & " (" & errNum & ")."
end errorHandler
Try:
try
1 / 0
on error errMsg number errNum
tell me
activate
display alert errMsg & return & return & errNum buttons "OK"
end tell
end try
beep 3