IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Random file read - PL/1


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Appu

New User


Joined: 26 Apr 2010
Posts: 73
Location: India

PostPosted: Wed Apr 03, 2013 5:09 pm
Reply with quote

Hi All,

In C programming language we can set pointers on files using functions like getp and setp. There we can also start reading the file from a pointer value by using setp. Is there any such random read functionality available in PL/1.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Apr 03, 2013 5:38 pm
Reply with quote

What did you not understand in the PL/1 manuals?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Apr 03, 2013 5:45 pm
Reply with quote

It would help greatly to know what type of file you are talking about reading from PL/I.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Apr 03, 2013 7:47 pm
Reply with quote

In what implementation of C are getp and setp library functions?

Note that in the LUW environment, you have "files", unstructured streams of bytes; the onus for making sense of them is entirely on the application programmer. IN MVS, we have "data sets", where a great deal of information is available to the operating system, and it handles many I/O functions, at the (not very high, IMNSHO) price of not allowing incompetent programmers to do stupid things like read half of one record and a quarter of another.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Apr 03, 2013 8:02 pm
Reply with quote

Akatsukami wrote:
In what implementation of C are getp and setp library functions?

Note that in the LUW environment, you have "files", unstructured streams of bytes; the onus for making sense of them is entirely on the application programmer. IN MVS, we have "data sets", where a great deal of information is available to the operating system, and it handles many I/O functions, at the (not very high, IMNSHO) price of not allowing incompetent programmers to do stupid things like read half of one record and a quarter of another.


Ah, C and C++ are LE languages. I'm afraid you can do this in z/OS as well (now). Plenty of other little "trip me, please"s as well, like trying to do it with a PS which has been MODded.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Apr 03, 2013 8:26 pm
Reply with quote

Bill Woodger wrote:
Akatsukami wrote:
In what implementation of C are getp and setp library functions?

Note that in the LUW environment, you have "files", unstructured streams of bytes; the onus for making sense of them is entirely on the application programmer. IN MVS, we have "data sets", where a great deal of information is available to the operating system, and it handles many I/O functions, at the (not very high, IMNSHO) price of not allowing incompetent programmers to do stupid things like read half of one record and a quarter of another.


Ah, C and C++ are LE languages. I'm afraid you can do this in z/OS as well (now). Plenty of other little "trip me, please"s as well, like trying to do it with a PS which has been MODded.

You could certainly always do this in Assembler, and I'm sure that software engineers just learning the language have so baked the dog on numerous occasions. But in z/OS C/C++, I don't believe that an MVS data set can be opened as a stream, which would be necessary to do this.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Apr 03, 2013 8:39 pm
Reply with quote

Just a quick google (due to something I was looking at a couple of months ago).

http://publib.boulder.ibm.com/infocenter/zvm/v5r4/index.jsp?topic=/com.ibm.zos.r9.cbcpx01/cbcpg18096.htm

I believe byteseek will produce the desired effect, hand-in-hand with some "functions" (as per ANSI C, I think). The docs (elsewhere) go into what happens when you try to write partial records and stuff like that, as though it were quite normal :-)
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Apr 03, 2013 9:12 pm
Reply with quote

Bill Woodger wrote:
Just a quick google (due to something I was looking at a couple of months ago).

http://publib.boulder.ibm.com/infocenter/zvm/v5r4/index.jsp?topic=/com.ibm.zos.r9.cbcpx01/cbcpg18096.htm

I believe byteseek will produce the desired effect, hand-in-hand with some "functions" (as per ANSI C, I think). The docs (elsewhere) go into what happens when you try to write partial records and stuff like that, as though it were quite normal :-)

But the fine manual states:
Quote:
When you specify this parameter and open a file in binary mode, all repositioning functions (such as fseek() and ftell()) use relative byte offsets from the beginning of the file instead of encoded offsets.

(Emphasis added.)
Again, I don't believe that an MVS data set can be opened in binary mode (a Unix file, yes, but who cares about Unix? icon_biggrin.gif)
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 04, 2013 3:41 am
Reply with quote

z/OS V1R11.0 XL C/C++ Run-Time Library Reference z/OS V1R10.0-V1R11.0 on fopen.

I know there's more, but I'm not going to look. I was researching RECFM=FS/FBS, which someone thought improved IO times on batch files (it doesn't), but when doing a C/C++ access to a specific starting byte in a file, FS/FBS allows a calculation to find it, whereas F/FB reads from the start of the file each time it is necessary (counting the bytes) which is where the "performance" confusion arose.

Effectively the same as is able to be done in Assembler, but more accessible to Software Engineers from non-Mainframe backgrounds to enable them to grind a CPU into the dust to "fix up" their code, because they can't design a program :-)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top