Operating System - OpenVMS
1752794 Members
5796 Online
108789 Solutions
New Discussion юеВ

Re: issues with f$file_format lexical function

 
SAMI AHMAD
Regular Advisor

issues with f$file_format lexical function

I am unable to get the number of records in a file using the following

why is "file_length_hint"  not working ? and why **bleep**/rms/stats is showing  File Length Hint (Data Byte Count): -1 (invalid)?

 

the vms version is Alpha 7.3-2

 

$ REC = f$file("A.A","file_length_hint")

$ show sym rec

  REC = "(-1,-1)"

 

$ **bleep**/RMS/stat a.a

уАА

RMS File Statistics                          24-JUL-2013 15:21:24.39   Page 1

PASDISK5:[MDX.OUTGOING.PROCESSED]A.A;1

уАА

FILE HEADER

        File Spec: PASDISK5:[MDX.OUTGOING.PROCESSED]A.A;1

        File ID: (46161,486,0)

        Owner UIC: [INTEROP,MDX]

        Protection:  System: RWED, Owner: RWED, Group: RE, World:

        Creation Date:   24-JUL-2013 14:54:40.07

        Revision Date:   24-JUL-2013 14:54:40.07, Number: 1

        Expiration Date: none specified

        Backup Date:     none posted

        Contiguity Options:  none

        Performance Options: none

        Reliability Options: none

        Journaling Enabled:  none

уАА

RMS FILE ATTRIBUTES

        File Organization: sequential

        Record Format: variable

        Record Attributes:  carriage-return

        Maximum Record Size: 0

        Longest Record: 7

        Blocks Allocated: 61, Default Extend Size: 0

        End-of-File VBN: 1, Offset: %X'001C'

        File Monitoring: disabled

        File Length Hint (Record Count):    -1 (invalid)

        File Length Hint (Data Byte Count): -1 (invalid)

        Global Buffer Count: 0

уАА

The analysis uncovered NO errors.

уАА

**bleep**/RMS/STAT A.A

11 REPLIES 11
Steven Schweda
Honored Contributor

Re: issues with f$file_format lexical function

 
Steven Schweda
Honored Contributor

Re: issues with f$file_format lexical function

 
John McL
Trusted Contributor

Re: issues with f$file_format lexical function

You can't get recod counts that way.

 

The following command procedure will do it for you, P1 is the target file.

 

$!
$       pipe search/stat 'p1' XYZZY | search sys$input "records searched" | -
                 (read sys$input module_name ; define/job MY_REC &module_name)
$       my_sym = f$trnlnm ("MY_REC", "LNM$JOB")
$       deass/job my_rec
$       recs = f$integer(f$extract(26, 10, my_sym))
$       write sys$output "No of records is ''recs'"
$!
$       exit

 

Modify to suit your purpose...

Hein van den Heuvel
Honored Contributor

Re: issues with f$file_format lexical function

>> You can't get recod counts that way.

 

Yes you can, Steven proved that in his second reply.

 

>> pipe search/stat 'p1' XYZZY

 

1) it is my understanding the an early match if quicker than no-match, so i use "" /WIN=0

2) In any reasonably recent openVMS version SEARCH will define statistics symbols for your convenience.

 

$ define/user sys$output nl:
$ searc /stat /win=0  ""  tmp.tmp
$ show symb sear*
:
  SEARCH$RECORDS_SEARCHED = "13"
$

 Works on all file types, contrary to the file hints.

hth,

Hein

 

 

 

Steven Schweda
Honored Contributor

Re: issues with f$file_format lexical function

 
SAMI AHMAD
Regular Advisor

Re: issues with f$file_format lexical function

i found the problem after reading openVMS notes from web ,  f$file("<file name>","file_length_hint")

works only if

  - file type is sequential

  - record type is VAR or VFC

  - volume is ODS-5

 

to fix the problem  I :

 

- generated the FDL for the file

- modified the FDL to correct the file type and record type.

- converted the file using the modified FDL

 

and then  f$file("<file name> ","file_length_hint") worked and gave me the record count.

 

Steven Schweda
Honored Contributor

Re: issues with f$file_format lexical function

 
John McL
Trusted Contributor

Re: issues with f$file_format lexical function

Hein,

 

Thanks for the tip but your search command seems to have the search string and the filename the wrong way around.

 

Also, I found that I was seeing error messages, so ...

 

$ def/user sys$output nl:
$ def/user sys$error  nl:
$ search/stat/win=0 [-]login.com XYZZY

 

