<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
Claude Heiland-Allen a écrit :
<blockquote cite="mid:487DCEFD.9060102@goto10.org" type="cite"><br>
<blockquote type="cite">
<pre wrap="">
local LSpell = pd.Class:new():register("lspell")
</pre>
</blockquote>
<pre wrap=""><!---->
This could be the problem, registering classes is usual in .pd_lua files
but not .pd_luax files.
</pre>
</blockquote>
I haven't really understood how to build a pd_luax file then...
nevermind.<br>
<blockquote cite="mid:487DCEFD.9060102@goto10.org" type="cite">
<pre wrap=""></pre>
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap=""><!---->
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.
</pre>
</blockquote>
mmh sure, I just used that cause that was the part of code frank
mentionned and thought this was a kind of pd secure-interacting
functions.<br>
<blockquote cite="mid:487DCEFD.9060102@goto10.org" type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">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?
</pre>
</blockquote>
<pre wrap=""><!---->
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.
</pre>
<br>
</blockquote>
I manage to get it work with this code:<br>
<br>
function LSpell:in_1_symbol(s)<br>
word = s<br>
<br>
cmd = "echo " .. word .. " | /sw/bin/ispell -a | grep \\*"<br>
<br>
p = assert(io.popen(cmd))<br>
<br>
result = p:read("*all")<br>
if(string.len(result) ~= 0) then<br>
self:outlet(1, "symbol", {word})<br>
end<br>
<br>
end<br>
<br>
It outputs the word only if it exists in ispell.<br>
<br>
Can Lua be used as a more stable shell interpretor for all the
functions?<br>
It is of a big interest!!<br>
<br>
Thanks to all,<br>
<br>
Nicolas<br>
<br>
<br>
<br>
<br>
<div class="moz-signature">-- <br>
<a class="moz-txt-link-freetext" href="http://nim.on.free.fr">http://nim.on.free.fr</a></div>
</body>
</html>