I would do this with a subroutine record or an SNL program. Yes, you can make loops in EPICS database, but I would not implement your example in that way.
If I had to do this kind of stuff in a database - for example, if I had to be able to write the _expression_ at run time - I'd use an acalcout record, and part of the _expression_ for your example would look like this:
sum(100*(ix%2)[0,9])+sum(-100*(!(ix%2))[0,9])
where, for example
ix is (0,1,2,3,...)
ix%2 is (0,1,0,1,...)
ix[0,9] is (0,1,2,3,4,5,6,7,8,9,0,0,0,...)
If you're really desperate for an explicit loop, the acalcout and scalcout records have the "until" function:
a:=0;b:=0;k:=until(a:=a+1.3;b:=b+1;b>=9);a
which is arcane, and difficult, and merely implements this:
a=0;
for (b=0; b<10; b+=1) {
a += 1.3;
}
If you want to process records in a loop, on the other hand, I second Bob's advice, and note that the calcout record has more help for conditionally executing a link. Finally, the sscan record does loops, and I've used it with calc records to make 2D arrays
of sample data.
Tim Mooney (
[email protected]) (630)252-5417
Software Services Group (www.aps.anl.gov)
Advanced Photon Source, Argonne National Lab