readme for limitcopies and secwin copies nettalk examples
---------------------------------------------------------

LimitCopies.App
---------------

The goal here is to determine how many copies of a program are running on the LAN.

This is done by adding some code to the FRAME procedure.

The result is stored in a local (LONG) variable called loc:copies. This variable has an initial value of 1. An additional working variable, loc:start (LONG) has also been declared.

The NetTalk Object Extension is added to the frame.
The Object Name is set as "ThisNetCopies".
The Base Class is set as "NetClient".
On the settings tab the "Private Service" is set OFF and
the "Suppress Error Messages" is set ON.
The service name is set to "LimitCopies".

In the source of the frame, the following code has been embedded:
In the INIT method

  loc:copies = 1
  loc:Start = clock()

The first line is only there in case you forgot to set the initial value of your loc:copies to 1. It can be removed if the initial value is set correctly.

The loc:Start is used to determine how long the program has been running. This helps to determine which machine should close in the case where more than the alloted copies are started. We'll see how this is used in a moment.

In the ThisNetCopies.ServersChanged Method, After the PARENT call

  loc:copies = records(self.servers) + 1 
  
  ! add any license checking code here
  if loc:start > clock() then loc:start -= 8640000.  ! midnight rollover.
  if clock() - loc:start < 200  ! 2 seconds.
    if loc:copies > 2 ! hard-coded to limit to 2 copies in this example
      message('Bummer - Too many copies running')
      post(Event:Closedown)
      loc:start = 0      ! this prevents this happening multiple times
    end
  end

This code is automatically triggered whenever a new instance of the program is started on the LAN. (However it is NOT triggered for the first instance on the LAN). It may be triggered multiple times as the program starts as the other instances are detected.

In the above code it is assumed that if an instance has been running for 2 seconds (since the INIT method ran) then it will be a legal copy, and no further checking is done.


SecwinCopies.App
----------------
The Secwin Copies app is the same as the LimitCopies app execpt that it uses Secwin to determine the valid number of copies. When using SQL databases this technique (using nettalk) is superiour to the built-in secwin "Network licensing".

Adding Secwin to the app is done via the normal method - if you're not sure then review the Secwin documentation, expecially the Quick-Start on how to get going. As a summary:

a) add global extension. Turn Licensing on. Allow program to create security files, and set security file location.

b) add User Login extension to frame. Make Login Optional To end User. Allow Multiple security files. Disable Network Licensing. 

the only change to the embed code is in the ServersChanged method.

    if loc:copies > 2 ! hard-coded to limit to 2 copies in this example

changes to

    if loc:copies > ds_CurrentCopies()

------------------------------------------------------------------------------------------------
