Simple Looping QuestionI have what I think is a very simple looping question. I've looked in the scripting index and scripting guide and I just can't seem to figure it out.
All I need to do is to create a table with a list of years beginning with defined earliest year and going to a defined latest year. So say 1960, 1961, 1962, etc. with one year in each row. The script I am using returns a blank column. Here it is...
Names Default to Here(1);
minYear = 1947;
maxYear = 2024;
dt = New Table ("Years by Quarter",
Add Rows (maxYear - minYear),
New Column("Year", Ordinal)
);
For (i=minYear, i<MAXYEAR></MAXYEAR>Can someone tell me what I'm missing here?
Thanks much as always.
Automation and ScriptingmacOSRe: Simple Looping QuestionFor each row is a for loop like for() or for each(). So, you can use it directly like in the example below, no need to combine it with a for loop.
There are also other possibilities to set the values.
Names Default to Here(1);
minYear = 1947;
maxYear = 2024;
dt1 = New Table ("Years by Quarter",
Add Rows (maxYear - minYear +1),
New Column("Year", Ordinal)
);
for each row(:Year = row()-1+ minYear);
dt2 = New Table ("Years by Quarter",
Add Rows (maxYear - minYear +1),
New Column("Year", Ordinal, set each value(row()-1+ minYear))
);
myYears = 1947::2024;
dt3 = New Table ("Years by Quarter",
Add Rows (maxYear - minYear +1),
New Column("Year", Ordinal, set values(myYears))
);
Re: Simple Looping QuestionHere is one way to do it
Names Default To Here( 1 );
minYear = 1947;
maxYear = 2024;
dt = New Table( "Years by Quarter",
Add Rows( maxYear - minYear ),
New Column( "Year",
Ordinal,
set each value( minYear + Row() )
)
);
Re: Simple Looping QuestionThanks to both of you! Gradually I am starting the get the hang of JSL.