Reinhard, you are using active polling which might be very time consuming for your cpu; and I guess your activate part is not working. Here is a slightly modified version:
long year, month, day
if type.of.field() = DB.ENUM then
child = activate("ttstpcalendar")
wait(child, WTHANG) | instead of "repeat until g.value > 0"
num.to.date(g.value, year, month, day)