turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- weeks = 25; is from a dialog box. Please help with...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 9:20 AM
(690 views)

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Solution

If you're familiar with Table Variables, no need to read further...

If your dialog box is part of a larger script, then MS' suggestion seems to be as streamlined as any. If collecting the value for "weeks" is all it is doing, you might consider ditching the script and creating a table variable called 'weeks'. Then use that in your formula:

To change the value for 'weeks', double click on the current value and type over it.

BTW - With proper scoping, changing the value for the table variable can be done by script, as well:

(Assuming dt = Data Table("Untitled 21") for the above example)

New Window**(** "Line Up Box",

<<**Modal**,

V List Box**(**

Lineup Box**(** N Col**(** **2** **)**, Text Box**(** "Set this value" **)**,

var = Number Edit Box**(** **45** **)**, **)**

**)**,

H List Box**(** Button Box**(** "OK", dt:weeks = var << **get** **)**,

Button Box**(** "Cancel", **)** **)**

**)**;

6 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 10:14 AM
(579 views)

Not sure exactly what you have already, or where you need to end up. But maybe something like this?

dt = New Table**(** "Weeks",

Add Rows**(** **1000** **)**,

New Column**(** "Date",

Numeric,

"Continuous",

Format**(** "m/d/y", **10** **)**,

Input Format**(** "m/d/y" **)**,

Formula**(** Random Integer**(** Today**()** - In Years**(** **1** **)**, Today**()** **)** **)**

**)**

**)**;

wList = **{}**; For**(**w=**1**, w<=**52**, w++, InsertInto**(**wList, Char**(**w**)))**;

win = NewWindow**(**"Pick Week",

lb = ListBox**(**wList, maxSelected**(****1****))**,

ButtonBox**(**"OK", OKscript**)**

**)**;

OKscript =

Expr**(**

win << **closeWindow**;

w = **(**lb << **getSelected****)[****1****]**;

w = Num**(**w**)**;

form = Expr**(**If**(**Week Of Year**(**:Date**)** == wTBD, **1**, **0****))**;

SubstituteInto**(**form, Expr**(**wTBD**)**, w**)**;

dt << **NewColumn****(**"Match Selected Week", Numeric, Nominal, Formula**(**NameExpr**(**form**)))**;

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 10:48 AM
(579 views)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 12:33 PM
(579 views)

New Window("Line Up Box",

<<Modal,

V List Box(

Line Up Box(NCol(2),

Text Box("Set this value"), var = Number Edit Box(45),),),

H List Box(

Button Box("OK", ),

Button Box("Cancel" , )) );

weeks = var << get;

show (weeks);

Need to use the variable **"weeks"** in a numerical column formula. Previous post may have been confusing

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 22, 2016 2:25 PM
(579 views)

One way is to update the formula through a button script (i.e. the "OK" button).

For example:

//Example table

dt = New Table**(**"weeks", Add Rows**(****10****)**, New Column**(**"Weeks to roll", Numeric**))**;

// User sets value and adds formula

New Window**(**"Line Up Box",

<<**Modal**,

V List Box**(**Lineup Box**(**N Col**(****2****)**, Text Box**(**"Set this value"**)**, var = Number Edit Box**(****45****)**, **)**, **)**,

H List Box**(**

Button Box**(**"OK",

Eval**(**Parse**(**"Column(\!"Weeks to roll\!")<<set formula(" || Char**(**var << **get****)** || ")"**))**

** )**,

Button Box**(**"Cancel"**)**

**)**

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

If you're familiar with Table Variables, no need to read further...

If your dialog box is part of a larger script, then MS' suggestion seems to be as streamlined as any. If collecting the value for "weeks" is all it is doing, you might consider ditching the script and creating a table variable called 'weeks'. Then use that in your formula:

To change the value for 'weeks', double click on the current value and type over it.

BTW - With proper scoping, changing the value for the table variable can be done by script, as well:

(Assuming dt = Data Table("Untitled 21") for the above example)

New Window**(** "Line Up Box",

<<**Modal**,

V List Box**(**

Lineup Box**(** N Col**(** **2** **)**, Text Box**(** "Set this value" **)**,

var = Number Edit Box**(** **45** **)**, **)**

**)**,

H List Box**(** Button Box**(** "OK", dt:weeks = var << **get** **)**,

Button Box**(** "Cancel", **)** **)**

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 23, 2016 4:34 AM
(579 views)

Just checked out the table variable solution and GREAT. Plus learned something new.

Using the script below....what would be the column formula using weeks ? Curious Thanks for the solution

New Window("Line Up Box",

<<Modal,

V List Box(

Line Up Box(NCol(2),

Text Box("Set this value"), var = Number Edit Box(45),),),

H List Box(

Button Box("OK", ),

Button Box("Cancel" , ))

weeks = var << get;

show (weeks);