weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an input<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Having trouble using "weeks" in a column formula. weeks = 25; is from a dialog box. Help is appreciated
Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an inputJust 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);
Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an inputIf 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", ) )
);
Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an inputOne 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\!")< || Char(var << get) || ")"))
),
Button Box("Cancel")
)
);
Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an inputNew Window("Line Up Box",
<
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
Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an inputThanks for the try....the data table column( "Weeks to Roll" should = 25, a value needed by the user to evaluate a secondary operation.
Re: weeks = 25; is from a dialog box. Please help with the column formula using "weeks" as an inputNot 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)));
);