Persistent Email Recipient Address Variables


Recommended Posts

I am new to DAQFactory and have been browsing the Forum(s) for an example of how to do the following:

We are creating a screen to configure the Email recipient addresses that will be used to send emails to a group when an Alarm Event happens.

Want to enter the Email addresses once during setup and then have them retained.   (through power loss or closing and re-opening the software application)

Note; The group may need to be updated at a later date as required by a user on the configuration screen when the recipients change.  The updated list should then be retained.

There has to be a simple way of making the data persistent through power loss or closing and re-opening the software application.

Any help would be much appreciated.

Link to comment
Share on other sites

  • 4 weeks later...

There are a couple ways:

1) you can use a registry variable.  The limitation here is that numbers are limited to integers.  Strings are no issue.  

2) you can use a Test D/A channel with Persist = 1 (or more).  This is limited to numbers, but supports decimals.3) you can use the file. functions to write variables to a file, and retrieve them.  Use file.open() to open the file, then file.read() or file.write() and file.close().  Personally I find it easiest to use a class too.  Then I can put all my settings in one place and not have to worry about file formatting or versioning.  Something like this:
 

class CSettings
   local string emailAddresses = ""

   function save()
      try
         private handle = file.open("c:\data\mySettings.json", 0, 1, 0, 1)
         file.write(handle, gSettings.toJson())
         file.close(handle)
      catch()
         ? strLastError
      endcatch
   endfunction

   function load()
      try
         private handle = file.open("c:\data\mySettings.json", 1, 0, 0, 1)
         private string in = file.read(handle)
         gsettings = fromJson(in)
         file.close(handle)
      catch()
         ? strLastError
      endcatch
   endfunction
endclass
global gSettings
gSettings.load()

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share