shawn Posted July 9, 2011 Report Share Posted July 9, 2011 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 More sharing options...
floele Posted July 10, 2011 Report Share Posted July 10, 2011 Hm, I will consider this. Ifempty still seems simple enough. Link to comment Share on other sites More sharing options...
shawn Posted July 10, 2011 Author Report Share Posted July 10, 2011 Thanks, Flo! Link to comment Share on other sites More sharing options...
floele Posted July 14, 2011 Report Share Posted July 14, 2011 It's actually a little more complicated though as I see now, since a variable does not actually "have knowledge" of any other variable... Link to comment Share on other sites More sharing options...
shawn Posted July 14, 2011 Author Report Share Posted July 14, 2011 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 More sharing options...
Tomorrow Posted July 23, 2011 Report Share Posted July 23, 2011 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 More sharing options...
Tomorrow Posted July 28, 2011 Report Share Posted July 28, 2011 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 More sharing options...
floele Posted August 7, 2011 Report Share Posted August 7, 2011 Still "difficult", not because "ifempty" but because the value of another variable needs to be inserted. That requires a couple of changes to the variable system. Link to comment Share on other sites More sharing options...
floele Posted September 10, 2015 Report Share Posted September 10, 2015 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 More sharing options...
shawn Posted September 15, 2015 Author Report Share Posted September 15, 2015 Nope. Keep it simple. Link to comment Share on other sites More sharing options...
MAPJe71 Posted January 31, 2018 Report Share Posted January 31, 2018 The "ifempty" was implemented in Ketarin v1.8.5. Has anyone (succesfully) used the function? See also my question here. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now