Clinton's Modal Question?

Smart people ~ Great Scripts
Post Reply
User avatar
trueBlue
Captain
Posts: 2930
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Clinton's Modal Question?

Post by trueBlue »

Question...
If an AnimTrack attribute exist, how would you stop the Question function from running?

Code: Select all

function Execute(params)
{

// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
function Question(strText)
{
	var nSecondsToWait = -1;
	var strTitle = "Question"; // Titlebar text
	// values are hexadecimal
	var MB_YESNO = 4;
	var MB_SYSTEMMODAL = 4096;//1000L force on top
	var MB_ICONQUESTION = 32;//20L question mark symbol // 16;= 10L stop-sign symbol


	var nType = MB_YESNO+MB_SYSTEMMODAL+MB_ICONQUESTION;
	var IDYES = 6;
	var IDNO = 7;

	var shell = new ActiveXObject("WScript.shell");
	var button = shell.Popup (strText, nSecondsToWait, strTitle, nType);

	if(button == IDYES) return true;
	return false;
}

if(!Node.ConExists(System.ThisName(), "AnimTrack")) {
System.Alert("AnimTrack exist")
}
if(Question("Would you like to continue?")) {
System.Alert("User selected Yes")
return;
}
System.Alert("User selected No")
}
BTW... this question function works with button scripts too!
Just do not use System.ThisOwner() etc...
Instead use '%THIS_OWNER_NAME%'

Code: Select all

function Question(strText)
{
var nSecondsToWait = -1;
var strTitle = "Question"; // Titlebar text
// values are hexadecimal
var MB_YESNO = 4;
var MB_SYSTEMMODAL = 4096;//1000L force on top
var MB_ICONQUESTION = 32;//20L question mark symbol // 16;= 10L stop-sign symbol
var nType = MB_YESNO+MB_SYSTEMMODAL+MB_ICONQUESTION;
var IDYES = 6;
var IDNO = 7;
var shell = new ActiveXObject("WScript.shell");
var button = shell.Popup (strText, nSecondsToWait, strTitle, nType);
if(button == IDYES) return true;
return false;
}
if(Node.ConExists(System.ThisName(), "AnimTrack")) {
System.Alert("AnimTrack exists")
}
if(Question("Would you like to continue?")) {
System.Alert("User selected Yes")
return;
}

clintonman
Captain
Posts: 3509
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Clinton's Modal Question?

Post by clintonman »

trueBlue wrote:
24 Jan 2020, 19:56
Question...
If an AnimTrack attribute exist, how would you stop the Question function from running?

Code: Select all

if(!Node.ConExists(System.ThisName(), "AnimTrack")) {
System.Alert("AnimTrack exist")
}
This part doesn't make sense to me. It says, "If there's no anim track then alert that the anim track exists". ?
Clinton Reese

http://clintons3d.com

User avatar
trueBlue
Captain
Posts: 2930
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Clinton's Modal Question?

Post by trueBlue »

It's just a place holder for what I am hoping can be modified.
The alerts are for testing.
If an AnimTrack attribute exist, how would you stop the Question function from running?
Or in other words...
If the AnimTract attribute exist the Question will not run.
If it does exist, the Question will run.

Wanting to do this using button code
As an example this does not work

Code: Select all

