EventToCode function

Convert string events to coded events