I have never done anything like this, and I am not conversant enough and there are no examples I can find to do this.
I need to call or pcall a callback function defined in your program and get a return value
rtx = cb_io_3(k, v)
the internals of the callback decision are unimportant at the moment, but are based on data you send in to call my program
you may have 0 to any number of callbacks for this io and it is based on fields you supply therefore
you may have
cb_io_1
cb_io_2
cb_io_3
cb_io_n
['mtx_fn'] =
{
[3] =
{
(function = cb_io_[ix](k, v) end, }
-- how do I pcall
--how do I get the function return 'o' or 'io'
end),
}
I can get nothing on this order to compile:
['mtx_fn'] = {[3] = function = ((rtx) = cb_io_[ix](k, v} end))},
so -- is it like---?
my first example
in my entry
and I code
rtx = ['mtx_fn]()
and your callback looks something like
function cb_io_3( k, v)
--some such nonsense to return a value
if alwchg = '0' then
return 'o'
else
return 'io'
end
end
what other things should I be doing to make it work?
* how do I create my own callback functions with return value?
how do I create my own callback functions with return value?
Last edited by Ron Melby on 19 May 2021 14:16, edited 1 time in total.
FH V.6.2.7 Win 10 64 bit
- ColeValleyGirl
- Megastar
- Posts: 4854
- Joined: 28 Dec 2005 22:02
- Family Historian: V7
- Location: Cirencester, Gloucestershire
- Contact:
Re: how do I create my own callback functions with return value?
Have the callback functions as parameters to your function.
Helen Wright
ColeValleyGirl's family history
ColeValleyGirl's family history
Re: how do I create my own callback functions with return value?
I dont understand that, nor how to do that, at least not that I know of, can you elucidate, Helen? Thanks.
FH V.6.2.7 Win 10 64 bit
Re: how do I create my own callback functions with return value?
oh wait....
k = key
v = val
rtx = ''
you mean
cb_io_[ix-](k, v, rtx) end
and then use rtx after the callback, right?
k = key
v = val
rtx = ''
you mean
cb_io_[ix-](k, v, rtx) end
and then use rtx after the callback, right?
FH V.6.2.7 Win 10 64 bit
- ColeValleyGirl
- Megastar
- Posts: 4854
- Joined: 28 Dec 2005 22:02
- Family Historian: V7
- Location: Cirencester, Gloucestershire
- Contact:
Re: how do I create my own callback functions with return value?
Code: Select all
function X (doStuff)
[snip]
doStuff(some parameters that match the requirements of doStuff)
[snip]
end
function doSomething()
--do something
end
X(doSomething)
Helen Wright
ColeValleyGirl's family history
ColeValleyGirl's family history