
Quote from Phil78 on December 10, 2021, 7:23 pmHi all,
I want to give the focus to numeric input of my dialog box when opening, I try FocusObject "NumericInput1" without succes.
In the dialog box I can enter a value between 0 and 13 but my test fail with 0 ?
See my example
Hi all,
I want to give the focus to numeric input of my dialog box when opening, I try FocusObject "NumericInput1" without succes.
In the dialog box I can enter a value between 0 and 13 but my test fail with 0 ?
See my example
Uploaded files:Quote from Gaev on December 10, 2021, 11:56 pm@phil78
I want to give the focus to numeric input of my dialog box when opening, I try FocusObject "NumericInput1" without succes.
Try this code ...
Watch [num1] "DisplayWatch" Watch [num2] "DisplayWatch" OpenDialog "NewDialog" SetVar [num1] 0 SetVar [num2] 0 Wait 2000 HideObject "Headline3" "" 0 FocusObject "NumericInput1" EndWaitNotes:
- you can try and wait any number more/less than 2000
- Headline3 is just a container for the "Please wait" message; remember to ShowObject it upon exit from the DialogIn the dialog box I can enter a value between 0 and 13 but my test fail with 0 ?
Perhaps I do not understand the translation, but when I set the value of NumericInput1 to to something other than 0 and then return to 0, it all works; please explain your exact steps.
I want to give the focus to numeric input of my dialog box when opening, I try FocusObject "NumericInput1" without succes.
Try this code ...
Watch [num1] "DisplayWatch" Watch [num2] "DisplayWatch" OpenDialog "NewDialog" SetVar [num1] 0 SetVar [num2] 0 Wait 2000 HideObject "Headline3" "" 0 FocusObject "NumericInput1" EndWait
Notes:
- you can try and wait any number more/less than 2000
- Headline3 is just a container for the "Please wait" message; remember to ShowObject it upon exit from the Dialog
In the dialog box I can enter a value between 0 and 13 but my test fail with 0 ?
Perhaps I do not understand the translation, but when I set the value of NumericInput1 to to something other than 0 and then return to 0, it all works; please explain your exact steps.

Quote from luishp on December 11, 2021, 9:01 am@gaev I have added a missing EndWait instruction to your code.
Probably 200 milliseconds is more than enough for the Dialog to be ready.
Thank you!
@gaev I have added a missing EndWait instruction to your code.
Probably 200 milliseconds is more than enough for the Dialog to be ready.
Thank you!

Quote from Phil78 on December 11, 2021, 1:46 pmThanks @gaev,
in fact we don't need a headline, just put Focusobject between wait and endwait, even wait 0 works. Can you explain why?
Why there is no page-enter for a dialog box ?
Concerning the scores, if I enter 13 / 0 or 0 / 13 I get one of my error messages wrong.
Regards
Thanks @gaev,
in fact we don't need a headline, just put Focusobject between wait and endwait, even wait 0 works. Can you explain why?
Why there is no page-enter for a dialog box ?
Concerning the scores, if I enter 13 / 0 or 0 / 13 I get one of my error messages wrong.
Regards

Quote from luishp on December 11, 2021, 2:55 pmCan you explain why?
Probably even waiting 0 milliseconds is enough in some devices, but I would add some minimal waiting to be sure it works everywhere.
Why there is no page-enter for a dialog box ?
Because it's not a page :)
Can you explain why?
Probably even waiting 0 milliseconds is enough in some devices, but I would add some minimal waiting to be sure it works everywhere.
Why there is no page-enter for a dialog box ?
Because it's not a page :)

Quote from Phil78 on December 14, 2021, 12:59 pmHi @gaev About my controls I broke down the IfEx test it's the num1 == "" or num2 == "" part that is at fault (IsVarEmpty returns true too).
But as far as I know 0 is a value and is not empty, so how to do it?thanks also to @luishp
regards
Hi @gaev About my controls I broke down the IfEx test it's the num1 == "" or num2 == "" part that is at fault (IsVarEmpty returns true too).
But as far as I know 0 is a value and is not empty, so how to do it?
thanks also to @luishp
regards
Quote from Gaev on December 15, 2021, 1:45 am@phil78
About my controls I broke down the IfEx test it's the num1 == "" or num2 == "" part that is at fault (IsVarEmpty returns true too).
But as far as I know 0 is a value and is not empty, so how to do it?1) When the Dialog is opened, [num1] and [num2] are zero; so you do not need to worry about them being null ... so just check for the upper/lower ranges.
2) The check for both [num1] and [num2] being zero needs to be done first ... otherwise, if [num1] and [num2] are in the specified range, the check for both zeroes will never be made.
IfEx [num2] == 0 and [num1] == 0 AlertBox "Error" "There can't be a null match at 0" "" FocusObject "NumericInput1" Return 0 EndIf IfEx [num1] > 13 or [num1] < 0 AlertBox "Error" "Num1 is [num1] ... Enter a number between 0 and 13" "" FocusObject "NumericInput1" Return 0 EndIf IfEx [num2] > 13 or [num2] < 0 AlertBox "Error" "Num2 is [num2] ... Enter a number between 0 and 13" "" FocusObject "NumericInput2" Return 0 EndIf CloseDialog
About my controls I broke down the IfEx test it's the num1 == "" or num2 == "" part that is at fault (IsVarEmpty returns true too).
But as far as I know 0 is a value and is not empty, so how to do it?
1) When the Dialog is opened, [num1] and [num2] are zero; so you do not need to worry about them being null ... so just check for the upper/lower ranges.
2) The check for both [num1] and [num2] being zero needs to be done first ... otherwise, if [num1] and [num2] are in the specified range, the check for both zeroes will never be made.
IfEx [num2] == 0 and [num1] == 0 AlertBox "Error" "There can't be a null match at 0" "" FocusObject "NumericInput1" Return 0 EndIf IfEx [num1] > 13 or [num1] < 0 AlertBox "Error" "Num1 is [num1] ... Enter a number between 0 and 13" "" FocusObject "NumericInput1" Return 0 EndIf IfEx [num2] > 13 or [num2] < 0 AlertBox "Error" "Num2 is [num2] ... Enter a number between 0 and 13" "" FocusObject "NumericInput2" Return 0 EndIf CloseDialog

