Topic on Help talk:Extension:ParserFunctions

#switch doesn't work with #while

4
Gunnar.offel (talkcontribs)

i tried to use a #while and deside by #switch how the reply would be.

in meta-code

     count:=3
     i:=0
     {{#while:
       | i < count
       | i++
         {{#switch:
          | 1 = 
          | count = 
          | #default = 
         }}
       }}   

So, not work isn't exactly right, it works for the first run, all other runs are empty. i solved it now by several #ifeq - compares. Is it a wanted behavior?

Dinoguy1000 (talkcontribs)

#while is not added by Extension:ParserFunctions; I don't know what extension adds it. Looking at your code, and knowing how while loops operate in general, though, I wonder if you didn't forget a pipe before the #switch:

     count:=3
     i:=0
     {{#while:
       | i < count
       | i++
       | {{#switch:
          | 1 = 
          | count = 
          | #default = 
         }}
       }} 
Gunnar.offel (talkcontribs)

The code was just to illustrate in which way i wanted do use.

No, the third pipe isn't correct, the #while has just a head and the instructions. i set the increment as first to get sure, that the loop terminates correctly. #while comes with the extension loops. i posted it here, since it works as said with #ifeq-compares.

I just wanted to get more information how it works. i could swear if i divide it in two pages it would works flawless (calling the secound page like a function). To look more in the philosophy may it be, that the #switch is set late in the page generation, so the loop couldn't generate properly?

Dinoguy1000 (talkcontribs)

I don't know any of the specifics of how/when #switch parsing happens, and I don't have any experience at all with the #while parser function (as you might have guessed when I incorrectly suggested you were missing a pipe in it). At this point, all I can offer is to experiment until you find something that works, and maybe file a bug report for constructions that you think should work, but don't currently (you would do this wherever the #while extension's issues are tracked, and if necessary mark your report(s) as belonging to that extension). I can at least say that it's unlikely any changes will be made to #switch or the other Ext:ParserFunctions functions to make them play nicely with #while, unless the cause of the issues is an actual bug in them that needs to be fixed for other reasons (but if you believe the cause is a bug in them, I'd encourage you to file a bug report anyways, especially if you can come up with a demonstration that only uses extensions enabled on WMF wikis).

Reply to "#switch doesn't work with #while"