Hello,
I want to use the confirm() function to ask if I want to continue to run an script or stop it but I'm a little lost. When I put only msg confirm("Ok?"); I've got two messages, the second with the value of the choice. And how to use this value to make a test ?
Thanks for any help.
[solved] confirm and output
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
[solved] confirm and output
Last edited by lian00 on 10 Mar 2015 15:17, edited 1 time in total.
Windows 10 64 bits
-
highend
- Posts: 14944
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: confirm and output
Code: Select all
$result = confirm("Continue script?", , , 4);
if ($result) {
echo "You clicked the yes button";
} else {
echo "You clicked the no button";
}
One of my scripts helped you out? Please donate via Paypal
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: confirm and output
Maybe a leeettle bit more explanation would help.
Confirm dialogs by default have Yes and Cancel buttons. When your press Yes, confirm() returns 1, else it returns 0. More buttons can be added, and each button has different integer return values.
if ($return) is true as long as $return is not empty nor 0, meaning its true as long as Cancel/No was not pressed
Confirm dialogs by default have Yes and Cancel buttons. When your press Yes, confirm() returns 1, else it returns 0. More buttons can be added, and each button has different integer return values.
if ($return) is true as long as $return is not empty nor 0, meaning its true as long as Cancel/No was not pressed
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
Re: confirm and output
So
will show the message AND save the value in $result automatically ?
Code: Select all
$result = confirm("Continue script?", , , 4);Windows 10 64 bits
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: confirm and output
yes
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
highend
- Posts: 14944
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: confirm and output
Of course...will show the message AND save the value in $result automatically ?
One of my scripts helped you out? Please donate via Paypal
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
Re: confirm and output
Powerful !highend wrote:Of course...will show the message AND save the value in $result automatically ?
Windows 10 64 bits
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
Re: [solved] confirm and output
Complement: I found the end function.
So
So
Code: Select all
end confirm ("Continue script ?") == 1;
blablabla (script to continue);Windows 10 64 bits
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: [solved] confirm and output
Actually that will end the script if you press OK.
You should useend stops running the script if the condition is true. When the condition is confirm ("Continue script ?") == 1; it really means: end if confirm() returns 1 (which occurs when pressing OK/Yes)
You should use
Code: Select all
end confirm ("Continue script ?") != 1; //end if anything but OK pressed
blablabla (script to continue);Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
lian00
- Posts: 429
- Joined: 09 Jul 2014 17:12
XYplorer Beta Club