Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>write_params() writes the last 24 bytes of (.frm) file rlback.prg</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Write_params() Writes the last 24 bytes of (.frm) file    Rlback.prg


Syntax:        Write_params()

Description:   Writes the last 24 bytes of the report file plus updates the
               first un-used offset.

Returns:       True (.T.) if the write operation was successful.

Calls:         Num_2_word()

Notes:         . Called by FRM_SAVE().
               . File error number placed in file_error.


--------------------------------- Source Code ------------------------------

   FUNCTION WRITE_PARAMS

   PRIVATE status, write_item, write_len, write_count, plus_byte

   status      = .F.
   write_item  = ""
   write_len   = 0
   write_count = 0
   plus_byte   = 0

   ** Calculate plus byte **
   IF frm_plainpage = "Y"
      plus_byte = plus_byte + 4
   ENDIF
   IF frm_peap = "Y"
      plus_byte = plus_byte + 2
   ENDIF
   IF frm_pebp = "N"
      plus_byte = plus_byte + 1
   ENDIF

   ** Prepare miscellaneous data area string for write ops **
   write_item = NUM_2_WORD(page_hdr_num) +;
                   NUM_2_WORD(grp_expr_num) +;
                   NUM_2_WORD(sub_expr_num) +;
                   NUM_2_WORD(grp_hdr_num) +;
                   NUM_2_WORD(sub_hdr_num) +;
                   NUM_2_WORD(frm_pagewidth) +;
                   NUM_2_WORD(frm_linespage) +;
                   NUM_2_WORD(frm_leftmarg) +;
                   NUM_2_WORD(frm_rightmarg) +;
                   NUM_2_WORD(frm_colcount) +;
                   frm_dblspaced +;
                   frm_summary +;
                   frm_pe +;
                   CHR(plus_byte)
   write_len = LEN(write_item)

   ** Seek to first parameters area **
   FSEEK(handle, end_offset)

   ** SEEK ok? **
   file_error = FERROR()
   IF file_error = 0
      write_count = FWRITE(handle, write_item, write_len)

      ** WRITE error? **
      IF write_count = 0
         file_error = -2
      ELSE
         file_error = FERROR()
      ENDIF

      IF file_error = 0
         FSEEK(handle, next_free_offset)

         ** SEEK ok? **
         file_error = FERROR()
         IF file_error = 0

            ** Update the next free expression offset **
            write_count = FWRITE(handle, NUM_2_WORD(last_expr), 2)

            ** WRITE error? **
            IF write_count = 0
               file_error = -2
            ELSE
               file_error = FERROR()
            ENDIF

            status = (file_error = 0)

         ENDIF
      ENDIF
   ENDIF


   RETURN (status)
.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson