The format string specifies input sequences and how the method must convert the

The format string specifies input sequences and how

This preview shows page 237 - 240 out of 334 pages.

The format string specifies input sequences and how the method must convert the input. The method maps each character to the input as it reads the input until it encounters a percentage symbol (%). The percentage symbol causes the method to read the value and then store it in an argument that follows the format string. Each argument that occurs after the format string receives the next parsed value from the next argument in the list of arguments that occur after the format string. Arguments In a Method That Performs a Scan Operation An argument in a method that performs a scan operation uses the following format: %[*][ width ] type f Floating-point of the format [- ]dddd.dddd. fprintf(file, "%f", 26.735); 26.735000 e Floating-point of the format [- ]d.ddde+dd or [-]d.ddde-dd. fprintf(file, "%e", 26.735); 2.673500e+001 E Floating-point of the format [- ]d.dddE+dd or [-]d.dddE-dd. fprintf(file, "%E", 26.735); 2.673500E+001 g Floating-point number of f or e, depending on precision. fprintf(file, "%g", 26.735); 26.735 G Floating-point number of F or E, depending on precision. fprintf(file, "%G", 26.735); 26.735 c Character. For example, a, b, 8. fprintf(file, "%c", 'a'); a s String. fprintf(file, "%s", "Test"); Test Table 137. Characters That Determine Character Type Character Description Example Statement and Output
Image of page 237
Siebel eScript Language Reference Version 8.1, Rev. A C Language Library Reference Clib File Input and Output Methods 238 Table 138 describes usage of the * (asterisk) and the width argument. If you specify the width, then the input is an array of characters of the length that you specify. Table 139 describes the values you can use for the type argument . Example The following example creates a file named myfile.txt and stores a float number and a string. It then rewinds the stream and uses fscanf to read the values: function WebApplet_Load() { var f; var str; var pFile = Clib.fopen ("c:\\myfile.txt","w+"); Clib.fprintf (pFile, "%f %s", 3.1416, "PI"); Clib.rewind (pFile); Clib.fscanf (pFile, "%f", f); Clib.fscanf (pFile, "%s", str); Table 138. Usage of the Asterisk and Width Arguments in a Method That Performs a Scan Operation Argument Description * Suppresses assigning this value to any argument. width Sets the maximum number of characters to read. If the method encounters a white-space character or a nonconvertible character, then it stops reading these characters. For more information, see “Use White Space to Improve Readability” on page 57 . Table 139. Usage of the Type Argument in a Method That Performs a Scan Operation Type Value Description d,D,i,I Signed integer. u,U Unsigned integer. o,O Octal integer. x,X Hexadecimal integer. f,e,E,g,G Floating-point number. s String. [abc] String that includes the characters in brackets, where A–Z represents the range A to Z. [^abc] String that includes the following character in brackets: not
Image of page 238
C Language Library Reference Clib File Input and Output Methods Siebel eScript Language Reference Version 8.1, Rev. A 239 Clib.fclose (pFile); Clib.printf ("I have read: %f and %s \n",f,str); } This example produces the following output: I have read: 3.141600 and PI Clib Clear Buffer Method The Clib Clear Buffer method writes to disk the data that exists in the buffer depending on the
Image of page 239
Image of page 240

You've reached the end of your free preview.

Want to read all 334 pages?

  • Summer '16
  • Oracle
  • Type system, Siebel, Siebel eScript

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes