help with creating function from snippit

I edited it should be in code snippit now

thanks