Author Topic: Logging question.  (Read 1157 times)

jamesj

  • Newbie
  • *
  • Posts: 2
    • View Profile
Logging question.
« on: July 30, 2019, 10:44:29 AM »
Let me start by stating that this is my first exposure to VS and AdvancedHMI. Thanks to the brilliant design of the AdvancedHMI product, I have been able to create a simple working application that logs a string upon a passing weight condition. Thank you for the great product design!!

Using BasicDataLogger1, I'm creating a text file that contains only one line "Pass,123456" when I get a pass signal. Currently, if no text file exists, it creates a new file and logs a new line of text. If the file exists already, it just keeps adding new lines. Is there an easy way to have the pass signal do the same if no file exists and if it does exist just replace the current text file with the new?

I can only have one line of text in the file. Our production reporting software will see the new file created, read the contents and then delete the text file. However, anything unexpected in the file will confuse the software and cause an error.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Logging question.
« Reply #1 on: July 30, 2019, 01:18:34 PM »
In the BasicDataLogger.vb file, if you go to about line 372 and look for this code:

                    Using sw As New System.IO.StreamWriter(FileName, True)

You can remove the True and it will never create more than 1 line of text

jamesj

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Logging question.
« Reply #2 on: July 30, 2019, 02:06:45 PM »
Thanks Archie for the great product and prompt support! Worked perfectly. I'm looking forward to learning more about the package and adapting it to work with future projects.