Use value returned from function - muttley:bd - 2010-11-30
Hi,
i don't understand very well how custom function work...and for this my question below.
I would make similar code:
Code: // this is my function
ImdbId = GetImdbIdFromFilmTitle ( "film title" )
// use ImdbId in common function in imdb addons
rating = GetIMDBRatingById ( "ImdbId")
plot = GetIMDBPlotById( "ImdbId")
[...]
how can i make the first step GetImdbIdFromFilmTitle and retrive ImdbId and save it in a buffer for reuse later.
Code: <RegExp input="$$1" output="<chain function="GetImdbIdFromFilmTitle">\1</chain>" dest="5+">
<expression >regex_for_get_title</expression>
</RegExp>
Which destBuffer should be use? and what must return from function (<details>something</details>)...??
I'm confused...and my english is not good, sorry.
Thanks!
- spiff - 2010-12-01
basically you return xml of the form
Code: <details>
<title>foo</title>
<genre>bar</genre>
(more tags)
<chain function="GetImdbIdFromFilmTitle>some data to run the function on</chain>
</details>
this will chain to the function "GetImdbIdFromFilmTitle" with $$1 set to 'some data to run the function on'. in GetImdbIdFromFilmTitle you then do exactly as in GetDetails. you return xml of the form <details>tags</details>. if you have to fetch another page, you use a <url function="somefunction">theurl</url>. it works the same, except this time $$1 will be set to the contents on that url on 'somefunction' entry.
- muttley:bd - 2010-12-01
Thanks for answer...but i don't find the solution for my problem :confused2:
"I would reuse a function result in another functions"
i write this sample code, i hope it's better of my english:
Code: <GetDetails dest="3">
<RegExp input="$$5" output="<details>\1</details>" dest="3">
[...]
<!-- This function find imdb id by film title -->
<RegExp output="<chain function="GetImdbIdFromFilmTitle">Aliens</chain>" dest="5+">
<expression noclean="1" />
</RegExp>
<!-- This one should use the imdb id and get, for example, imdb rating -->
<RegExp output="<chain function="GetImdbRatingById">$$value_returned_by_GetImdbIdFromFilmTitle</chain>" dest="5+">
<expression noclean="1" />
</RegExp>
<!-- Another one should use the imdb id and get, for example, imdb studios -->
<RegExp output="<chain function="GetImdbStudiosById">$$value_returned_by_GetImdbIdFromFilmTitle</chain>" dest="5+">
<expression noclean="1" />
</RegExp>
<expression noclean="1" />
</RegExp>
</GetDetails>
i have tried this:
Code: <RegExp input="$$6" output="\1" dest="5+">
<RegExp output="<chain function="MyFuncTest">passed value</chain>" dest="3">
<expression noclean="1" />
</RegExp>
<RegExp input="$$3" output="<chain function="MyFuncTest2">\1</chain>" dest="6">
<expression noclean="1" />
</RegExp>
<expression noclean="1" />
</RegExp>
with this functions definition:
Code: <MyFuncTest clearbuffers="no" dest="5">
<RegExp input="$$1" output="<details>\1 processedMyFuncTest</details>" dest="5">
<expression />
</RegExp>
</MyFuncTest>
<MyFuncTest2 clearbuffers="no" dest="5">
<RegExp input="$$1" output="<details><plot>\1 processedMyFuncTest2</plot></details>" dest="5">
<expression />
</RegExp>
</MyFuncTest2>
...but nothing
I think there is something that don't understand
|