Page 1 of 1

Routine code issue

Posted: Mon May 23, 2011 11:13 pm
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
]

Posted: Tue May 24, 2011 1:18 am
by ray.wurlod
Start a new thread. This question is unrelated to the subject of this particular thread.

Posted: Tue May 24, 2011 1:22 am
by evee1
Sorry. Will do.

Posted: Tue May 24, 2011 6:23 am
by chulett
Un-hijacked. Next time don't be sorry, just don't do it. :wink:

Posted: Tue May 24, 2011 6:27 am
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