Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Random file read - PL/1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
Appu

New User


Joined: 26 Apr 2010
Posts: 74
Location: India

PostPosted: Wed Apr 03, 2013 5:09 pm    Post subject: Random file read - PL/1
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: 1715
Location: UK

PostPosted: Wed Apr 03, 2013 5:38 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Apr 03, 2013 5:45 pm    Post subject: Reply to: Random file read - PL/1
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: 1738
Location: Bloomington, IL

PostPosted: Wed Apr 03, 2013 7:47 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Apr 03, 2013 8:02 pm    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Wed Apr 03, 2013 8:26 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Apr 03, 2013 8:39 pm    Post subject: Reply to: Random file read - PL/1
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: 1738
Location: Bloomington, IL

PostPosted: Wed Apr 03, 2013 9:12 pm    Post subject: Re: Reply to: Random file read - PL/1
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Thu Apr 04, 2013 3:41 am    Post subject: Reply to: Random file read - PL/1
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us