Conditional statement problems

UKenGB

Member
I am starting the message with the following:-

<IF [[Firstname]] <> "">Hi [Firstname], </IF>I hope......

So, if there is a Firstname, it will be used preceded by "Hi " and followed by ", " with that end space obviously required. BUT, when viewed in the preview mode, the trailing space is stripped. How can I stop this and allow the use of that very necessary space if the condition is met?

In fact, I think the above is a more general problem that trailing spaces in the conditional text get stripped.

Also, I cannot get the following to work:-

<IF [[Type]] ?# "Club">The</IF>

even when Type is 'Car Club' and obviously should match.

If I instead use = "Car Club", it works. Why does the 'ends with' fail?
 

stanbusk

Administrator
Staff member
Add your space outside the conditional statements:

<IF [[Firstname]] <> "">Hi [Firstname],</IF> I hope......

About your second question, are you sure the condition is supposed to match? Please confirm and if yes I would have a closer look.
 

UKenGB

Member
I can't believe you suggested that. The space is of course ONLY required when the condition is met. If the space is included in ALL cases, those with no Firstname will start with a space before the first word.

I have been able to avoid other instances of this, what can only be called a bug, by rearranging it to have the conditional space IN FRONT of the text, rather than trailing and this works, but can only be used when it is all in-line with other text and not at the start of a line/para etc.

Basically this is a generic bug, as I mentioned before, where trailing spaces (part of the conditional text) are stripped.

Having said that, maybe it's not a bug as you intend it to do this, but either way it is WRONG and needs fixing. It shouldn't be doing anything to the text unless specifically coded to do that in the conditional structure.

As for the problem with the 'ends with' comparison operator, I'm not sure what you are asking. If the value of that field (Tag) is 'Car Club', the match currently fails when it obviously should succeed since that quite unequivocally DOES end with Club.

If I instead use the = operator and the comparison text to 'Car Club', the match succeeds as it should, so the basic structure is correct. For whatever reason the 'ends with' operator currently is not working.

I just tried your suggestion of !# (which I would suggest is bad syntax in any case), but it made no difference. In the end I used the '*' contains operator and that seems to work. But 'ends with' is just broken.

BTW, why not have 'Doesn't start with' and Doesn't end with' operators. They are very valid and important operators and easy to simply place the '!' in front to reverse the function. Except that the basic operators don't work though:-(
 

stanbusk

Administrator
Staff member
About spaces there a thing called non-breaking-space, you can insert that type of space with Alt+Space. Have you tried?

About your second question, try !#
It works perfect for me here.
 

UKenGB

Member
stanbusk said:
About spaces there a thing called non-breaking-space, you can insert that type of space with Alt+Space. Have you tried?
Yes, that's exactly how I got around the problem. But, that's not the real answer is it. There is a problem with your program which is stripping a character from the end of the text that the user has decided is required. Being forced to use an alternative is NOT a solution, it's a bodge. It is your code that needs fixing to stop it from modifying the conditional text.

You need to accept responsibility for this and suggest when you might be able to correct it.

About your second question, try !#
It works perfect for me here.
Well, I already said it doesn't work for me, but I tried again and hey, guess what, it still doesn't work.

Something has occurred to me. The field (tag) I am using is at the end of the row. Is there any chance that your comparison code is including the 'end of row' character as part of that last field when it performs the comparison? In which case, it would never match the end of the text that exists in the last field. Is this perhaps another little bug?

In any case, are you now saying that the 'ends with' and 'begins with' comparison operators are in fact '!#' and '#!' ?

Why is the manual/help page so completely incorrect about this. You have even referenced that page in responses to other questions about conditional statements here on the forum. Now you are saying it is in fact wrong?

Why use the negating character '!' ? That is entirely inconsistent. Can you not use the actual regex '$' and '^'. At least that is consistent with the vast usage of reqex. Anyway, using '!' is not appropriate.
 

stanbusk

Administrator
Staff member
Yes, that's exactly how I got around the problem. But, that's not the real answer is it. There is a problem with your program which is stripping a character from the end of the text that the user has decided is required. Being forced to use an alternative is NOT a solution, it's a bodge. It is your code that needs fixing to stop it from modifying the conditional text.
I agree, I guess you are using a Mac, right? If so create a plain text file and copy that to it:
Code:
<html>
<head></head>
<body> My text
</body>
</html>
Name it test.html and drop it on your Safari icon. You will find out how the heading space is not rendered.
 

UKenGB

Member
I'm not sure what the relevance is to HTML since all renderers ignore (i.e. strip) leading whitespace. But setting up a conditional structure has nothing to do with HTML, at least from the user's point of view.

If I use regex to replace some text (e.g. with sed, or awk etc), what I specify as the replacement text is exactly what is used. It doesn't mess with it in any way and that's how it should be.

What about the 'ends with' problem?
 

stanbusk

Administrator
Staff member
Oh yes it has to do, and a lot! The preview is HTML and WebKit is being used. Webkit remove that space, it is was I am trying to explain you, now I have to think about how to fix that. Not easy nut not impossible.

The second problem, I have tested again and again '!# ' and it works just fine four me. I also checked the code and all is all right.
 

UKenGB

Member
I'll let you get on with fixing the trailing space stripping problem.

This is where we're at regarding the 'ends with' problem.

First of all the current manual page states:-

#? starts with
?# ends with

This is WRONG for 2 reasons.

1. You must use '!' and not '?'

So, why are you actually using '!' instead of what the manual states. One of them must be wrong. IMO you should NOT use '!' because that is expected to mean some sort of negation, so to use it in this context is a BAD idea. You should simply change your code to instead use '?'. No-one will notice the change since it's obvious no-one else is using this function or they would have complained about the error.

2. They are the WRONG WAY ROUND. IOW, it should state:-

!# starts with
#! ends with

I have tested many times and this is the consistent result. Using:

<IF [[Type]] op "Club"> The</IF>

Type =                              Bike Club                              Other
op=*                                  matches                                 no
op=#?                                     no                                     no
op=?#                                     no                                     no
op=!#                                      no                                     no
op=#!                                 matches                                 no

I've NO idea how you are testing and finding '!#' works. Your testing must be flawed in some way. Were you perhaps testing 'begins with'?

So, re-code to use '?' instead of '!' and then modify the manual so it's the right way round.
 

UKenGB

Member
stanbusk said:
What field are you using the condition with? I only tried with the company field.
I'm using 2 of the OPT fields. One is renamed Type and the other is Source. But I tried it using the standard Company field also and the result was the same.

And yes, I am on a Mac (Pro with OSX 10.7.2) in case there is some discrepancy between the platforms.
 

stanbusk

Administrator
Staff member
The conditional are inverted in the code, use the opposite and it will work. I have fixed this problem for next version.
 

UKenGB

Member
OK, since I worked it out, I know how to avoid the problem in the future, but I implore you to NOT use '!'. Please implement it exactly as shown on the manual page as that makes more sense and also means you won't have to update the manual :wink:
 

stanbusk

Administrator
Staff member
The manual is right and the software is wrong, don't worry, the software will be fixed to match the manual and not the opposite.
 
Top