Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 7 of 7

Thread: Date problem

  1. #1
    Join Date
    Oct 2006
    Location
    Belgium
    Posts
    22

    Date problem

    Can anyone explain me what's wrong with this code since it doesn't seem to work..(It doesn't create the txt files)

    Code:
    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:
    Code:
    TextFile.WriteFromString("AutoPlay\\"datum".txt", naam, true);
    Tried this too but doesn't work either..

    Thanks in advance!

  2. #2
    Join Date
    Oct 2008
    Location
    UK - Midlands
    Posts
    63
    Quote Originally Posted by webcrtor View Post
    Can anyone explain me what's wrong with this code since it doesn't seem to work..(It doesn't create the txt files)

    Code:
    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.

    Code:
    naam = TextFile.ReadToString(_SourceFolder.."\\naam.txt");
    Quote Originally Posted by webcrtor View Post
    and btw can't I replace this by something like:
    Code:
    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 ...

    Code:
    TextFile.WriteFromString(_SourceFolder.."\\"..datum..".txt", naam, true);
    should do it!

    Code:
    datum = System.GetDate(DATE_FMT_DAYOFWEEK);
    naam = TextFile.ReadToString(_SourceFolder.."\\naam.txt");
    TextFile.WriteFromString(_SourceFolder.."\\"..datum..".txt", naam, true);
    TTJ

  3. #3
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    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:
    Code:
    datum = System.GetDate(DATE_FMT_DAYOFWEEK);
    naam = TextFile.ReadToString("AutoPlay\\naam.txt")
    TextFile.WriteFromString("AutoPlay\\"..datum..".txt", naam, true);


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  4. #4
    Join Date
    Oct 2008
    Location
    UK - Midlands
    Posts
    63
    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.
    TTJ

  5. #5
    Join Date
    Oct 2006
    Location
    Belgium
    Posts
    22
    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??
    Last edited by webcrtor; 03-12-2010 at 08:48 AM.

  6. #6
    Join Date
    Oct 2006
    Location
    Belgium
    Posts
    22
    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
    Last edited by webcrtor; 03-12-2010 at 09:09 AM.

  7. #7
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Quote Originally Posted by webcrtor View Post
    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


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts