Routine code issue

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
evee1
Premium Member
Premium Member
Posts: 96
Joined: Tue Oct 06, 2009 4:17 pm
Location: Melbourne, AU

Routine code issue

Post by evee1 »

Sorry for hijacking this thread.
I have a routine that validates whether a file contains a header. It's good enough to check whether the first line in a file starts with "H".

My routine contains the following code:

Code: Select all

ExCmd = "head -1 ":FilePath:"/":FileName:" | cut -c1"
Call DSExecute("UNIX", ExCmd, Output, SystemReturnCode)
If Output = "H" Then
   Ans = "OK"
End Else
   Ans = "Error"
End
[/color]

When I test it the Ans is always "Error". I have added the following code to see what the Output actually is.

Ans = "[":Trim(Output):"]"


It looks there is an extra CR returned after the result (see below). How can I get rid of it?

Result = [H
]
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Start a new thread. This question is unrelated to the subject of this particular thread.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
evee1
Premium Member
Premium Member
Posts: 96
Joined: Tue Oct 06, 2009 4:17 pm
Location: Melbourne, AU

Post by evee1 »

Sorry. Will do.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Un-hijacked. Next time don't be sorry, just don't do it. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That "Output" can be multiple lines and is returned in a dynamic array so you've got a Field Mark in there as well. Use array notation to check it:

Code: Select all

If Output<1> = "H" Then
-craig

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