You are here

Preconditional and postconditional arguments

4 posts / 0 new
Last post
ankont
Offline
ankont's picture
Has donated long time ago
Joined: 9 years
Last seen: 4 years
Preconditional and postconditional arguments

I seem to have confused the syntaxes for arguments. See the below example from the documentation:

rating.modify {replace("")|nine|9} replaces the word 'nine' by the number 9, also if the word 'nine' is the whole rating

What is the meaning of the two quotes after replace? It is implied that they are postconditional, as if it is null. Like "when you do the replace, make sure that rating will be left empty".
But if the meaning is this, what is the meaning of:

rating.modify {replace("nine")|nine|9}

Now I assume that it is a preconditional argument, like "check first that rating is nine, then do the replace". In preconditional arguments the manual states clearly that the operation could be omitted, as well as the element to be checked. So, this leaves as with the plain string to check, in this case the string "nine". Am I wrong?
The syntax for both is exactly the same! Could they have different meanings?

francis
Offline
francis's picture
Has donated long time agoWG++ Team member
Joined: 11 years
Last seen: 1 month
Is the support helpful?
support us
rating.modify {replace("")|nine|9}

means: if rating is equals "" (so empty), do the replace. (so this line will never do anything)
 

rating.modify {replace("nine")|nine|9}

means: if rating is equals "nine", then do the replace (so only when it is "nine", so an extra space in the rating and the replace will also not be done)
 
Both are preconditional arguments.
The only postconditional arguments are "null" and "notnull" (and "anycase")

ankont
Offline
ankont's picture
Has donated long time ago
Joined: 9 years
Last seen: 4 years

OK, that is the way it should be, but the first line I wrote and the mentioned comments ("replaces ... the whole rating") came from the manual!
Page 37, paragraph 4.6.4.9.

WGMaker
Offline
WGMaker's picture
WG++ Team memberDonator
Joined: 11 years
Last seen: 2 hours
Is the support helpful?
support us

Hi ankont,

I just finished the update of the manual, and , indeed that line in it is wrong!! Chapter 4.6.5 is an old one, and I must confess that I didn't check it because I assumed it was still OK. I will review that section next update.

The explanation of Francis is -of course- the correct one.

(In fact the post-conditionals were the first conditionals and are not very much in use, but they are still there because of compatibity reasons.)

 

Jan

Log in or register to post comments

Brought to you by Jan van Straaten

Program Development - Jan van Straaten ------- Web design - Francis De Paemeleere
Supported by: servercare.nl