fopen/open contexts - Hewlett Packard

This is a discussion on fopen/open contexts - Hewlett Packard ; Hello All, I am working with a C program that needs to write to/read from permanent and temporary files that I create. However I cannot figure out how to choose my context using fopen or open. Is there some mechanism ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: fopen/open contexts

  1. fopen/open contexts

    Hello All,


    I am working with a C program that needs to write to/read from permanent
    and temporary files that I create. However I cannot figure out how to
    choose my context using fopen or open. Is there some mechanism to do
    this or some other call(s) to use? I have tried HPFOPEN, but that call
    is a mess and returns success but says there is nothing in the file.


    Thanks,
    Dan

    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


  2. Re: fopen/open contexts

    I was using fopen(lowercase). Can I bother you to show me an example
    usage of this call to open a permanent file, I would really appreciate it.

    Dan


    Jack Connor wrote:
    > I'm not sure what you're looking for, Dan, but all you should have to do
    > for FOPEN is choose the FOPTIONS/AOPTIONS as doc'd in the intrinsics
    > manual.
    >
    > jack
    >
    > -----Original Message-----
    > From: HP-3000 Systems Discussion [mailto:HP3000-L@RAVEN.UTC.EDU] On
    > Behalf Of Daniel Griffin
    > Sent: Tuesday, October 28, 2008 1:03 PM
    > To: HP3000-L@RAVEN.UTC.EDU
    > Subject: [HP3000-L] fopen/open contexts
    >
    > Hello All,
    >
    >
    > I am working with a C program that needs to write to/read from permanent
    > and temporary files that I create. However I cannot figure out how to
    > choose my context using fopen or open. Is there some mechanism to do
    > this or some other call(s) to use? I have tried HPFOPEN, but that call
    > is a mess and returns success but says there is nothing in the file.
    >
    >
    > Thanks,
    > Dan
    >
    > * To join/leave the list, search archives, change list settings, *
    > * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
    >
    > * To join/leave the list, search archives, change list settings, *
    > * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
    >
    >


    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


  3. Re: fopen/open contexts

    --- On Tue, 10/28/08, Daniel Griffin wrote:

    I was using fopen(lowercase). Can I bother you to show me an example
    usage of this call to open a permanent file, I would really appreciate it.

    **************************************
    Dan,

    Allegro's site may help you...

    Look for FILEOPEN

    http://www.allegro.com/software/hp3000/allegro.html


    Here is a brief description.
    http://www.allegro.com/software/hp30...ff/FILERPT.txt

    -Craig



    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


  4. Re: fopen/open contexts

    From: "Daniel Griffin"
    >I was using fopen(lowercase). Can I bother you to show me an example
    > usage of this call to open a permanent file, I would really appreciate it.
    >
    > Dan


    Its tru you could use FOPEN or HPFOPEN with the correct options to access
    perm or temp
    files. But you would also need to use the other, matching, access intrinsics
    FREAD/FWRITE,
    and FCLOSE.

    As I see your question, its about using the C library fopen, with fgets,
    fprintf, fclose, etc.

    The C library reference manual should be a click away in that case.
    http://docs.hp.com/cgi-bin/doc3k/B3002690004.12349/1

    Also check other availble docs: http://docs.hp.com/en/mpeixall.html

    But to the question, I just coded this to test. Its crude, but works for
    perm or temp, read or write.
    The trick is the extra options to the mode parm of the fopen.

    You should be able to take it from here.
    Run the program with these options:
    rogram << write perm >>
    rogram T << write temp >>
    rogram R << read perm >>
    rogram RT << read temp >>

    #pragma list off
    #include
    int main ( int ac, char *av[] )
    {
    int n;
    char file [40], mode [40];
    FILE *f;

    strcpy ( file, "FT1" );
    strcpy ( mode, "w " );
    n = 1;
    if ( ac > 1 && av[1][0] == 'R' )
    {
    strcpy ( mode, "r " );
    n = 0;
    }
    if ( ac > 1 && ( av[1][0] != 'R' || av[1][1] > ' ' ))
    strcat ( mode, "Te" );
    f = fopen ( file, mode );
    if ( !f )
    perror ( "fopen" );
    else
    {
    if ( n )
    fprintf ( f, "Output from test" );
    else
    {
    fgets ( file, sizeof(file), f );
    printf ( file );
    }
    fclose (f);
    }
    return 0;
    }


    Keven Miller

    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


+ Reply to Thread