Ga naar inhoud

Blij dat we Jeroen hier op dit forum hebben


AvD

Aanbevolen berichten

Het café is wel niet de ideale plaats, maar voor alle posters die namen van andere posters hier zien als vrij anonieme mensen: we mogen blij zijn dat we hier iemand hebben als Jeroen Aerts. Lees anders maar eens na wat hij gepost heeft op filemaker.webcrossing in verband met recursieve functies.

 

Dank, Jeroen!

Link naar reactie

Wel jongens, zoveel eer verdien ik echt niet hoor. Er zijn op dit forum posters die veel meer onbezoldigde tijd en energie steken om clarify - volgens mij - wereldwijd tot een van de meest actieve en sympathiekste 'user groups' te maken.

 

De link zelf posten gaat niet, want het is een tread op FileMaker Technet, en niet ale clarifyers zijn lid van Technet - helaas. Voor de geïnteresseerden, ik reageerde, in mijn nimmer aflatende strijd tegen onrecht en misverstanden omtrent recursie, op een bericht waarop een goedbedoeld maar nogal gebrekkig antwoord werd geformuleerd op een vraag over recursieve functies.

 

Als iemand mijn gebazel nog kan volgen, hier komt ie dan, dit is de oorspronkelijke vraag:

 

I can't seem to figure out recursion.

 

I have a field that has up 30+ entries comma demlimited and I want to be

able to display 1-10, 11 -20 in return delim lists

 

This is how far i have gotten

 

Let (

 

Txt = Substitute ( Text ; ", " ; "�" );

;

 

If ( Start < End ; PackParse ( Txt ; Start + 1 ; End ); Txt ))

 

It just returns the complete list.

 

Thanks

--

John Morina

Pueblo Systems, Inc.

 

a bit more info...

 

the custom function is PackParse ( Text ; Start ; End )

 

I am putting the comma delim field with 20 entried and Start = 1 end = 10

 

--

John Morina

Pueblo Systems, Inc.

 

 

Hier is het antwoord:

Hi, John.

 

It doesn't work because the result to be processed when Start < End

doesn't do anything except march through iterations until Start = End,

at which point it returns Txt.

 

The following would work, although you should just use MiddleValues as

Ibrahim suggested:

 

Let (

 

Txt = Substitute ( Text ; "," ; "¶" ) ;

 

If ( Start ≤ End ; LeftValues ( Txt ; 1 ) & PackParse

( RightValues ( Txt ; ValueCount ( Txt ) - 1 ) ; Start + 1 ; End ) )

 

)

 

Regards,

 

...

 

En hier is dan de post:

I may be wrong, but I think that neither the explanation nor the example are correct.

 

The reason why your recursion does not work is simply because Start < End always evaluates to true (as long as Start is less than End), and then your function simply returns Txt without any recursion.

 

Robs example works as long as Start is 1, and doesn't work at all when Start is anything else than 1.

 

The recursive function - which is far too complicated compared to MiddleValues() - would look like:

 

PackParse(Text; Start; End):

 

Let ([

Txt = Substitute ( Text ; "," ; "¶" ) ;

Txt = RightValues(Txt ; (ValueCount(Txt) - Start) + 1) ;

Start = 1 ;

End = End - Start + 1

]

; If ( Start < End ; LeftValues ( Txt ; 1 ) & PackParse

( RightValues ( Txt ; ValueCount ( Txt ) - 1 ) ; 1 ; End - 1 ) )

 

)

 

Just to say that this is a case where you would not want to write a recursive function ;-)

 

- Jeroen

Link naar reactie

Mijn voorbeeld bekijkend, merk ik uiteraard dat er 2 overbodige lijnen in staan. Zoek de 2 verschillen:

PackParse(Text; Start; End): 

Let ([ 
Txt = Substitute ( Text ; "," ; "¶" ) ; 
Txt = RightValues(Txt ; (ValueCount(Txt) - Start) + 1) 
] 
; If (  End > 1 ; LeftValues ( Txt ; 1 ) & PackParse 
( RightValues ( Txt ; ValueCount ( Txt ) - 1 ) ; 1 ; End - 1 ) ) 

) 

Link naar reactie

Doe mee aan dit gesprek

Je kunt dit nu plaatsen en later registreren. Indien je reeds een account hebt, log dan nu in om het bericht te plaatsen met je account.

Gast
Antwoord op deze discussie...

×   Geplakt als verrijkte tekst.   Plak in plaats daarvan als platte tekst

  Er zijn maximaal 75 emoji toegestaan.

×   Je link werd automatisch ingevoegd.   Tonen als normale link

×   Je vorige inhoud werd hersteld.   Leeg de tekstverwerker

×   Je kunt afbeeldingen niet direct plakken. Upload of voeg afbeeldingen vanaf een URL in

×
×
  • Nieuwe aanmaken...