| Front Page | News Headlines | Technical Headlines | Planning Features | Advanced Search |

January 2005

Get the most out of your Robelle Tools

Qedit Deals with Trailing Blanks

Removing Trailing Blanks

A Qedit for MPE user called with an interesting problem. He had a large data file that was used as input to a program. The input records had many trailing blanks, so he thought he could save a lot of disc space by converting the file to variable-length records instead of fixed-length records. His first attempt at converting the file was not successful. He had used FCOPY to convert the file from fixed- to variable-length, but the file didn’t take any less space. It seems that FCOPY did not strip the trailing blanks.

:listf fixfile,2
ACCOUNT=  DEV         GROUP=  MIKE
FILENAME  CODE  ------------LOGICAL RECORD-----------  ----SPACE----
                   SIZE  TYP        EOF      LIMIT R/B  SECTORS #X MX
FIXFILE           200B  FA       13982      13982  20    10928 33 32
:build varfile;rec=-200,1,v,ascii;disc=123456
:fcopy from=fixfile;to=varfile
:listf varfile,2
              SIZE  TYP    EOF   LIMIT R/B  SECTORS #X MX
VARFILE      200B  VA    13982  123456 1    12288  9  *
Because the customer had Qedit, we used Qedit to convert the file from fixed- to variable-length:
:run qedit.pub.robelle
/t fixfile; set keep var on; keep varfile; exit
13982 lines in file
13982 lines saved
:listf varfile,2
               SIZE  TYP  EOF  LIMIT  R/B  SECTORS #X MX
VARFILE       1276B  VA  13982  514   1    2576  8  8

Qedit stripped the trailing blanks from each record. The file was now significantly smaller than the original file. But the user’s application program choked on the file, because the file label no longer described the file as a 200-byte file. Qedit assigned its own record length and blocking factor, which the user has no control over.

The third attempt was successful, combining both Qedit and FCOPY:

:run qedit.pub.robelle
/t fixfile
13982 lines in file
/set keep var on
/keep foo
13982 lines saved
/exit
END OF PROGRAM
:build varfile;rec=-200,1,v,ascii;disc=123456
:fcopy from=foo;to=varfile
HP31900A.05.02 FILE COPIER (C) HEWLETT-PACKARD CO. 1990
*200*WARNING: FROMFILE RECSIZE IS 1276 BYTES, TOFILE RECSIZE IS 200 BYTES.
CONTINUE OPERATION (Y OR N) ?y
EOF FOUND IN FROMFILE AFTER RECORD 13981
13982 RECORDS PROCESSED *** 0 ERRORS
END OF SUBSYSTEM
:listf varfile,2
             SIZE  TYP      EOF    LIMIT R/B  SECTORS #X MX
VARFILE     200B  VA     13982   123456   1     4096  5  *
>

:listf varfile,2
SIZE TYP EOF LIMIT R/B SECTORS #X MX
VARFILE 200B VA 13982 123456 1 4096 5 *

Ta-dah. The variable file was now significantly smaller than the original fixed file, while still retaining the original record length and blocking factor.

Preserving Trailing Spaces

In the past, Qedit always padded lines with spaces in fixed-length files (Set Keep Var Off) and removed trailing spaces in variable-length files (Set Keep Var On). However, users-specified trailing spaces are sometimes significant, and are not supposed to vary during the edit session. Since version 5.5, Qedit has offered the TrailingSpaces feature. The option is disabled by default on MPE and enabled (by default) on HP-UX.

Set Work Trailingspaces ON requests that Qedit preserves trailing spaces and makes them significant characters. The option also allows creation of odd-length lines. Once enabled, all workfiles created or opened from that point will have trailing spaces preserved. To check the current status, do:

/Verify Work
Set WOrk Jumbo ON Block 8 Labels OFF Temp ON Size 3200
Set WOrk TRailingspaces ON

/Verify Keep
Set Keep Ascii OFF Cctl OFF COde 0 Lab 0 Num OFF Var ON
Set Keep COBfree ON NAme /home/user1/afile.txt
Set Keep LF ON Saved modification timestamp 2003.
Trailing spaces preserved

The last line shows that trailing spaces are preserved in this workfile. If the option is disabled, that line reads “Trailing spaces trimmed.”

Disabling the global setting with Set Work Trailing Off does not disable the option in the workfile. You have to clear the workfile after disabling it. The Trailingspaces setting is stored in the workfile so it’s recognized when the file is opened in the future. These workfiles may contain data specific to Trailingspaces. This may cause unexpected behavior if opened with old versions of Qedit. Because trailing spaces are now treated as significant characters, Keep files created from these workfiles may be different from Keep files created with an older version.

 


Copyright The 3000 NewsWire. All rights reserved.