Jump to content
Ketarin forum

if/then or ifempty logic


shawn
 Share

Recommended Posts

Hi, Flo!

 

Can you please add some form of elementary if/then logic for variable assignments?

 

Here's the situation. The microsoft site is making big changes and breaking all the existing URLs. Now there are two different patterns for getting the correct download page and link, and ONLY ONE will work. I need to be able to have one template that takes a single search string and returns the correct result which can be either of two patterns. I'm looking into using a long & ugly pattern that'll actually match both, but maintenance will be a nightmare. Using a switch of sorts would be easier.

 

I'd like to be able to have two variables that each perform a different test for different URL patterns and then be able to use something like "{var1:ifempty:var2}". This would result in testing the value of {var1} and if it's empty (the default value if no match since ~1.5 or so, thanks!), it assigns the value of {var2} to {var1}.

 

Thanks for your consideration, Flo!

Link to comment
Share on other sites

Even for the isempty logic? I can see how you wouldn't be able to overwrite the value of one variable, but I didn't really expect that to work anyway.

 

Rather, I expect a *new* variable to be able to perform the isempty test and return the value of one of two variable values. Currently, if I create a new variable "foo" and assign it the textual value "{bar}" then {foo} will be equal to {bar}. This method should simply allow a single test within the assignment for content. Thus {foo:isempty:bar} wouldn't change the value of {foo}, but would only return the contents of {bar} if {foo} is empty. This would be assigned to either a new variable or a new context (such as downloadsource). Here's an example variable assignment:

      <item>
       <key>
         <string>version</string>
       </key>
       <value>
         <UrlVariable>
           <RegexRightToLeft>false</RegexRightToLeft>
           <VariableType>Textual</VariableType>
           <Regex />
           <TextualContent>{version1:ifempty:version2}</TextualContent>
           <Name>version</Name>
         </UrlVariable>
       </value>
     </item>

Link to comment
Share on other sites

  • 2 weeks later...

Wonder if this could be very valuable for textual variables?, but in a simplified way:

Meaning there are (for example) 3 variables defined.The textual variable fails.Ketarin registeres app update failiure but will not notify user and instead will use predefined backup value or variable.

So it would be like extra redundacy.Textual variables can sometimes break very easily but for example setting a version for something coming from an FTP site pretty much the only way (well there's the date option too yes).

 

But sometimes these future changes can be foreseen.For example i have Firefox Aurora build and a textual variable 7.0a2 (the version).I know that if it will change then next time it will read 8.0a2 then 9.0a2 and so on...

So something like this: {version:7.0a2:8.0a2} meaing first Ketarin tries 7.0a2.If that fails it tries 8.0a2 and so on.

Link to comment
Share on other sites

Another good example: CCleaner Slim

When new version of CCleaner comes the slim build is delayed (on purpose)

So every time a new version comes all templates involving the Slim build download will fail.

 

With if/fail logic it would be possible to set up a backup variable so that the current template will not be broken until they upload the slim build and the template starts working again like it should.

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 years later...

This feature is among the top voted features, so can we discuss the requirement scope a bit?

 

As far as I can see, most needed is {originalVariable:ifempty:useOtherVariable}. Other requirements other than falling back to a different variable if the original one is empty?

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.