[PD] Spell checking / existence of a word
Claude Heiland-Allen
claudiusmaximus at goto10.org
Wed Jul 16 12:35:41 CEST 2008
Nicolas Montgermont wrote:
> Hi Frank,
>
> Frank Barknecht a écrit :
>> Hallo,
>>
>> You could use Lua instead. It's like [shell] on steroids, if you
>> employ something like "io.popen" like this:
>>
>> word = get_word_from_inlet()
>> cmd = "aspell -c " .. word
>> p = assert(io.popen(cmd))
>> result = p:read("*all")
>>
>> Lua is trivial to build on OS-X. I just did it and I'm a complete OS-X
>> idiot. Here's how: You check out pdlua from goto10 subversion, edit
>> Makefile.static to let it find m_pd.h and build for OS-X ("PLATFORM =
>> macosx"), then do "make -f Makefile.static" while connected to the net
>> to let make download and build Lua for you and that's it. OS-X seems
>> to come with everything needed.
>>
>> Ciao
>>
> pdlua compile and load well here I think, console says:
>
> lua 0.5 (GPL) 2008 Claude Heiland-Allen <claudiusmaximus at goto10.org>
> lua: compiled for pd-0.40 on Jul 16 2008 11:41:16
>
> After that I wrote a little pd_luax object called lspell.pd_luax and
> containing:
>
> local LSpell = pd.Class:new():register("lspell")
This could be the problem, registering classes is usual in .pd_lua files
but not .pd_luax files.
> function LSpell:initialize(name, atoms)
> self.outlets = 1
> self.inlets = 1
> return true
> end
>
> function LSpell:in_1_symbol(s)
> pd.post("received :" .. s)
> word = get_word_from_inlet()
> cmd = "aspell -c " .. word
> p = assert(io.popen(cmd))
> result = p:read("*all")
> end
>
> I know there is no output yet but the code is bugging at the
> get_word_from_inlet() function.
where did you define get_word_from_inlet? You should just be able to
use 's', as that's the symbol atom passed to the inlet method.
> When I do :
>
> [symbol toto(
> |
> [lspell]
>
> pd prints:
>
> received :toto
> error: lua: error in dispatcher:
> [string "lspell.pd_luax"]:14: attempt to call global
> 'get_word_from_inlet' (a nil value)
>
> I have no really idea of the way pdlua manage functions and everything.
> Must I dig more into the pd_lua examples or is this only a lua problem I
> can handle if searching universal lua docs?
This seems to be a Lua problem more than a pdlua problem - you use
get_word_from_inlet() but don't define it anywhere.
A pdlua manual is on my todo list, but for now the examples are the best
documentation.
>
> Thanks for your answers,
>
> Nicolas
Hope this helps,
Claude
--
http://claudiusmaximus.goto10.org
More information about the Pd-list
mailing list