Jump to content
pctechtv

Recursive Custom Function

Recommended Posts

pctechtv

In my solution that is based on this type of relationship (pic) I have a custom function called Infobase(). What it does is let me deduce the parent of a particular Primary Key. I use it to do things like link Information Topics back to found sets.

http://pctechtv.com/show/cus.png

So I am imagining that I keep feeding the result of Infobase() back into itself that I can come up with the parent of all parents in a particular topic. I was looking into to recursion in Custom Function and saw some info that said a Custom Function cannot iterate but it can recursively call itself. Assuming that is true I would think that this can be done with my function Infobase(). Eventually the “empty” of the result could insure we are at the highest parent. In my attempt to create a recursive Custom Function I must be doing something wrong?

Share this post


Link to post
Share on other sites
eos
[…] deduce the parent of a particular Primary Key […] come up with the parent of all parents in a particular topic […]

 

Could you give some concrete examples?

Share this post


Link to post
Share on other sites
pctechtv

I received some help that that showed me what I was doing wrong and not understanding. It explained the Let function better so I see why my declaration and reference were getting me no where. This worked

 

Let ( id = Infobase ( anid ) ;
       If ( IsEmpty ( id ) ; anid ;
                                   DuParent ( id )
          ) // if
      )// let

 

​The Let variables only keep there value for as long as the Let Evaluates is what I learned and it is a great help.

Edited by pctechtv

Share this post


Link to post
Share on other sites
eos

That's good for you, though now I'm none the wiser. I would have loved to see a practical example (as in real data). Also, using Let () is not the crux of the matter, it just makes things easier to read (which of course is nothing to be sneezed at).

 

btw, if you have a hierarchical relationship, you can also use a recursion of sorts without a CF, by using the calculation field itself in its definition – though it's not the exact same field, but its version from the related TO, like in:

 

cPath =

 

name & Case ( not IsEmpty ( parentTable::someID ) ; parentTable::cPath )

 

where FileMaker regards the cPath you're currently defining as a different entity from the cPath you're referring.

Share this post


Link to post
Share on other sites
This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Terms of Use