Onchange "Vessel_Batch", "@New_Email()" Onchange "Vessel_Cycle_NO","@WriteToFile()" Function WriteToFile() $Date$ = T$ (4 To 5) + "_" + T$ (1 TO 2) + "_" + T$ (7 TO 10) + "_" + T$(12 To 13) + "_" + T$(15 To 16) + "_" + T$(18 To 19) // puts the time into this format MMDDYYYY HHMMSS Open "file:/usr/" + "Historical_Log_" + $Date$ + "_Report.csv" FOR BINARY APPEND AS 1 //This creates a new file as well as names it based off the vessel batch number T=TIME$ A$ = T$(4 To 6)+T$(1 To 3)+T$(7 To 19) If Vessel_Cycle_No@ = 1 Then Put 1, "Vessel Batch No;Vessel Cycle No;Max Vac(mbar);Max Pressure(bar);Date" + CHR$(13) + CHR$(10) // writes the names for each column Put 1, STR$ Vessel_Batch@ + ";" + STR$ Vessel_Cycle_No@ + ";" + STR$ Max_Vac@ + ";" + STR$ Max_Pressure@ + ";" + A$ + CHR$(13) + CHR$(10) //calls the values, semicolon delimited Else If Vessel_Cycle_No@ = 2 Then Put 1, STR$ Vessel_Batch@ + ";" + STR$ Vessel_Cycle_No@ + ";" + STR$ Max_Vac@ + ";" + STR$ Max_Pressure@ + ";" + A$ + CHR$(13) + CHR$(10) Else If Vessel_Cycle_No@ = 3 Then Put 1, STR$ Vessel_Batch@ + ";" + STR$ Vessel_Cycle_No@ + ";" + STR$ Max_Vac@ + ";" + STR$ Max_Pressure@ + ";" + A$ +CHR$(13) + CHR$(10) Else If Vessel_Cycle_No@ = 4 Then Put 1, STR$ Vessel_Batch@ + ";" + STR$ Vessel_Cycle_No@ + ";" + STR$ Max_Vac@ + ";" + STR$ Max_Pressure@ + ";" + A$ + CHR$(13) + CHR$(10) Else Endif Endif Endif Endif Close 1 Print "file written" EndFn Function New_Email() oldval% = Vessel_Batch@ - 1 // so that when the value increments it will grab the previously created data $EmailTo$ = "Johnsmith@email.com" $EmailCC$ = "mark@email.com" $EmailSubject$ = STR$ oldval% + " Report" $EmailBody$ = "" $EmailBody$ = $EmailBody$ + "Third Line " + CHR$(13) + CHR$(10) // the CHR$(13) + CHR$(10) is the same as newline $EmailBody$ = $EmailBody$ + "Second Line" + CHR$(13) + CHR$(10) // Second line of email $EmailBody$ = $EmailBody$ + "Third Line" + CHR$(13) + CHR$(10) // Third Line of email... ect $EmailBody$ = $EmailBody$ + "Time: " + TIME$ + CHR$(13) + CHR$(10) // Gives the full date when this was sent // Want to include data such as graphs as an attachment? see: https://ewonsupport.biz/ebd/ $EmailAttachment$ = "&[$dtUF$uf/usr/" + "Historical_Log_" + $Date$ + "_Report.csv$ftT]" $EmailContents$ = $EmailBody$ + $EmailAttachment$ SENDMAIL $EmailTo$, $EmailCC$, $EmailSubject$, $EmailContents$ Print "mail sent" Endfn