Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
mwallman
Creator III
Creator III

Set a value for a variable and set the next value after each reload?

Hi all,

I would like to create a variable in the script that holds a certain value that updates every time there is a reload.

The value should iterate over from 1993 to 1998.

So for example it is 1993

After I reload it should be 1994

Then the next reload it should be 1995

...

Until 1998, after 1998 it should again hold the value of 1993.

Here is the basic of what I want to do:

SET vYear = <value of year based on above>;

LOAD

$(vYear) as CurrentYear,

<fields>

From file.txt;

How is it possible to create a variable like this please?

8 Replies
sunny_talwar

May be this

LET vYear = If(vYear = 1998, 1993, $(vYear) + 1);

mwallman
Creator III
Creator III
Author

Hi Sunny,

It's a good idea, however I get 1, 2, 3 as results and not 1993, 1994 etc. Any ideas why?

sunny_talwar

I am a little confused, are you trying to loop through these values during a single reload? or are you trying to increment by 1 every time you reload?

swuehl
MVP
MVP

Have you initialized your vYear variable once to 1993?

mwallman
Creator III
Creator III
Author

Hi Sunny,

I am trying to loop through them. So initial value could be 1993, then after the next reload it would be 1994, then next reload it would be 1995 etc. Until 1998, after this it loops through again and start at 1993.

sunny_talwar

Try this may be:

LET vYear = If(vYear <> 1998, $(vYear) + 1, 1993);

or

LET vYear = If(Len(Trim(vYear)) = 0, 1993, If(vYear = 1998, 1993, $(vYear) + 1);

alexpanjhc
Specialist
Specialist

try this?

If $(vFirst)=0 then

LET vYear=1992;

end if;

LET vYear = If(vYear = 1998, 1993, $(vYear) + 1);// i copied sunny's idea here...

set vFirst=1;

KiruthikaA
Contributor II
Contributor II

Hi,

I would like to create a variable in the front end 

The variable should iterate from the  year 2010  to the current year

can you suggest how  to iterate year in front end variable