Quote from Phil78 on December 15, 2021, 5:26 pmHi @Gaev, thanks for your answer.
When the dialog box is opened, [num1] and [num2] are null, and I can raise an error if they stay null without problem. As it is from a numeric input object the value cannot be "", so removing the test [num1] == "" or [num2] == "" solve the problem I agree with you.
But you and I don't explain why this raises an error :(
Hi @Gaev, thanks for your answer.
When the dialog box is opened, [num1] and [num2] are null, and I can raise an error if they stay null without problem. As it is from a numeric input object the value cannot be "", so removing the test [num1] == "" or [num2] == "" solve the problem I agree with you.
But you and I don't explain why this raises an error :(
Quote from Gaev on December 15, 2021, 5:41 pm@phil78
When the dialog box is opened, [num1] and [num2] are null, and I can raise an error if they stay null without problem.
Not if you set them to 0 at the time of popping the Dialog ... as per my previous post ...
OpenDialog "NewDialog" SetVar [num1] 0 SetVar [num2] 0On my machine, when the Dialog is popped up, both inputs contain the value 0 ... so I do not see a scenario where any of those two values can be null.
Are you using a Wait of 0 ? ... as per suggestion by @luishp, make sure your wait is around 200.
When the dialog box is opened, [num1] and [num2] are null, and I can raise an error if they stay null without problem.
Not if you set them to 0 at the time of popping the Dialog ... as per my previous post ...
OpenDialog "NewDialog" SetVar [num1] 0 SetVar [num2] 0
On my machine, when the Dialog is popped up, both inputs contain the value 0 ... so I do not see a scenario where any of those two values can be null.
Are you using a Wait of 0 ? ... as per suggestion by @luishp, make sure your wait is around 200.

Quote from Phil78 on December 15, 2021, 7:17 pm@gaev In my real application, the values are those of my table before calling the dialog. If it's the first access the values are null, otherwise it enters in modification with the previous values. This is the reason while this is the reason why setvar is positioned before opendialog. But I have no problem with the null management.
@gaev In my real application, the values are those of my table before calling the dialog. If it's the first access the values are null, otherwise it enters in modification with the previous values. This is the reason while this is the reason why setvar is positioned before opendialog. But I have no problem with the null management.
Quote from Gaev on December 16, 2021, 3:16 am@phil78
In my real application, the values are those of my table before calling the dialog. If it's the first access the values are null, otherwise it enters in modification with the previous values.
1) the box is called Numeric Input ... null is NOT a number
2) you can force a value of zero ...
a) either by specifying it in the initial-value property for the Numeric Input Box(es)
b) or doing a SetVar before the first call to the Dialog
But if you insist on passing null/undefined values to the Boxes, try this inside the OK Button ...
IfEx [num2] == undefined AlertBox "num2" "is undefined" "" Return 0 EndIf
In my real application, the values are those of my table before calling the dialog. If it's the first access the values are null, otherwise it enters in modification with the previous values.
1) the box is called Numeric Input ... null is NOT a number
2) you can force a value of zero ...
a) either by specifying it in the initial-value property for the Numeric Input Box(es)
b) or doing a SetVar before the first call to the Dialog
But if you insist on passing null/undefined values to the Boxes, try this inside the OK Button ...
IfEx [num2] == undefined AlertBox "num2" "is undefined" "" Return 0 EndIf

Quote from Phil78 on December 16, 2021, 5:17 pmHi @gaev
As I said before I do not have any problem with null value. My only question is why the test 0 == "" return true when for me it should be false !
Hi @gaev
As I said before I do not have any problem with null value. My only question is why the test 0 == "" return true when for me it should be false !

Quote from luishp on December 16, 2021, 8:41 pm@phil78 This is a JavaScript related question. As 0 and empty strings are both evaluated as false, 0 == "" is evaluated as false == false and that's true.
Try 0 === "" instead and you will get false.More info here:
https://www.freecodecamp.org/news/falsy-values-in-javascript/Regards.
@phil78 This is a JavaScript related question. As 0 and empty strings are both evaluated as false, 0 == "" is evaluated as false == false and that's true.
Try 0 === "" instead and you will get false.
More info here:
https://www.freecodecamp.org/news/falsy-values-in-javascript/
Regards.

Quote from Phil78 on December 17, 2021, 7:20 pmThanks @luishp I find it twisted but I understand. At least I won't die a fool! :)
Regards
Thanks @luishp I find it twisted but I understand. At least I won't die a fool! :)
Regards