Applies To:
  • CitectSCADA 3.4, 4.2

When I display a text file using the PageFile(...) command on a page created from the File template, the format is a mess - tabs are erratic and columns of numbers don't line up. How do I fix this? 

The reason things are all out of whack when you view with the PageFile command is because of the default font being used for the display - it is a proportional font instead of a fixed width font (like Courier). This can be changed:
  1. Define a font in your project that is something like Courier (or some other fixed width font), 12, White for the foreground color.
  2. Create a Cicode library in the project, the name doesn't matter as long as it's 8 characters or less, no spaces or special characters. Put the following functions in the library:

MyPageFile(string sFile = "")

   IF PageDisplay("File") THEN
   DspFile(21, DspFontHnd("YourFontName"), 24, 95);
   DspFileSetName(21, sFile);

MyTextFileRun(INT hAn = 21)
   IF StrToInt(PageInfo(7)) = 0 THEN
      DspFile(hAn, DspFontHnd("YourFontName"), 24, 95);

Replace YourFontName with whatever you named your font, but keep it in quote marks.

  1. Open the !file page in your project, choose Edit|Break Lock Mode, then Edit|Select All, then Edit|Cut Link. Double-click on the f(x) at the start of the file display area and replace the TextFileRun command with your MyTextFileRun command, keeping the argument the same.
  2. On the button you use to call the PageFile command (or the keyboard command), replace PageFile("File path and name") with MyPageFile("File path and name"). Save the changes and run.