It's working as expected now, thank you very much for explaining it to me. This way I could continue writing my library.
btw, the correct command should be :
command <read #@thing#> if action <#thing#; read> then doaction <#thing#; read> else msg <You can't read that.>
(the 'then' was missing)