1

我对 if 语句有一点问题,因为它只填充最后一个 elseif

%%[IF @Add3 == "Y" AND @Add4 == "Y" AND @Add5 == "N" THEN
        SET @WhichNom1 = "1"
        SET @WhichNom2 = "2"

ELSEIF @Add3 == "Y" AND @Add4 == "N" AND @Add5 == "Y" THEN
        SET @WhichNom1 = "1"
        SET @WhichNom2 = "3"

ELSEIF @Add3 == "N" AND @Add4 == "Y" AND @Add5 == "Y" THEN
        SET @WhichNom1 = "1"
        SET @WhichNom2 = "3"
]%%
@WhichNom1
@WhichNom2
%%[ENDIF]%%

当最后一个 ELSEIF 为 TRUE 时,上面的代码将显示两个变量。我需要做什么来检查 3 个语句并为每个场景显示 WhichNom1 和 WhichNom2?

谢谢丹

4

3 回答 3

3

如果最后一个 elseif 为真,则仅打印变量。

像这样移动它们:

...    
ELSEIF @Add3 == "N" AND @Add4 == "Y" AND @Add5 == "Y" THEN

        SET @WhichNom1 = "1"
        SET @WhichNom2 = "3"
]%%
%%[ENDIF]%%

@WhichNom1
@WhichNom2

所以他们在 IF/ELSEIF 之外。这样它们将始终被打印,但变量将根据子句设置不同。

编辑:

如果您只想在其中一个语句为真时打印变量,那么您将(如您所提到的)需要在 if 语句中打印它们,或者您可以:

SET @WhichNom1 = ""
SET @WhichNom2 = ""

在 if 语句之前,然后在它们之后:

IF @WhichNom1 != "" THEN @WhichNom1
IF @WhichNom2 != "" THEN @WhichNom2

所以只有在它们被设置为“”以外的东西时才打印它们。

于 2014-07-18T10:34:00.360 回答
2

我设法使用两个 IF 语句以稍微不同的方式对其进行排序

%%[IF @Add3 == "Y" AND @Add4 == "Y" AND @Add5 == "N" THEN
SET @WhichNom1 = "1"
SET @WhichNom2 = "2"
SET @Status = "T" 

ELSEIF @Add3 == "Y" AND @Add4 == "N" AND @Add5 == "Y" THEN
SET @WhichNom1 = "1"
SET @WhichNom2 = "3"
SET @Status = "T" 

ELSEIF @Add3 == "N" AND @Add4 == "Y" AND @Add5 == "Y" THEN
SET @WhichNom1 = "2"
SET @WhichNom2 = "3"
SET @Status = "T" 

ELSE

SET @Status = "F" 

ENDIF]%%

%%[IF @Status == "T" THEN]%%
@WhichNom1
@WhichNom2
%%[ENDIF]%%

感谢您的帮助罗布!

于 2014-07-21T06:47:22.093 回答
1

罗伯是对的。此外,如果您想在块之外打印@WhichNom1,您可能需要编写如下代码:@WhichNom2AMPscript

%%[
IF @Add3 == "Y" AND @Add4 == "Y" AND @Add5 == "N" THEN
SET @WhichNom1 = "1"
SET @WhichNom2 = "2"
SET @Status = "T" 

ELSEIF @Add3 == "Y" AND @Add4 == "N" AND @Add5 == "Y" THEN
SET @WhichNom1 = "1"
SET @WhichNom2 = "3"
SET @Status = "T" 

ELSEIF @Add3 == "N" AND @Add4 == "Y" AND @Add5 == "Y" THEN
SET @WhichNom1 = "2"
SET @WhichNom2 = "3"
SET @Status = "T" 

ELSE

SET @Status = "F" 

ENDIF
]%%

%%[ IF @Status == "T" THEN ]%%

%%= v(@WhichNom1) =%%<br />
%%= v(@WhichNom2) =%%

%%[ ENDIF ]%%
于 2014-10-22T20:47:54.963 回答