[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Returning data from C functions called using "loadlib".
- From: William Roper <lacutis@...>
- Date: Wed, 1 Sep 2004 14:22:34 -0700
The return is indicating the number of variables being returned by the
function, not the value being returned by the function.
Ryan.
On Wed, 1 Sep 2004 22:05:27 +0100 (BST), Aaron Newell
<add_aaron_2_x@yahoo.com> wrote:
> Thanks a lot that works great!
> I've got two more questions though:
> 1) why do you "return 1"? As you're obviously not
> returning one.
> 2) Can you do a similar thing with arrays?
>
> Thanks, again!
> Aaron
>
> > I'm quite sure that C code is wrong. You need to
> push a onto the > > > stack,
> > and
> > then return how many results your function is
> returning. So the
> > function
> > would be something like:
> >
> > static int functionFromCLibrary(lua_State* L) {
> > int a = (int)lua_tonumber(L, -1);
> > printf("cfunction: %d\n", a);
> > a = a + 1;
> > printf("cfunction now: %d\n", a);
> > lua_settop(L, 0);
> > lua_pushnumber(L, a);
> > return 1;
> > }
> >
> >
> > Greetings,
> > Ignacio Burgueño
>
>
> ___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
>