Cache’ Object Script is an interesting language. Take a look at the following two loops

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
test
	s done=0
	f ln=1:1:10 d  q:done
	. w !,ln
	. i ln=5 s done=1
	w !,"ln after loop "_ln
	q
test2
	s done=0
	f ln=1:1:10 q:done  d
	. w !,ln
	. i ln=5 s done=1
	w !,"ln after loop "_ln
	q

The goal is stop after five iterations and then use the ending index to do something more. Executing the above code results in…

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
PLAY>d test

1
2
3
4
5
ln after loop 5
PLAY>d test2

1
2
3
4
5
ln after loop 6
PLAY>

Can you spot the difference?

Back to blog...