Page 1 of 1

Oconv(SrchRslts,"G":DelCnt-1:"/1")

Posted: Fri May 20, 2005 1:10 pm
by ranga1970
Folk;
I am doing the production support and going through one of the routines returned some one

Part of it is

Code: Select all

CMD = "ls -a ":TmpFilePath:TmpFilePrefix:"*":TmpMarkerFileExtension
Call DSExecute ('UNIX',CMD, SrchRslts,ErrorCD)
         SrchRslts = Oconv(SrchRslts,"G":DelCnt-1:"/1")

I am familier with what DSExecute

it returns the value to SrchRslts

after this

Code: Select all

SrchRslts = Oconv(SrchRslts,"G":DelCnt-1:"/1")
what does this exactly do

what does DelCnt-1 mean

and in

Code: Select all

CMD = "ls -a ":TmpFilePath:TmpFilePrefix:"*":TmpMarkerFileExtension
I know what ls -a do

but no clue why it is included in quotes, does this have any additional meaning, if I go to unix prompt and give the command

"ls -a ":somepath/somefile.someextension

it says it did not find the ksh

looking for soem help from DS Guru.. to understand this..
I appreciate the help ...

Posted: Fri May 20, 2005 2:27 pm
by ds_developer
Here is what the G conversion code does (found in Basic.pdf):
G code: Group Extraction
Correlative and Conversion Codes C-21
Format
G [ skip ] delim #fields
The G code extracts one or more values, separated by the specified delimiter, from a field.

skip specifies the number of fields to skip; if it is not specified, 0 is assumed and no fields are skipped.

delim is any single nonnumeric character (except IM, FM, VM, SM, and TM) used as the field separator.

#fields is the decimal number of contiguous delimited values to extract.
It looks to me that it is skipping DelCnt-1 fields.
The delimiter is "/" and it is extracting 1 field.

The quotes in "ls -a " just makes it a string so it can be concatenated with the path, file prefix, "*" and extension (they would not be typed in on the command line).

Hope this helps,
John

(am I a guru now? I doubt it...)

Posted: Fri May 20, 2005 6:07 pm
by ray.wurlod
DelCnt is a variable set earlier in your code.
The Oconv is specifying that the first (DelCnt - 1) "/" characters should be skipped then one pipe-delimited field returned.
An equivalent expression is:

Code: Select all

Field(SrchRslts, "/", DelCnt, 1)
Looks like the original developer grew up with Pick BASIC. Nothing wrong with that - it's just another way of doing things.