Page 135 - DCAP408_WEB_PROGRAMMING
P. 135

Unit 8: File I/O




          Self Assessment                                                                       Notes

          Fill in the blanks:
          1.   fopen opens a file and associates a ………………… with it.
          2.   Path is a string specifying the name of the file, while ………………….. is a string indicating
               how the file is to be opened.
          3.   fscanf is the analogue of scanf for use with ……………………. streams.
          4.   ………………………… option is provided as a simple method for loading any file into the
               buffer.
          5.   Load sequential hex string option allows you to load a sequential string of hex characters
               into the……………………..


          8.2 Creating File Selection Dialog Box

          In  this section,  we’ll write code so that your menu items actually do  something other than
          displaying message boxes. In other words, the Edit > Cut menu will really cut text, and the Edit
          > Paste menu will really paste text.
          So open up  the project you completed for the previous section. Comment out or delete any
          message box code.
          We’ll start with the File > Open menu.

          The Open File Dialogue Box

          In most programmes, if you click the File menu, and select the Open item, a dialogue box is
          displayed. From the dialogue box, you can click on a file to select it, then click the Open button.
          The file you clicked on is then opened up. We’ll see how to do that from our menu.

               !
             Caution  Except, the file won’t open yet - only the dialogue box will display, and then name
             of the chosen file.
          First, place two textboxes on your form. In the properties box, locate the MultiLine property.
          Type some default text for the Text Property of textbox1. Change the Font size to 14 points.
          Your form should now look something like this one:
























                                           LOVELY PROFESSIONAL UNIVERSITY                                   129
   130   131   132   133   134   135   136   137   138   139   140