if(Question("This object has been animated, this part of the animation will be lost!\n\nDo you still want to remove this object?") && (Node.ConExists('%THIS_NAME%', "AnimTrack"))) {
Space.Select("%THIS_OWNER_NAME%")
Node.Delete('%THIS_NAME%')
return;

clintonman
Captain
Posts: 3509
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Clinton's Modal Question?

Post by clintonman »

trueBlue wrote:
24 Jan 2020, 22:17
It's just a place holder for what I am hoping can be modified.
The alerts are for testing.
If an AnimTrack attribute exist, how would you stop the Question function from running?
Or in other words...
If the AnimTract attribute exist the Question will not run.
If it does exist, the Question will run.

Wanting to do this using button code
As an example this does not work

Code: Select all

if(Question("This object has been animated, this part of the animation will be lost!\n\nDo you still want to remove this object?") && (Node.ConExists('%THIS_NAME%', "AnimTrack"))) {
Space.Select("%THIS_OWNER_NAME%")
Node.Delete('%THIS_NAME%')
return;
reverse it and use not
Read below as, "if animtrack does not exist AND question ..."
AND(&&) means both have to be true and for efficiency jscript does not go beyond the && if the first one is false

Code: Select all

if( !Node.ConExists('%THIS_NAME%', "AnimTrack") && Question("This object has been animated, this part of the animation will be lost!\n\nDo you still want to remove this object?") ) {
Clinton Reese

http://clintons3d.com

User avatar
trueBlue
Captain
Posts: 2930
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Clinton's Modal Question?

Post by trueBlue »

Thank you for the explanation, that is very helpful!
However, the following does not work...
It does not honor ( !Node.ConExists('%THIS_NAME%', "AnimTrack")
Button code on an Object that does not have an AnimTrack attribute"

Code: Select all

function Question(strText)
{
var nSecondsToWait = -1;
var strTitle = "Question"; // Titlebar text
// values are hexadecimal
var MB_YESNO = 4;
var MB_SYSTEMMODAL = 4096;//1000L force on top
var MB_ICONQUESTION = 32;//20L question mark symbol // 16;= 10L stop-sign symbol
var nType = MB_YESNO+MB_SYSTEMMODAL+MB_ICONQUESTION;
var IDYES = 6;
var IDNO = 7;
var shell = new ActiveXObject("WScript.shell");
var button = shell.Popup (strText, nSecondsToWait, strTitle, nType);
if(button == IDYES) return true;
return false;
}
if( !Node.ConExists('%THIS_NAME%', "AnimTrack") && (Question("This object has been animated, this part of the animation will be lost!\n\nDo you still want to remove this object?")) ) {
Space.Select("%THIS_OWNER_NAME%")
Node.Delete('%THIS_NAME%')
return;
}
And the second part, if you can get the first part working, is to Remove the object if the AnimTrack attribute does NOT exist.
I tried an if else too, still no luck.
You do not have the required permissions to view the files attached to this post.

clintonman
Captain
Posts: 3509
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Clinton's Modal Question?

Post by clintonman »

"If the AnimTract attribute exist the Question will not run.
If it does exist, the Question will run."

Those 2 mean the opposite of each other assuming "it" is the AnimTract attribute.
Maybe you want only the second part of that statement, "If it does exist, the Question will run."

if so then you don't want the !(not)

Code: Select all

if( Node.ConExists('%THIS_NAME%', "AnimTrack") && Question("This object has been animated, this part of the animation will be lost!\n\nDo you still want to remove this object?") ) {

Clinton Reese

http://clintons3d.com

User avatar
trueBlue
Captain
Posts: 2930
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Clinton's Modal Question?

Post by trueBlue »

Thanks!
I had to add another statement and it works as I had wanted.

Code: Select all

if( Node.ConExists('%THIS_NAME%', "AnimTrack") && (Question("This object has been animated, this part of the animation will be lost!\n\nDo you still want to remove this object?")) ) {
Space.Select("%THIS_OWNER_NAME%")
Node.Delete('%THIS_NAME%')
return;
}
if( !Node.ConExists('%THIS_NAME%', "AnimTrack") ) {
Space.Select("%THIS_OWNER_NAME%")
Node.Delete('%THIS_NAME%')
}
If the AnimTract attribute exist, the Question will run. Giving a user a choice to remove it or not.
If the AnimTract attribute does not exist the object will be removed.
This eliminates the Question script from running if the object has not been animated and THAT was the GOAL.

This is where I was stumped...
AND(&&) means both have to be true and for efficiency jscript does not go beyond the && if the first one is false
My apology for not asking my request correctly.
Thank you!

clintonman
Captain
Posts: 3509
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Clinton's Modal Question?

Post by clintonman »

You're welcome.
The && "stop early" behavior isn't intuitive if you've never seen it before.
Just FYI, the OR operator, ||, does the opposite thing in that it stops checking as soon as anything is true.
Clinton Reese

http://clintons3d.com

Post Reply