Re: What am I doing wrong with BPXWUNIX sort?

2024-03-07 Thread Charles Mills
Yes, that is exactly my impression. I have not run exhaustive experiments but I 
think that is it. Yes, for reasons related to other logic, this program 
contains Index. = "" but Sri's and my previous successful use of BPXWUNIX sort 
do not.

CM

On Thu, 7 Mar 2024 17:17:23 +, Jeremy Nicoll 
 wrote:

>On Thu, 7 Mar 2024, at 16:54, Charles Mills wrote:
>> Thank you! THAT is the clue I needed. I need to quote the stem names.
>> Passing plain Index. passes "", the value of Index., to sort.
>
>
>So... the difference between your code & Sri's is that you'd
>initialised index. = ""   whereas his didn't have a default
>value for the stems? ...
>
>... because his example didn't have quotes around stem names?

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-07 Thread Jeremy Nicoll
On Thu, 7 Mar 2024, at 16:54, Charles Mills wrote:
> Thank you! THAT is the clue I needed. I need to quote the stem names. 
> Passing plain Index. passes "", the value of Index., to sort.


So... the difference between your code & Sri's is that you'd 
initialised index. = ""   whereas his didn't have a default 
value for the stems? ...

... because his example didn't have quotes around stem names?

-- 
Jeremy Nicoll - my opinions are my own.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-07 Thread Charles Mills
Thank you! THAT is the clue I needed. I need to quote the stem names. Passing 
plain Index. passes "", the value of Index., to sort.

Problem solved. Thanks all.

CM

On Thu, 7 Mar 2024 16:22:02 +, Alan Young  wrote:

>I think I have always used the position specification format. In a couple of 
>processes I ran before, I have
>
>xrc = BPXWUNIX("/bin/sort -bdu -k1.1,1.11 ","pl.","pls.")

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-07 Thread Alan Young
I think I have always used the position specification format. In a couple of 
processes I ran before, I have

xrc = BPXWUNIX("/bin/sort -bdu -k1.1,1.11 ","pl.","pls.")

xrc = BPXWUNIX("/bin/sort -bd -k1.10,1.26 -k2.1,2.8","d.","ds.")

Maybe sort is aborting with a return code (RC, retval, etc.) and no message? 

Alan

-Original Message-
From: IBM Mainframe Discussion List 
Sent: Mar 7, 2024 9:04 AM
To: 
Subject: Re: What am I doing wrong with BPXWUNIX sort?

Thanks all. The mystery deepens.

Using the same stem variable should not be the problem. I have done that before 
successfully, and the sort command documentation talks about how it uses a 
temporary file to avoid clobbering the input data if the files are the same.

BUT ... changing to a different stem variable revealed that sort is not 
populating my output file at all. The new stem variable was uninitialized after 
the sort! THAT is why Index. is unchanged -- sort is not writing to my output 
file/stem at all!

So that leaves the question: why is sort not populating my output stem? I know 
sort is available and actually running because in one test I fat-fingered the 
-k2 and got three messages in stderr.

Why would sort not populate the output stem?

Charles


On Thu, 7 Mar 2024 10:15:10 +0800, David Crayford wrote:

>Youre using the same stem variable for input and output. Use a specific 
>stdout. stem and see if that fixes it. Kolusus snippet works for me.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-07 Thread Charles Mills
Thanks all. The mystery deepens.

Using the same stem variable should not be the problem. I have done that before 
successfully, and the sort command documentation talks about how it uses a 
temporary file to avoid clobbering the input data if the files are the same.

BUT ... changing to a different stem variable revealed that sort is not 
populating my output file at all. The new stem variable was uninitialized after 
the sort! THAT is why Index. is unchanged -- sort is not writing to my output 
file/stem at all! 

So that leaves the question: why is sort not populating my output stem? I know 
sort is available and actually running because in one test I fat-fingered the 
-k2 and got three messages in stderr.

Why would sort not populate the output stem?

Charles

 
On Thu, 7 Mar 2024 10:15:10 +0800, David Crayford  wrote:

>You’re using the same stem variable for input and output. Use a specific 
>stdout. stem and see if that fixes it. Kolusu’s snippet works for me. 

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-07 Thread Schmitt, Michael
Not the question you asked, but...


sort_stem = 'index.'
call sort 6, ???(see comments after code)


/* Sort sort_stem using combsort */
sort: procedure,
   expose (sort_stem)
   arg key_start, key_length
   size = value(sort_stem'0')
   gap  = size
   do until switches = 0 & gap = 1
  gap = gap % 1.3
  select
 when gap =  0 then gap =  1
 when gap =  9 then gap = 11
 when gap = 10 then gap = 11
 otherwise
 end
  switches = 0
  do i = 1 to (size - gap)
 j = i + gap
 if substr(value(sort_stem'i'), key_start, key_length) >,
substr(value(sort_stem'j'), key_start, key_length) then do
/* swap the entries */
hold = value(sort_stem'i')   /* hold   = stem.i */
x = value(sort_stem'i', value(sort_stem'j')) /* stem.i = stem.j */
x = value(sort_stem'j', hold)/* stem.j = hold   */
switches = switches + 1
end
 end
  end
   return


The problem is that as written, the code expects the key_length to be the same 
across all elements of the stem. If yours are variable length then the code 
will need to be adjusted. Maybe in your case it would need to be comparing 
subwords instead of substr.

-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Charles Mills
Sent: Wednesday, March 6, 2024 6:10 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: What am I doing wrong with BPXWUNIX sort?

I am trying to sort a Rexx "array" starting with the second "word" of the 
variables. My "array" is in Index.n and contains records of the form  where  is 0001, 0002, 0003, etc. and string is 2 to 5 
Rexx "words."

