How would you code something like this in TX ?
IF CODE = 1, WRITE A REC
OR IF CODE = 2 WRITE B REC
OR IF CODE = 3 WRITE C REC
OR IF.... ETC
OR logic: How do you code for multiple conditions ?
Re: OR logic: How do you code for multiple conditions ?
DatastageTX's If/Then does not have an ElseIF component common to many traditional languages. Also, it does not have true Case statement. What it does have is the EITHER function. Although not the same as a case statement, it can perform in a similar fashion. The premise behind it is to return the first non-null result. Here's one such use:jazzer1 wrote:How would you code something like this in TX ?
IF CODE = 1, WRITE A REC
OR IF CODE = 2 WRITE B REC
OR IF CODE = 3 WRITE C REC
OR IF.... ETC
Code: Select all
=EITHER(
Field1:Record:File
,Field2:Record:File
,Field3:Record:File
)
Code: Select all
=PUT(
"FILE"
,EITHER(
IF(CODE = 1,"ARecFileName")
,IF(CODE = 2,"BRecFileName")
,IF(CODE = 3,"CRecFileName")
)
,EITHER(
IF(CODE = 1,ARec)
,IF(CODE = 2,BRec)
,IF(CODE = 3,CRec)
)
)
Code: Select all
=EITHER(
IF(CODE = 1,PUT("FILE","ARecFileName",ARec))
,IF(CODE = 2,PUT("FILE","BRecFileName",BRec))
,IF(CODE = 3,PUT("FILE","CRecFileName",CRec))
)