[Solved] Windows StringGrid.SaveToFile - no file content. lazarus / 31-LCL ---------------------------------------------------------------------- iru · 2020-08-19 05:25 Environment/s: Laz 2.0.10, Linux Mint 19.3, Win 10 latest. Gentlefolk, Created a program using a StringGrid on Linux, tested, all works OK. Published the program and loaded it into Laz on Win10. Compiles clean, the program behaves exactly the same as on Linux except: On Linux a StringGridEvent.SaveToFile(..file name..) creates the file, creates 3+K of content. On Win10 the same StringGridEvent.SaveToFile(..file name..) creates a file of ZERO length and content. Tried to debug through Grids file lines 9760.... Both Linux and Windows seem to do the same thing but no file content on Win10. Any ideas, suggestions?? Ian ---------------------------------------------------------------------- iru · 2020-08-19 07:51 Gentlefolk, I have just created a simple form on Win10, added a  String grid and a couple of buttons to add to the grid and then save the content to a file. It worked!!!! Back to the original program, it failed, file created but no content. Stepped my way through the Grids code in both programs, appeared to do similar things, I could see nothing strange/different. What is the difference? In the test program the save file name is 'testgrid.sav'. In the failed program the save file name is '3_TJ_34_2.SAV'. (represents an athletic event, event number, heat....) Changed the save file name to 'test-grid.pas' and it works! The content is saved! Hmmm, something somewhere does not like the file name??? I search on.... Ian ---------------------------------------------------------------------- wp · 2020-08-19 07:52 The kind and amount of data saved for a StringGrid is determined by the SaveOptions property of the grid. In the grid's constructor the property is set to a well-defined initial value. And when I save an empty StringGrid to xml file it is stored with about 1 kB, in both Win10 and Manjaro Linux, tested with Laz trunk and Laz 2.0.10. Please check the SaveOptions with the debugger. Do you have your own variable for it in your program? A situation which could explain your observation: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  save_options: TSaveOptions;   // uninitialized variable!begin  StringGrid.SaveOptions := save_options;  StringGrid.SaveToFile('test.xml');end; ---------------------------------------------------------------------- iru · 2020-08-19 10:44 Thank you for the response but the problem appears to to do with the 'directory' symbol '/' and '\' used in Linux and Windows. I thought I had it covered but somewhere in my code the directory- path-filename includes a '/'. Strange that the file is created.... I will do some more checking and fix the code/constants that appear to cause the problem. Ian ---------------------------------------------------------------------- wp · 2020-08-19 12:17 Apply the function SwitchPathDelims from unit LazFileUtils to a filename before further processing; it will replace all (back)-slashes to those supported by the system: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TPathDelimSwitch = (    pdsNone,    // no change    pdsSystem,  // switch to current PathDelim    pdsUnix,    // switch to slash /    pdsWindows  // switch to backslash \    ); function SwitchPathDelims(const Filename: string; Switch: TPathDelimSwitch): string;function SwitchPathDelims(const Filename: string; Switch: boolean): string;  // Switch=true --> use pdsSystem ---------------------------------------------------------------------- iru · 2020-08-20 03:20 Thank you for the information on SwitchPathDelims. It saved me some code and time. Problem solved.... ian.