Page 1 of 1

Sub routine

Posted: Thu Aug 14, 2008 2:56 am
by bikan
Hi ,

Can any one tell me the meaning of !, <-1> & <1> in the following :


Cmd = "db2 connect to ": PServer : " user " : USERDB : " using " : DADASS

Call DSExecute("UNIX",Cmd,Output,Status)
Call DSU.Jobharieadh(REST,Output)
!Ans<-1> = Cmd

If Status<1> = 0 Then Ans = @TRUE


PS: is '!' equivalent to OR or NOT[/b]

Posted: Thu Aug 14, 2008 3:41 am
by ArndW
Bikan - you really should know better than to use "urgent" in your message and expect a response. Invariably the frequent posters will ignore posts marked "urgent" for a while. Ray will certainly add his comments regarding the true cost of urgent and immediate support.

This is exacerbated by the fact that your question is answered by looking into the documentation, and you consider it faster and easier to post here instead of reading the file on your PC so I am not particularly inclined to respond.

Posted: Thu Aug 14, 2008 7:06 am
by chulett
Well, now that I'm up from sleepy time...

:? This is oddly coded as I don't know why one would treat 'Ans' as a dynamic array for no good reason, which is what the angle brackets are doing: they denote the element of the array to access. So <1> means the first element and <-1> is special magic to mean "push this to the next available element".

And a bang (!) means 'not' in an expression but used there at the beginning of an assignment line? I'm guessing they think it makes the line a comment. I know '*' does but have never seen '!' used that way that I recall. :?

Posted: Thu Aug 14, 2008 7:21 am
by ArndW
Yes, the "!" at the beginning of the line means that it is a comment.

"IF Status<1> = 0" means the first field of the Status variable, this comes back as one field only so is equivalent to "IF Status = 0" in this case.

Posted: Thu Aug 14, 2008 7:31 am
by chulett
Assumed so, thanks for the confirmation.

Output is a dynamic array here, not Ans or Status, which is why I found this syntax odd. Technically it works cuz DataStage is smarter than us but tells me the coder didn't really understand what they were doing. :?

Posted: Thu Aug 14, 2008 3:47 pm
by ray.wurlod
"#" does NOT introduce a comment in DataStage BASIC.

Looks like the dynamic array was being passed back while testing, since this line is now commented out.

I often pass dynamic arrays - it's a more convenient mechanism than most others that are available.

The -1 syntax in dynamic array assignment means "append a new element"; in this particular case, since the -1 appears at the field position in the reference, it means to append a new field. For this to work properly, the dynamic array (Ans in this case) must already exist (have been assigned a value), even if it's Ans = "", which this code lacks.

Posted: Thu Aug 14, 2008 3:51 pm
by chulett
Early. Misremembered. Edited.