PDA

View Full Version : Text file


stevequest
11-27-2006, 02:35 AM
I was writing a text file to refer back to in order to trigger a page jump back to the last page previously viewed. The code I worte was:

SaveGame = Shell.GetFolder(SHF_PROGRAMFILES);
Folder.Create(SaveGame.."\\SaveFolder");
TextFile.WriteFromString("C:\Save1.txt", "Saved", false);
Application.Exit(0);

I saw that the text file seemed to find it's way into the Save Folder that was created even though there was nothing but c:\ specified. So since this seemed to be unusual I changed the code to read:

SaveGame = Shell.GetFolder(SHF_PROGRAMFILES);
Folder.Create(SaveGame.."\\SaveFolder");
SaveGame = TextFile.WriteFromString("C:\\Save1.txt", "Saved", false);
Application.Exit(0);

As you can see I added one extra backslash behind C: as well as put "SaveGame =" in front of the line. It found it's way there again. Now I have learned the hard way that with so many systems out there that there is usually only one "right" way to code something to prevent problems. I want this to work properly on 98/2000/XP. So which way should I go in order to make sure that the file always finds it way to the right place on ALL systems without any errors?

stevequest
12-07-2006, 12:52 AM
I've apparently stumped some folks with this one but I would appreciate any stab in the dark that someone might have.