If statement I never seen before

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ggarze
Premium Member
Premium Member
Posts: 78
Joined: Tue Oct 11, 2005 9:37 am

If statement I never seen before

Post by ggarze »

Just started a new job and looking over an IF statement that in my 7 years I've never seen before. Can someone explain to me what's going on in this statement. I never knew you can end an IF statment with a then and else then do another statement then else. I've always seen If then Else If then ...

If Not( If Len(Trim(svINPUTFIELD)) = Count(svINPUTFIELD,' ') Then 0 Else 1) Then TrimF(TrimB(svINPUTFIELD)) Else svINPUTFIELD

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's basically just your normal if-then-else, it's just that the if side has a self-contained if-then-else inside it, one that resolves to true or false.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ggarze
Premium Member
Premium Member
Posts: 78
Joined: Tue Oct 11, 2005 9:37 am

Post by ggarze »

Thanks Craig - so if I understand correctly:

0 = true "Then TrimF(TrimB(svINPUTFIELD))"
1 = false "Else svINPUTFIELD"
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Other way 'round, actually. 0 is false and (technically) any non-zero value evaluates as true, including the 1 used here.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply