Shouldn't ddat and did a var instead of integer?
It doesn't matter, the compiler will promote the var to an integer implicitly.
The problem is this line: STRING *read = " ";
The STRING is actually a const char *, not a STRING *. Use str_create() to create a temporary string and str_remove() to clean it up afterwards.
Also; You don't need a wait(1) in your loop.