Right, a timer works better. Here's a version using the timer...
autocam off
make object box 1,1,20,1
offset limb 1,0,0,10,0
position camera 0,10,-20
nSwingTime = timer()
nSwingDirection = 1
do
` main loop, do other stuff here
if timer() > nSwingTime + 10
nSwingTime = timer()
zrotate object 1,object angle z(1) + nSwingDirection
if object angle z(1) = 45 then nSwingDirection = -1
if object angle z(1) = -45 then nSwingDirection = 1
endif
loop
I made the delay 10/1000ths to see it better, just substitute 1000 instead of 10 for a slower rate.