View previous topic :: View next topic |
Author |
Message |
rnanavaty Beginner
Joined: 12 Apr 2006 Posts: 29 Topics: 20
|
Posted: Tue Jun 14, 2011 6:41 am Post subject: Assembly language : Sequential file reading |
|
|
A file is defined in assembly language as VB (Variable Block) where first record contains 5000 characters while 2nd record is of 10 bytes.
Above file opened in read mode. We want to write 1st record in one output sequential file if first character of 2nd record is 'A'.
How can we do it.
Will locate mode (defined in MACRF) will help in it ? |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 699 Topics: 63 Location: USA
|
|
Back to top |
|
|
zatlas Beginner
Joined: 17 Dec 2002 Posts: 43 Topics: 4
|
Posted: Sun Jun 26, 2011 12:26 am Post subject: |
|
|
Like any language, you need to store the first record in a reliable memory storage before you read the next one. You may not rely on MACRF=GL because that memory in the buffer is bound to be reused by QSAM at the next READ and is not under your control. If you know what is your maximum record length then you may define it as a memory chunk (i.e. DC 5000C) and use the regular MACRF=GM. If you do not, you may use GETMAIN to store the first record (after you used MACRF=GL.) You may reuse that storage after you write the first record for the next iteration. Once you get a record that is longer then the original GETMEM, you may issue a FREEMAIN and GETMAIN for the longer record, and so on.
ZA |
|
Back to top |
|
|
rnanavaty Beginner
Joined: 12 Apr 2006 Posts: 29 Topics: 20
|
Posted: Mon Jun 27, 2011 7:32 am Post subject: |
|
|
Thanks ZA !!!
It looks fine.
One query regarding this. How we will come to know that GETMAIN defined the memory enough to contain the record. Will it provide error if defined memory location is not enough or overwrite next memory location.
One more thing...Will it require change in program again and again to change memory defined by GETMAIN. |
|
Back to top |
|
|
asr2 Beginner
Joined: 25 Jun 2011 Posts: 26 Topics: 4 Location: Germany
|
Posted: Wed Jul 27, 2011 11:44 am Post subject: |
|
|
Considering the GETMAIN size. There are two possibilities: either access the file attributes (with the RDJFCB = Read Job File Control Block to obtain the maximum record length) or use a "sledge hammer" approach to allocate the maximum possible record length of 32K. |
|
Back to top |
|
|
|
|