CADS_COLE@GALLUA.BITNET ("Kevin Cole at Gallaudet U. Washington DC") (01/20/88)
Hi. I'm finally messing with C after promising myself for years that I would learn it. Unfortunately, I don't have ready access to the VAX C manual(s). I SHOULD be getting some soon, (if the cuts to the budget here don't zap me). Anyway, til then, the list is my best resource. Sorry 'bout that. So, here's the scoop. In a nutshell, how do I open a new file for output with the same attributes as an old file already opened for input? I'm writing a compression program that takes an input file and changes multiple spaces to tabs and strips off trailing spaces. I'm probably re-inventing the wheel, but it's a good way to learn. The program seems to be working for the most part. However, upon attempting to edit the created file I get the "... not standard format" message from EDT. The (edited) FILE program output tells me that the only differences are: $ FILE/OUTPUT OLD.MAR /TYPE=VARIABLE /RECORD_SIZE=80 $ FILE/OUTPUT NEW.MAR /TYPE=LFSTREAM /RECORD_SIZE=0 What are the attributes I need in the C fopen? Or is there a better way (for a beginner). (I'm not sure if it's relevant but right now, I'm doing the I/O with getc and putc. I'm also assuming that exiting closes everything nicely for me.) I'm no expert on VMS either. So, no fancy stuff without lots of detail. Thanx in advance. -------------------------------------------------------------------------------- Kevin Cole <Flatline> BITNET: KJCOLE@GALLUA.BITNET Center for Assessment and or Demographic Studies (CADS) CADS_COLE@GALLUA.BITNET Gallaudet Research Institute (GRI) UUCP: ...!psuvax!gallua.bitnet!kjcole Gallaudet University CompuServe: 76167,1406 Washington, D.C. 20002 (202) 651-5575 "Hey Rocky! Watch me pull a rabbit out of my hat!"
LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) (01/22/88)
...[H]ow do I open a new file for output with the same attributes as an old file already opened for input? I'm writing a compression program that takes an input file and changes multiple spaces to tabs and strips off trailing spaces. I'm probably re-inventing the wheel, but it's a good way to learn. The program seems to be working for the most part. However, upon attempting to edit the created file I get the "... not standard format" message from EDT. The (edited) FILE program output tells me that the only differences are: $ FILE/OUTPUT OLD.MAR /TYPE=VARIABLE /RECORD_SIZE=80 $ FILE/OUTPUT NEW.MAR /TYPE=LFSTREAM /RECORD_SIZE=0 What are the attributes I need in the C fopen? Or is there a better way (for a beginner). The answer to this comes in three parts: 1. Your NEW.MAR file is perfectly good. EDT is showing its age; it really has no reason to complain. In any case, the complaint is only a warning. So...the easiest approach is to live with it. 2. If this is the only kind of file you want to deal with, the formula for creating a "plain vanilla" VMS text file is: file = fopen(spec,how,"rfm=var","rat=cr"); "rfm=var" asks for variable-length records (/TYPE=VARIABLE); "rat=cr" asks for carriage-return carriage control (i.e., insert a carriage return/line feed when sending the file to something like a terminal). The record size stuff is handled automatically. 3. The GENERAL problem of making the output file have the same characteristics as the input file is fairly complex and requires using direct RMS calls - the information isn't available through the C library. Not recommended for begin- ners. -- Jerry