Announcement

Collapse
No announcement yet.

Output to file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Output to file

    With the following code:


    var fFile = new File("myfile.txt");
    fFile.open("at+");
    fFile.writeln(getMonth() + getDay());
    fFile.close();

    How is it possible that I am getting one digit numbers written to my file?

    Thanks
    fan27

  • #2
    Hi,

    Have you tried to do a debugPrintln() to see what the values are when you get them?

    getDay() returns 1=Monday, 2=Tuesday, etc if I remember correctly. Is this what you expected?

    Garth
    Garth

    Comment


    • #3
      Hello Garth,

      I am getting the same output with:

      debugPrintln(getMonth() + getDay())

      I dont see how this could possibly Print a 1 digit number. What am I missing?

      fan27

      Comment


      • #4
        fan27
        FWIW if I run debugPrintln(getMonth() + getDay()) I get a return of 17 which I think is correct (ie 5+12)
        Alex

        Comment


        • #5
          I think the thing I was missing was my brain. I was wanting to concatinate getDay() onto geMonth(). I should have used the && operator instead of the + operator.

          thanks
          fan27

          Originally posted by Alexis C. Montenegro
          fan27
          FWIW if I run debugPrintln(getMonth() + getDay()) I get a return of 17 which I think is correct (ie 5+12)
          Alex

          Comment


          • #6
            fan27
            I don't think && will give you the result you want. Try
            debugPrintln(getMonth() +""+ getDay());
            Alex

            Comment


            • #7
              Thanks,

              fan27

              Originally posted by Alexis C. Montenegro
              fan27
              I don't think && will give you the result you want. Try
              debugPrintln(getMonth() +""+ getDay());
              Alex

              Comment

              Working...
              X