Custom BASIC report


trying to create a custom report as current log does not display the information that is required, i have been trying to follow the example on this link HOW TO: Create a custom historical log file in BASIC

some questions I would appreciate some support with

in the example it is logging every 1 second, in my application I am logging DI with the flexy IO card so i only want to log when the state changes so I have set the tag up to log deadband 1, how do i alter the script on the example to do this?

in terms of sending the file after the setup has been done, im assuming I use EBD and $dtHL$fn"your file name" if i call my file the same as whats shown in example?

If you want this to be done when an individual value changes, you could do an OnChange function and write it so that it will only write to the file when you see that individual tag change values.

Here’s another ticket that goes over a custom historical logging method that might be useful for you.

But if you want to continue with the example you originally posted, you’ll need to make sure that the name you choose for the file matches what you use in the EBD section.

thanks TIm, i will test this out also on this application is it possible when sending an email to use the contents of a string tag to populate the send to field?

That would be fine, I believe you’d just need to call the string tag with an @ symbol at the end of its name. If you have some questions on doing that feel free to send me that section of code and I can take a look at it


thanks for your replay and sorry for all the questions, I am not very familiar with BASIC

i have attached copy of my script

i have a tag “demo_tag” if this changes to 1 i want to send the mail

the tag “email” is my string tag that will contain the address i need the email to be sent to

the tag “alarm_string” is another string tag that i need to put into the body of the email

im not having much luck and appreciate any support.

Try following this document below as an example

Sending Emails with a Flexy.docx (433.3 KB)

thanks Tim

got this working with 1 exception on the following line

$EmailBody$ = $EmailBody$ + "Value of First Tag is " + STR$ alarm@ + CHR$(13) + CHR$(10) // the CHR$(13) + CHR$(10) is the same as newline

my tag “alarm” is a string value

this line works if i pick anything other than string - does this need to be in a different format?

I believe you should just need to remove the +STR$ before the tag is called and that should work

perfect Tim thats it working - many thanks for your support

1 Like

You’re welcome, let me know if there’s more questions

Hi Tim

going back o my first point and the custom report on this link HOW TO: Create a custom historical log file in BASIC

I have created the 2 tags (TankLevel & Valve) as per the example and copied the scrip to my flexy.

I have assumed that to get the file I need to use the EBD? so have used &[$dtHL$fnewon log.csv] in my planner, but not getting anything sent like you have in the example?

the only thing I have changed in the script is

fileName$ = “YourfileName” and replaced your file name with “ewon log”

have I used the correct format in the EBD or am I missing a step?

I believe since the file is already created, you’d need to use dtUF (user file) instead of the dtHL (historical logs) to call it.

Here’s an example of one

“&[$dtUF$uf/usr/” + “Historical_Log_” + $Date$ + “_Report.csv$ftT]”


sorry for all the questions but not having any joy at all - I have copied the script exactly as in the example

getting error ‘=’ expected (3) 10: INIT Section:
if I remove this line i am then getting an error syntax error(0) 15: TSET, 1% REM - Begin a 1 second interval timer

program (1).bas (1.5 KB)

Can I try taking a look at this over teamviewer when you have some time available?

hi Tim yes no problem let me know when suits

or i can create you as as user if it makes things easier?

Could you make me a temporary user and DM the credentials?

I think it should work now, I think the issue was that when the basic script was pulled, the section that says section Init: was left in and it didn’t actually create the section. The same thing was true for the WriteRecord section.

thanks tim thats great can now see the file in my usr directory

You’re welcome, let me know if that seems to work