(If sys$error not redefined or messages not disabled, here you'll see "%SEARCH-I-NOMATCHES, no strings matched")


$ sho sym search*
  SEARCH$CHARACTERS_SEARCHED = "2300"
  SEARCH$FILES_SEARCHED = "1"
  SEARCH$LINES_PRINTED = "0"
  SEARCH$RECORDS_MATCHED = "0"
  SEARCH$RECORDS_SEARCHED = "94"

cachaza
Occasional Contributor

Re: issues with f$file_format lexical function

Hi : ...i dont speak english...only spanish (Chile-south America).....

I know a way to calculate de records quantity ..without read the file ,but only for sequential file (fixed format)

1.- dcl : receive de file name by parameter,extract and send file attributes to a cobol program.

2.- Cobol: calculate de records quantity and display it....send this quantity to dcl too.

3.- below you will find dcl + cobol

 

$ Set NoVer

$ Status:= " "

$ Ws    := "Write Sys$output "

$ On Error Then Goto Err_Com

$!----------------------------------------------------------------*

$! El Pgma Cobol Util_ctareg.sco Devuelve La Variable "Numregs",  *

$! La Cual Contiene El Numero De Registros Que Tiene El Archivo   *

$! Nota: solo acepta archivos Secuenciales de Largo Fijo          *

$!----------------------------------------------------------------*

$  Archivo :='P1'

$  Archivo = F$edit(archivo,"upcase,trim,compress")

$  Archivo = F$string(archivo)

$  Ws " Archivo Ingresado : ''Archivo'"

$!-----------------------------------------------------------------------------------------------*

$  parOrg  = f$file_attributes(archivo,"org")

$  if  parOrg.NeS. "SEQ"

$      then

$      Ws "*** Error : Este archivo NO es Secuencial ***"

$      Exit

$  endif

$!

$  parRfm  = f$file_attributes(archivo,"rfm")

$  if  parRfm.NeS. "FIX"

$      then

$      Ws "*** Error : Solo admite registros de Largo Fijo ***"

$      Exit

$  endif

$!-----------------------------------------------------------------------------------------------*

$  Pareof  = F$file_attributes(archivo,"eof")

$  Pareof9 = F$fao("!(09ZL)",f$integer(pareof))

$!---------------------------------------------------*

$  Parffb  = F$file_attributes(archivo,"ffb")

$  Parffb9 = F$fao("!(09ZL)",f$integer(parffb))

$!---------------------------------------------------*

$  Parmrs  = F$file_attributes(archivo,"mrs")

$  Parmrs9 = F$fao("!(09ZL)",f$integer(parmrs))

$!-----------------------------------------------------------------------------------------------*

$!=====================================================

$  Run/nodeb Dka1:[optiafc.cta.exe]util_ctareg.exe

$!=====================================================

$! Ws " Numero De Registros Recibido: ''Numregs'"

$ If  Status.eqs."-1"

$     Then

$      Ws "***===>>> Util_ctareg  Mal-Mal-Mal <<<===***"

$ Else

$      Ws "***===>>> Util_ctareg  Ok-Ok-Ok    <<<===***"

$ Endif

$!

$ Exit

$!

$!--------

$ Err_Com:

$!--------

$    Set Nover

$    Ws "***===>>> Util_ctareg con ERROR a nivel de .Com <<<===***"

$    Exit

$!-----------------------------------------------------------------------------------------------*

 

 IDENTIFICATION DIVISION.

*************************

 PROGRAM-ID.       UTIL_CTAREG.

*AUTHOR              CACHAZA.

 ENVIRONMENT DIVISION.

**********************

 CONFIGURATION  SECTION.

*=======================

 SPECIAL-NAMES.

*--------------

       DECIMAL-POINT IS COMMA.

 DATA DIVISION.

***************

 WORKING-STORAGE SECTION.

*========================

*

 01 VARIABLES-INICIO.

    02  PAR-EOF9               PIC  9(09).

    02  PAR-FFB9               PIC  9(09).

    02  PAR-MRS9               PIC  9(09).

    02  WS-PIC9                PIC  9(09).

    02  WX-LARGO               PIC  9(04) COMP.

    02  NUM-REG                PIC  9(12) COMP.

    02  NUM-REGZ               PIC  ZZZ.ZZZ.ZZZ.ZZ9.

*

********************

 PROCEDURE DIVISION.

********************

 AAXX.

           INITIALIZE VARIABLES-INICIO

*

           CALL "LIB$GET_SYMBOL" USING BY DESCRIPTOR "PAREOF9", PAR-EOF9,

                                    BY REFERENCE WX-LARGO.

           IF  WX-LARGO = 0

               DISPLAY "PARAMETRO PAR-EOF9 NO DEFINIDO. CANCELA . . ."

               STOP RUN.

*

           move  0  to  WX-LARGO

           CALL "LIB$GET_SYMBOL" USING BY DESCRIPTOR "PARFFB9",PAR-FFB9

                                    BY REFERENCE WX-LARGO.

           IF  WX-LARGO = 0

               DISPLAY "PARAMETRO PAR-FFB9 NO DEFINIDO. CANCELA . . ."

               STOP RUN.

*

           move  0  to  WX-LARGO

           CALL "LIB$GET_SYMBOL" USING BY DESCRIPTOR "PARMRS9",PAR-MRS9

                                    BY REFERENCE WX-LARGO.

           IF  WX-LARGO = 0

               DISPLAY "PARAMETRO PAR-MRS9 NO DEFINIDO. CANCELA . . ."

               STOP RUN.

*

           IF  FUNCTION REM (PAR-MRS9 , 2) = 1

               ADD 1 TO PAR-MRS9

           END-IF.

*

           COMPUTE NUM-REG ROUNDED = (((( PAR-EOF9 - 1 ) * 512 ) + PAR-FFB9 ) / PAR-MRS9 )

           MOVE NUM-REG  TO  NUM-REGZ

*

           DISPLAY "*--------------------------------------------------*".

           DISPLAY "*** ==== > ARCHIVO TIENE:"NUM-REGZ CONVERSION" REGS"

           DISPLAY "*--------------------------------------------------*".

           CALL "LIB$SET_SYMBOL" USING BY DESCRIPTOR "NUMREGS",NUM-REG

           STOP RUN.

*****************************************************************************

*****************************************************************************

*****************************************************************************