View Full Version : Date problem
webcrtor
03-12-2010, 02:59 AM
Can anyone explain me what's wrong with this code since it doesn't seem to work..(It doesn't create the txt files)
datum = System.GetDate(DATE_FMT_DAYOFWEEK);
naam = TextFile.ReadToString("AutoPlay\\naam.txt")
if (datum == "1") then
TextFile.WriteFromString("AutoPlay\\1.txt", naam, true);
elseif (datum == "2") then
TextFile.WriteFromString("AutoPlay\\2.txt", naam, true);
elseif (datum == "3") then
TextFile.WriteFromString("AutoPlay\\3.txt", naam, true);
elseif (datum == "4") then
TextFile.WriteFromString("AutoPlay\\4.txt", naam, true);
elseif (datum == "5") then
TextFile.WriteFromString("AutoPlay\\5.txt", naam, true);
elseif (datum == "6") then
TextFile.WriteFromString("AutoPlay\\6.txt", naam, true);
else
TextFile.WriteFromString("AutoPlay\\7.txt", naam, true);
end
and btw can't I replace this by something like:
TextFile.WriteFromString("AutoPlay\\"datum".txt", naam, true);
Tried this too but doesn't work either..
Thanks in advance!
TopicTJ
03-12-2010, 06:54 AM
Can anyone explain me what's wrong with this code since it doesn't seem to work..(It doesn't create the txt files)
datum = System.GetDate(DATE_FMT_DAYOFWEEK);
naam = TextFile.ReadToString("AutoPlay\\naam.txt")
if (datum == "1") then
TextFile.WriteFromString("AutoPlay\\1.txt", naam, true);
elseif (datum == "2") then
TextFile.WriteFromString("AutoPlay\\2.txt", naam, true);
elseif (datum == "3") then
TextFile.WriteFromString("AutoPlay\\3.txt", naam, true);
elseif (datum == "4") then
TextFile.WriteFromString("AutoPlay\\4.txt", naam, true);
elseif (datum == "5") then
TextFile.WriteFromString("AutoPlay\\5.txt", naam, true);
elseif (datum == "6") then
TextFile.WriteFromString("AutoPlay\\6.txt", naam, true);
else
TextFile.WriteFromString("AutoPlay\\7.txt", naam, true);
end
Basically, it's the path to the file name that's causing the problem.
Assuming naam.txt is located in the folder from which you're running your program, use the Global Variable _SourceFolder.
naam = TextFile.ReadToString(_SourceFolder.."\\naam.txt");
and btw can't I replace this by something like:
TextFile.WriteFromString("AutoPlay\\"datum".txt", naam, true);
Tried this too but doesn't work either..
As your variable datum contains the number you want to append to the .txt file title then ...
TextFile.WriteFromString(_SourceFolder.."\\"..datum..".txt", naam, true);
should do it!
datum = System.GetDate(DATE_FMT_DAYOFWEEK);
naam = TextFile.ReadToString(_SourceFolder.."\\naam.txt");
TextFile.WriteFromString(_SourceFolder.."\\"..datum..".txt", naam, true);
jassing
03-12-2010, 07:00 AM
You're code works. are you hitting f5 to run it or are you building to an exe?
and yes, you can shorten it to:
datum = System.GetDate(DATE_FMT_DAYOFWEEK);
naam = TextFile.ReadToString("AutoPlay\\naam.txt")
TextFile.WriteFromString("AutoPlay\\"..datum..".txt", naam, true);
TopicTJ
03-12-2010, 07:18 AM
I thought the gap was closing between me and those who really know what they're talking about but here's further evidence I should learn to keep my mouth shut!
Sorry to have unnecessarily complicated it. :eek:
webcrtor
03-12-2010, 09:36 AM
Still doesn't work for some reason.. maybe because datum is seen as a real date and not as some kind of normal word/number and it can't save it that way??
webcrtor
03-12-2010, 09:55 AM
I know what the problem was.. for some reason when you export and rename the Autoplay folder(I named it Data), normally It would rename all autoplay references to data, and it does it for all my txt files, except for this one..(the one with a variable in filename) and because the autoplay folder didn't exist he didn't create the txt.. simple as that
jassing
03-12-2010, 10:11 AM
Still doesn't work for some reason.. maybe because datum is seen as a real date and not as some kind of normal word/number and it can't save it that way??
post your APZ
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.