fprintfUL()

Writes to a file similar to fprintf() except changes to the current Windows user language before converting.

Synopsis

int fprintfUL(file file, string format, [,<type1> var1 [,<type2> var2 ...]] );

Parameters

Parameter Description
file file to be written, use the constants stdin, stdout, stderr (see Reference tables)
format Output format
var1, var2, ... Arguments

Return value

In the event of errors, the function returns -1 or EOF otherwise, the number of written characters.

Error

If incorrect data types are used or if a file is not open.

Description

Writes to a file similar to fprintf() but uses the current Windows user language before converting (Start->Settings-> Countries) to be able to use, for example, semicolons as in other Windows programs such as Excel.

Example

The following example writes three float values into a text file and reads them again from the file.

main()
{
  file f;
  int i;
  dyn_float value;
  value[1]=12.123;
  value[2]=8.0;
  value[3]=3.1;
  f=fopen("C:/TEMP/tfile.TXT","w+"); //creates a file for writing and reading
  for (i=1;i<=3;i++) fprintfUL(f,"%5.3f\n",value[i]);
  //writes the float values into the text file
  rewind(f); //back to the beginning of the file
  for (i=0;i<=3;i++)
  {
    fscanfUL(f,"%f",value[i]); //reads the float values from the file
    DebugN(value[i]);
  }

  fclose(f);//closes the file
}

Example

The following example writes the current day, month and year into a text file and reads the data from the file again.

main()
{
  file f;
  int err;
  time now = getCurrentTime(); //gets the current time
  int tDay,tMonth,tYear;
  f=fopen("C:/TEMP/TEST.TXT","w"); //creates a new file for writing
  err=ferror(f); //searches for file errors
  fprintfUL(f,"Today is : %d %d %d", day(now), month(now),
  year(now)); //writes "Today is"+ current date into a text file TEST.TXT
  fclose(f); //closes the file
  f=fopen("C:/TEMP/TEST.TXT","r"); //opens the file for reading
  fscanfUL(f,"Today is : %d %d %d", tDay,tMonth,tYear);
  //reads the current date from the text file
  DebugN(tDay,tMonth,tYear);
  err=ferror(f);
  fclose(f);
}

Assignment

File functions

Availability

CTRL