You need to set c2 back to 0 before you enter the 2nd while loop. (Or after exiting it, doesn't matter in this case. Use whatever is clearer to you.)
Before entering:
// aim of the script to generate 16 trials that show the following sequences of numbers
// 1 1
// 1 2
// 2 1
// 2 2
// attempting to do this by programmatically populating lists
// stmulus 1
<text thetext>
/items=("1","2")
/select =list.anumber.nextvalue
/ position = (45%, 50%)
</text>
// stimulus 2
<text thetext2>
/items=("1","2")
/select =list.anumber2.nextvalue
/ position = (55%, 50%)
</text>
//list to populate desired end state (1,1,2,2)
<list anumber>
/items=()
/selectionrate = always
/select = sequence
</list>
//list to populate desired end state (1,2,1,2)
<list anumber2>
/items=()
/selectionrate = always
/select = sequence
</list>
//loop through 2 states of c
//calculate the target variable for writing to the list w
// update the control variable to terminate the loop when required c
//loop through 2 states of c2 (at each level of the prior loop c)
//calculate the target variable for writing to the list w2
// update the control variable to terminate the loop when required c2
// write the values when the final value is calculated w and w2
<expt e>
/ onexptbegin = [
var c =0;
var w =0;
var c2 =0;
var w2 =0;
while (c<2) {
w = c+1;
c +=1;
c2 = 0;
while (c2<2) {
w2 = c2+1;
c2 +=1;
list.anumber.appenditem(w);
list.anumber2.appenditem(w2);
}
};
]
/ blocks = [1=b]
</expt>
<block b>
/trials=[1-4 =t]
</block>
<trial t>
/ posttrialpause = 100
/ pretrialpause = 100
/stimulustimes = [0=thetext, thetext2]
/ inputdevice = keyboard
/ validresponse = (" ")
</trial>
After exiting:
// aim of the script to generate 16 trials that show the following sequences of numbers
// 1 1
// 1 2
// 2 1
// 2 2
// attempting to do this by programmatically populating lists
// stmulus 1
<text thetext>
/items=("1","2")
/select =list.anumber.nextvalue
/ position = (45%, 50%)
</text>
// stimulus 2
<text thetext2>
/items=("1","2")
/select =list.anumber2.nextvalue
/ position = (55%, 50%)
</text>
//list to populate desired end state (1,1,2,2)
<list anumber>
/items=()
/selectionrate = always
/select = sequence
</list>
//list to populate desired end state (1,2,1,2)
<list anumber2>
/items=()
/selectionrate = always
/select = sequence
</list>
//loop through 2 states of c
//calculate the target variable for writing to the list w
// update the control variable to terminate the loop when required c
//loop through 2 states of c2 (at each level of the prior loop c)
//calculate the target variable for writing to the list w2
// update the control variable to terminate the loop when required c2
// write the values when the final value is calculated w and w2
<expt e>
/ onexptbegin = [
var c =0;
var w =0;
var c2 =0;
var w2 =0;
while (c<2) {
w = c+1;
c +=1;
//c2 = 0;
while (c2<2) {
w2 = c2+1;
c2 +=1;
list.anumber.appenditem(w);
list.anumber2.appenditem(w2);
}
c2 = 0;
};
]
/ blocks = [1=b]
</expt>
<block b>
/trials=[1-4 =t]
</block>
<trial t>
/ posttrialpause = 100
/ pretrialpause = 100
/stimulustimes = [0=thetext, thetext2]
/ inputdevice = keyboard
/ validresponse = (" ")
</trial>