Here's my Rexx code:

  Say "Before sort" Index.0 Index.1 Index.2 Index.3
  stdout.0 = 0
  stderr.0 = 0
  Call BPXWUNIX "/bin/sort -k2",Index.,Index.,stderr.
  Do i = 1 to stderr.0
Say "Sort error:" stderr.i
End i
  Say "After  sort" Index.0 Index.1 Index.2 Index.3

And here is the output:

Before sort 8 0001 Main Check 0002 OMVS (FTP Session) 0003 C Validation
After  sort 8 0001 Main Check 0002 OMVS (FTP Session) 0003 C Validation

My expectation is that -k2 would have caused sort to sort on the "descriptive 
strings" (ignoring the ) but obviously that is not what has happened. What 
am I doing wrong? (I have tried both -k2 and -k 2, and also -k1 and +1 -- all 
with the same results.)

Thanks,
Charles

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN



--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-06 Thread David Crayford
You’re using the same stem variable for input and output. Use a specific 
stdout. stem and see if that fixes it. Kolusu’s snippet works for me. 

> On 7 Mar 2024, at 8:41 am, Charles Mills  wrote:
> 
> Thanks. As I said, I have tried both -k2 and -k 2, and also -k1 and +1, all 
> with the same result.
> 
> CM
> 
> On Thu, 7 Mar 2024 00:27:21 +, Sri Hari Kolusu  wrote:
> 
>> Charles,
>> 
>> Try a space after k.
> 
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-06 Thread Dale R. Smith
On Wed, 6 Mar 2024 18:10:28 -0600, Charles Mills  wrote:

>I am trying to sort a Rexx "array" starting with the second "word" of the 
>variables. My "array" is in Index.n and contains records of the form some descriptive string> where  is 0001, 0002, 0003, etc. and string is 2 
>to 5 Rexx "words."
>
>Here's my Rexx code:
>
>  Say "Before sort" Index.0 Index.1 Index.2 Index.3
>  stdout.0 = 0
>  stderr.0 = 0
>  Call BPXWUNIX "/bin/sort -k2",Index.,Index.,stderr.
>  Do i = 1 to stderr.0
>Say "Sort error:" stderr.i
>End i
>  Say "After  sort" Index.0 Index.1 Index.2 Index.3
>
>And here is the output:
>
>Before sort 8 0001 Main Check 0002 OMVS (FTP Session) 0003 C Validation 
>After  sort 8 0001 Main Check 0002 OMVS (FTP Session) 0003 C Validation 
>
>My expectation is that -k2 would have caused sort to sort on the "descriptive 
>strings" (ignoring the ) but obviously that is not what has happened. What 
>am I doing wrong? (I have tried both -k2 and -k 2, and also -k1 and +1 -- all 
>with the same results.)
>
>Thanks,
>Charles

Use a different Stem Name for the output, it can't be the same name as the 
input.

-- 
Dale R. Smith

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-06 Thread Charles Mills
Thanks. As I said, I have tried both -k2 and -k 2, and also -k1 and +1, all 
with the same result.

CM

On Thu, 7 Mar 2024 00:27:21 +, Sri Hari Kolusu  wrote:

>Charles,
>
>Try a space after k.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-06 Thread Sri Hari Kolusu
Charles,

Your example data

/* REXX */
stdin.0=3
stdin.1="0001 Main Check"
stdin.2="0002 OMVS (FTP Session)"
stdin.3="0003 C Validation"

cmd="sort -k 2"
call bpxwunix cmd,stdin.,stdout.,stderr.

say "stdout:"
say "==="
do i=1 to stdout.0
  say stdout.i
end

say "stderr:"
say "==="
do i=1 to stderr.0
   say stderr.i
end

produces


stdout:
===
0003 C Validation
0001 Main Check
0002 OMVS (FTP Session)
stderr:
===

Thanks,
Kolusu


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: What am I doing wrong with BPXWUNIX sort?

2024-03-06 Thread Sri Hari Kolusu
Charles,

Try a space after k.

Something like this

/* REXX */
stdin.0=5
stdin.1="KIJJ 3"
stdin.2="KQWR 1"
stdin.3="ADGF 2"
stdin.4="OEPE 6"
stdin.5="VNVV 5"

cmd="sort -k 2"
call bpxwunix cmd,stdin.,stdout.,stderr.

say "stdout:"
say "==="
do i=1 to stdout.0
  say stdout.i
end

say "stderr:"
say "==="
do i=1 to stderr.0
   say stderr.i
end

Thanks,
Kolusu


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


What am I doing wrong with BPXWUNIX sort?

2024-03-06 Thread Charles Mills
I am trying to sort a Rexx "array" starting with the second "word" of the 
variables. My "array" is in Index.n and contains records of the form  where  is 0001, 0002, 0003, etc. and string is 2 to 5 
Rexx "words."

Here's my Rexx code:

  Say "Before sort" Index.0 Index.1 Index.2 Index.3
  stdout.0 = 0
  stderr.0 = 0
  Call BPXWUNIX "/bin/sort -k2",Index.,Index.,stderr.
  Do i = 1 to stderr.0
Say "Sort error:" stderr.i
End i
  Say "After  sort" Index.0 Index.1 Index.2 Index.3

And here is the output:

Before sort 8 0001 Main Check 0002 OMVS (FTP Session) 0003 C Validation 
After  sort 8 0001 Main Check 0002 OMVS (FTP Session) 0003 C Validation 

My expectation is that -k2 would have caused sort to sort on the "descriptive 
strings" (ignoring the ) but obviously that is not what has happened. What 
am I doing wrong? (I have tried both -k2 and -k 2, and also -k1 and +1 -- all 
with the same results.)

Thanks,
Charles

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN