• File Access

    From PistolGrip@VERT/WASTELND to Jim King on Mon Apr 2 11:09:00 2001
    Here's a simple example for a text based file.

    ##### START ############################################################## !include file_io.inc

    # Variable Definitions
    int file_handle

    str string
    str string2

    # Sets a variable to a value
    set string2 "Hello, World."

    fopen file_handle O_RDWR "%n..\baja\somedir\somefile.txt"
    if_false
    print "\r\nnError opening File!\r\n"
    return
    end_if

    fread_line file_handle string # reads line from file into variable
    fset_pos file_handle 0 SEEK_END # sets file position to end of file
    fprintf file_handle "%s" string # writes variable to file

    fclose file_handle
    ##### END ##############################################################

    PG

    ---
    þ Synchronet þ WasteLand BBS þ telnet://wasteland.darktech.org