Use value returned form function
#1
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="&lt;chain function=&quot;GetImdbIdFromFilmTitle&quot;&gt;\1&lt;/chain&gt;" 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!
Reply
#2
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.
Reply
#3
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="&lt;details&gt;\1&lt;/details&gt;" dest="3">
[...]
       <!-- This function find imdb id by film title -->
       <RegExp output="&lt;chain function=&quot;GetImdbIdFromFilmTitle&quot;&gt;Aliens&lt;/chain&gt;" dest="5+">
                <expression noclean="1" />
       </RegExp>
    
    <!-- This one should use the imdb id and get, for example, imdb rating -->    
      <RegExp output="&lt;chain function=&quot;GetImdbRatingById&quot;&gt;$$value_returned_by_GetImdbIdFromFilmTitle&lt;/chain&gt;" dest="5+">
                <expression noclean="1" />
       </RegExp>

    <!-- Another one should use the imdb id and get, for example, imdb studios -->    
      <RegExp output="&lt;chain function=&quot;GetImdbStudiosById&quot;&gt;$$value_returned_by_GetImdbIdFromFilmTitle&lt;/chain&gt;" 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="&lt;chain function=&quot;MyFuncTest&quot;&gt;passed value&lt;/chain&gt;" dest="3">
                    <expression noclean="1" />
         </RegExp>
    <RegExp input="$$3" output="&lt;chain function=&quot;MyFuncTest2&quot;&gt;\1&lt;/chain&gt;" dest="6">
                    <expression noclean="1" />
         </RegExp>
                <expression noclean="1" />
</RegExp>

with this functions definition:
Code:
<MyFuncTest clearbuffers="no" dest="5">
        <RegExp input="$$1" output="&lt;details&gt;\1 processedMyFuncTest&lt;/details&gt;" dest="5">
            <expression />
        </RegExp>
    </MyFuncTest>
    <MyFuncTest2 clearbuffers="no" dest="5">
        <RegExp input="$$1" output="&lt;details&gt;&lt;plot&gt;\1 processedMyFuncTest2&lt;/plot&gt;&lt;/details&gt;" dest="5">
            <expression />
        </RegExp>
    </MyFuncTest2>
...but nothing

I think there is something that don't understand Oo
Reply

Logout Mark Read Team Forum Stats Members Help
Use value returned form function0