Subscribe Bookmark RSS Feed

Modal windows - using {Button(1)} in if statements?

DSA

Community Trekker

Joined:

Feb 15, 2016

Hi JMP community,

i am struggeling with a very simple issue but i cannot get it to work.

I have a modal window with some input fields, and OK/Cancel buttons.

I would like to do an if-statement based on the OK or Cancel button, so levering -1 vs 1 inside the Button( ) clause like they describes in Modal Windows.

So how do i actually constructed my if statement to use this?

I guess it is some sort of function handle and i cannot get it to work as a text string and i cannot manage to extract the -1 or 1.

What is the better practice here?

Thanks in advance,

Daniel

1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

// One way to use the default Modal Window output

Q = New Window("test", <<Modal, Button Box("OK"), Button Box("Cancel"));

If(Arg(Q[1], 1) == 1,

    Print("Okayed"),

    Print("Canceled")

);

// But it's easier to use a button script

New Window("test",

    <<Modal,

    Button Box("OK", Print("Okayed")),

    Button Box("Cancel", Print("Canceled"))

);

3 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Solution

// One way to use the default Modal Window output

Q = New Window("test", <<Modal, Button Box("OK"), Button Box("Cancel"));

If(Arg(Q[1], 1) == 1,

    Print("Okayed"),

    Print("Canceled")

);

// But it's easier to use a button script

New Window("test",

    <<Modal,

    Button Box("OK", Print("Okayed")),

    Button Box("Cancel", Print("Canceled"))

);

DSA

Community Trekker

Joined:

Feb 15, 2016

Thanks for the great support in short time MS,

It worked right a way.

/Daniel

msharp

Super User

Joined:

Jul 28, 2015

Alternatively, the result stored from a New Window object is an actual object, thus bracket notation can be used.  I should note this is practically the only object supported by JSL.

Q = New Window("test", <<Modal, Button Box("OK"), Button Box("Cancel"));

If(Q["Button"] == 1,

    Print("Okayed"),

    Print("Canceled")

);

//Q = {Button(-1)};