                                                                   
         







                                C A P T A I N
                                -------------


                           SOFTWARE LICENCE CONTROL


                        THINK COMPUTERS (011) 483-2230




     NOTE: The use of this product is subject to the licence agreement
                            contained in this manual.





































         
         CAPTAIN                                                     
                                                                   Contents
         






                                 CONTENTS


     Description                                                  Page   

     INTRODUCTION               . . . . . . . . . . . . . . . . . . 2                                                                                

     HOW TO USE THIS MANUAL     . . . . . . . . . . . . . . . . . . 4

     INSTALLATION               . . . . . . . . . . . . . . . . . . 5 

     CREATING THE DEMONSTRATION .EXE  . . . . . . . . . . . . . . . 6

     CAPTAIN SCREENS AND PROCESSES  . . . . . . . . . . . . . . . . 7

     USING CAPTAIN WITH THE DEMO PROGRAM  . . . . . . . . . . . .  10

     USING CAPTAIN WITH YOUR APPLICATION  . . . . . . . . . . . .  15

     CAPTAIN FUNCTIONS          . . . . . . . . . . . . . . . . .  16

     SAMPLE PROGRAMS            . . . . . . . . . . . . . . . . .  26

     LICENCE AGREEMENT          . . . . . . . . . . . . . . . . .  44




























         
         CAPTAIN                                                     Page 1
                                                               Introduction
         



                               INTRODUCTION


    CAPTAIN has been designed to solve several problems related to the 
    distribution of software.

    There  is a need to control the distribution of software,  WITHOUT 
    imposing restrictions on copying diskettes. 

    CAPTAIN allows you, the application developer to...

    -    Avoid software piracy of your applications 

    -    Ship   full   featured  applications  with  no   worries   of 
         unauthorized use.

    -    ENCOURAGE  copying  of your software,  knowing that you  have 
         complete control of all copies.

    -    Keep  track  of  all authorized copies  of  each  application 
         developed.  CAPTAIN keeps records of each authorization (who, 
         where, when, what type of authorization, expiry date, etc.).

    -    Create exact duplicates of distribution diskettes - there  is 
         no need to serialize each diskette before shipping.

    -    Give  new  clients an unconditional money back  guarantee  on 
         your  packages  by  allowing only temporary  licencing  until 
         expiry of guarantee period.

    -    Allow  users  to try before they buy - knowing that  if  they 
         don't buy then the software will stop functioning.

    -    Keep  track of individual events within an application  (e.g. 
         execution  count,  month end process count,  ...,  count  any 
         event  within  your  application).  The user  can  phone  for 
         further authorization and you can control the number of  each 
         event available.

    -    For   custom   written  software  clients  - give  them   the 
         confidence  that the software THEY HAVE PAID FOR can  not  be 
         used  by  a competitor (e.g.  when a staff member leaves  and 
         takes a copy with him) without authorization.

    -    For  In-house  software  development  - keep  track  of   all 
         installations of software within the organization,  including 
         identification  of different versions of each application  if 
         required.

    CAPTAIN is written in Clipper 5.01 and C.  Libraries are  supplied 
    for use with Clipper 5.01 and Summer 87.




         
         CAPTAIN                                                     Page 2
                                                               Introduction
         



    There  are  NO bad sectors created on any disks.  No other  "nasty 
    tricks"  are used,  in fact all functions are above board  without 
    any "below dos" calls.  Backups or copies will not be hindered  in 
    any way by the authorization mechanisms used.

    Each  copy of CAPTAIN is unique - one developer can not  authorize 
    another developer's software when both are using CAPTAIN.

    CAPTAIN  can be used to authorize software on a network - once the 
    application  has  been  authorized  on the  network  disk  by  one 
    workstation, then all workstations can access the software without 
    the   need  for  all  workstations  to  individually   apply   for 
    authorization.

    Authorization  is achieved by the client telephoning the developer 
    (voice)  and  then the two parties swap authorization  codes  - it 
    only  takes seconds to read the codes to each other and type  them 
    in.

    CAPTAIN is very simple to use within your application.  There  are 
    very  few functions to learn,  and examples have been provided  to 
    assist you. 

    CAPTAIN  is supplied with software,  libraries (Clipper  5.01  and 
    Summer  87)  and documentation complete with examples  and  sample 
    .prgs.





























         
         CAPTAIN                                                     Page 3
                                                     How to Use This Manual
         



                              HOW TO USE THIS MANUAL

    This  manual  uses boldface with normal capitalization for any  of 
    the  commands  that you must enter.  You will notice that  when  a 
    specific key on the keyboard is to be  pressed,  the name of  this 
    key  will  be  in  angle brackets and in   CAPITALS  like  this  : 
    <ENTER>.   This  means  you  must  press  the  key  called  Enter.             
    <ESCAPE>. This means  you must press the key called Esc. 
     
    The up, down, left and right arrow keys will be <UP-ARROW>, <DOWN-
    ARROW>, <LEFT-ARROW>, <RIGHT-ARROW>. 

    We  suggest that you try out the demonstration program first,  and 
    then build the CAPTAIN functions into your application.









































         
         CAPTAIN                                                     Page 4
                                                               Installation
         



                               INSTALLATION


    The   distribution   disk  contains  a  self-extracting   file   - 
    CAPNZIP.EXE.

    Copy  this file onto your computer and execute it to  extract  the 
    files. You will then have the following files...

    The  CAPTAIN  database  files  and EXE that will be  used  on  the 
    central system to allocate authorization numbers to clients...

    CAPNATYP.DBF            
    CAPNCLNT.DBF
    CAPNELOG.DBF
    CAPNINST.DBF
    CAPNLOCN.DBF
    CAPNPROD.DBF
    CAPNXTB.DBF
    CAPNXTI.DBF
    CAPNZOPR.DBF
    CAPNZOPT.DBF
    CAPNZOPT.DBT
    CAPNZTB.DBF
    CAPNELOG.DBT
    CAPNBOX.MEM
    CAPN.EXE
    CAPNINT.OBJ

    The libraries that you will link into your applications...

    CAPN5.LIB
    CAPN87.LIB

    Demonstration and example programs...

    CAPNDEMO.PRG
    CAPNEG2.PRG
    CAPNEG1.PRG

    This documentation...

    CAPNDOC1.TXT


    We assume that you already have Clipper and a suitable linker  (in 
    our examples we will use syntax for Clipper 5.01 and Blinker).








         
         CAPTAIN                                                     Page 5
                                            Creating the Demonstration .EXE
         



                     CREATING THE DEMONSTRATION .EXE

    To  be  able  to see how it all works,  we have  provided  a  demo 
    program (CAPNDEMO.PRG) which you can now compile and link using...

          CLIPPER CAPNDEMO
          BLINKER FI CAPNDEMO LI CAPN5

    This  will  create CAPNDEMO.EXE which should be copied to  another 
    computer. 

    You will need two computers (or two "virtual" computers if you are 
    using  a multi-tasking or task-swapping operating system) to fully 
    experience the demonstration. 

    One  computer  will be your development system (where  you  copied 
    the CAPTAIN database and CAPN.EXE). 

    The other computer will simulate the Client's system (by executing 
    CAPNDEMO.EXE).



































         
         CAPTAIN                                                     Page 6
                                              CAPTAIN Screens and Processes
         



                      CAPTAIN SCREENS AND PROCESSES

    The screens and menus displayed by CAPN.EXE follow a standard user 
    interface, which is described below.

    None of the CAPTAIN functions that you include in your application 
    code  display  anything on the screen.  They all communicate  with 
    your  application via return codes - this leaves it up to  you  to 
    display  the results of these functions using your own  standards. 
    The  example  programs supplied offer a very basic screen  display 
    which can be modified to your requirements.


    *  Help

         Help  information  can be called up on screen at any time  by 
         pressing the F1 key.


    GENERAL INFORMATION
    
    The  bottom  line of the screen always tells you what you  can  do 
    next,  or what CAPTAIN is doing.

    NOTE:  While a message box or help panel is being  displayed,  you 
    must follow its instructions first. 
          
    *  Screen Displays

         There  are  three kinds of screen in the  program:
            menus;
            data  screens; and
            procedure/report  request screens.

         Most  of  the time,  you will be working with  data  screens: 
         viewing, entering, and amending the data in your files. 
 
         CAPTAIN's functions are consistent throughout,  and for data 
         screens, fall into the following groups: 
 
    *  Getting Help:

         You already know that you press F1 to get help. What help you 
         get depends on when you ask. If you are entering a field, the 
         program  will display a help panel about that field,  whereas 
         if the program is waiting for you to choose a  function,  the 
         help will be general about that screen. 







 
         
         CAPTAIN                                                     Page 7
                                              CAPTAIN Screens and Processes
         



    *  Changing Screens: 
        
    (Esc)ape     returns  you  to the main menu,  which allows you  to 
                 choose another screen or task.  However,  you  should 
                 learn to use the options below, as they will save you 
                 time  going  back and forth,  rekeying the values  of 
                 computer codes for "header" data. 

    (B)ack       goes back to a summary screen relative to this  level 
                 of detail
         
    (S)wp(L)     S)wap  changes  the "details" for the  same  "header" 
                 sp(L)it  shows  two kinds of detail by splitting  the 
                 screen 

    Enter        Selects  the  current  record  and  goes  to  a  more 
                 detailed  screen.  For  example,  when in  the  NAMES 
                 screen,  you  may  press  the enter key  to  see  all 
                 transactions for one of your customers and  suppliers 
                 only. 
 

    *  Changing Screen Views: 
       
    Up arrow     Moves the current record pointer up one detail record 
    Down arrow   Moves the current record pointer down one record 
    PgUp         Scrolls  the  screen  back up one screen  of  details             
    PgDn         Scrolls down one screen of details 
    Home         Displays the first screenful of detail records 
    End          Displays the last screenful of detail records 
    (Z)oom       Displays more data about the current record. 

    You can use all the keys above whilst in zoom mode,  namely: Up Dn 
    PgUp PgDn Home End
 
    (N)ew        Allows  you to select a new header  record,  and  its 
                 details 
    (F)ind       Allows you to find a detail record by key value 
    (P)rint      Allows  you to print the logical screen contents  for 
                 this  screen. 
               
    *  Changing Data:     
         
    (A)dd        Allows you to add a new detail record 
    (C)hg        Allows you to change the current detail record 
    (D)el        Allows you to flag the current record for deletion 
    (U)ndel      Allows  you  to  remove the deletion  flag  from  the 
                 current  record 
 






         
         CAPTAIN                                                     Page 8
                                              CAPTAIN Screens and Processes
         



    *  Entering Data

    Enter        Accept the field contents and go on to the next field           
    Up  arrow    Accept the current field and go back to the  previous 
                 field 
    PgUp         Accept  the  current field and go back to  the  first 
                 field 
    PgDn         Accept all fields and complete this record 
    (Esc)ape     Cancel   the  current  function  (restore  all  field 
                 contents) 
    Home         Move the cursor to the first position in the field 
    End          Move  the cursor to the position after the last  non-
                 blank 
    BackSpace    Delete  the  character over the cursor and  move  the 
                 cursor 
    Delete       Move the cursor back one and delete that character 
    Insert       Toggles between insert and overstrike modes. 

     

    *   Key Fields - computer codes 
    
    Whenever  CAPTAIN asks you to enter the value of a code,  you  may 
    select  the  required  value from a "Key  Selection  Window".  You 
    invoke the window by pressing Enter with a blank code, or pressing 
    the down arrow key after entering a partial key value. 

    You  can A)dd the record for a new code from this window,  if  the 
    bottom line of the screen suggests this.


























         
         CAPTAIN                                                     Page 9
                                        Using CAPTAIN With the Demo Program
         



                   USING CAPTAIN WITH THE DEMO PROGRAM

    To   demonstrate  the  authorization  process  we  will  use   two 
    computers.  One  to  run  CAPN.EXE (we will refer to this  as  the 
    CENTRAL PC),  and the other to run CAPNDEMO.EXE (we will refer  to 
    this as the CLIENT PC).

    On the client PC run CAPNDEMO. The screen will look like this...

    
Ŀ
            CAPTAIN  -  SOFTWARE LICENCE CONTROL   (Demonstration)            
ͻ ͻ
Check if a System is Authorized      System NOT AUTHORIZED!               
Request Authorization of a System                                         
Show Contents of an Event Counter    Enter System name :  capncode        
Reduce Event Counter by 1            No Authorization found!              
Request Authorization of More Events System NOT AUTHORIZED!               
Write to an Event Counter                                                 
Exit to DOS                          Enter System name :  capnabc         
                                     Enter Event name  :  count1          
                                     System capnabc    not authorized!    
ͼ ͼ
ͻ
   if y = -1                                                                
      showprg(-1)                                                           
      scrollup(1)                                                           
      @ mr,mc say 'System '+msystem+' not authorized!'                      
   elseif y = -2                                                            
      showprg(-1)                                                           
      scrollup(1)                                                           
      @ mr,mc say 'Network Error!'                                          
PgUpPgDnͼ



    The top left corner of this screen is a simple menu.

    The  top  right  corner  is an "action"  window  where  all  other 
    displays  and data entry will occur.  This window scrolls so  that 
    you can see the last few entries.

    The  bottom  half of the screen shows the program as it  is  being 
    executed.  This  window will automatically position itself to  the 
    current  code segment.  You can scroll this window yourself  using 
    the PgUp and PgDn keys at any time that the program is waiting for 
    data input.

    Now...

    Select the first item on the menu <ENTER>
    Enter capndemo as the system name <ENTER> 
    You  will  be told that the capndemo system is not authorized  for 
    use on this computer.

         
         CAPTAIN                                                    Page 10
                                        Using CAPTAIN With the Demo Program
         



    Select the second item on the menu <ENTER>
    Enter C for the disk drive <ENTER>
    The  system  name  will default to the last  entry  (capndemo)  so 
    <ENTER>
    A  serial number will be displayed and you will be asked to  enter 
    an authorization number...

    Now,  go  to  the  central PC and run CAPN.  The  main  menu  will 
    appear...

    
CAPN Screens  System  92.03.16  C
     Ŀ                                                
     Installations       #09                                                
     Clients             #01                                                
     Products            #02                                                
     Authorization Types #03                                                
                                                     
                                                                              
                                                                              
                             << CAPTAIN >>                                    
                                                                              
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                 
                                                                              

    

    Select INSTALLATIONS and <ENTER>

    On the Installations screen press A to add a new record.


















         
         CAPTAIN                                                    Page 11
                                        Using CAPTAIN With the Demo Program
         



    When  it  asks you for Client Number,  <DOWN-ARROW> and  a  Client 
    window  will  pop up.  A to add a new client and enter the  client 
    name as FIRST CLIENT <ENTER>

    
CAPN  Installations  #09   92.03.16X
                                                                              
  Inst Client & Location                   Product & Authorization   Date/Exp 
ĳ
  0013 Ŀ6 Debtors system       92.02.26 
         Client Number                      3 30 Days              92.03.07 
       ĳ                                
  0014   0001 VAT Consultants               6 Debtors system       92.02.26 
         0002 Dr Bhyat                      2 10 Days              93.04.01 
         0003 Leon                                                          
  0015   0004 PLCS                          7 Project Management   92.02.26 
         0005 ABC Inc.                      0 5    Events          92.02.26 
         0006 FIRST CLIENT                                                  
                                                                            
                                       
                                                                              
                                                                              

    

    When it asks you for Location,  <DOWN-ARROW> and a Location window 
    will pop up.  A to add a new location and enter the location  name 
    as DEMONSTRATION PC <ENTER>

    
CAPN  Installations  #09   92.03.16X
                                                                              
  Inst Client & Location                   Product & Authorization   Date/Exp 
ĳ
  0013 0005 ABC Inc.                       0006 Debtors system       92.02.26 
       Ŀ       0003 30 Days              92.03.07 
         Location                                                           
  0014 ĳ       0006 Debtors system       92.02.26 
         0002 DEMONSTRATION PC           0002 10 Days              93.04.01 
                                                                            
  0015                                   0007 Project Management   92.02.26 
                                         0010 5    Events          92.02.26 
                                                                            
                                                                            
                                                 
                                                                              

    







         
         CAPTAIN                                                    Page 12
                                        Using CAPTAIN With the Demo Program
         



    When  it asks you for Product,  <DOWN-ARROW> and a Product  window 
    will pop up.  A to add a new product and enter the product name as 
    Captain Demo <ENTER>. Enter the Product ID as capndemo <ENTER>

    
CAPN  Installations  #09   92.03.16X
                                                                              
  Inst Client & Location                   Product & Authorization   Date/Exp 
ĳ
  0013 0005 ABC Inc.                 Ŀ 
       0001 Accounts Server            Product Number                       
                                     ĳ 
  0014 0005 ABC Inc.                   0006 Debtors system       debtors    
       0002 Steve's laptop             0007 Captain Demo         capndemo   
                                                                            
  0015 0006 Sunshine Homes                                                  
       0001 Reception PC                                                    
                                                                            
                                                                            
                                      
                                                                              

    

    When  it  asks  you for Authorization Type,  <DOWN-ARROW>  and  an 
    Authorization  Types  window will pop up.  Select 10  Days  Expiry 
    <ENTER>. 

    
CAPN  Installations  #09   92.03.16X
                                                                              
  Inst Client & Location                   Product & Authorization   Date/Exp 
ĳ
  0013 0005 ABC Inc.                       0006 Debtors system       92.02.26 
       0001 Accounts Server                Ŀ03.07 
                                             Authorization Type             
  0014 0005 ABC Inc.                       ĳ02.26 
       0002 Steve's laptop                   0002 10 Days             04.01 
                                             0003 30 Days                   
  0015 0006 Sunshine Homes                   0004 60 Days             02.26 
       0001 Reception PC                     0005 90 Days             02.26 
                                             0006 120 Days                  
                                             0007 1 Year (400 days)         
                                             0008 Forever!                  
                                             0009 1    Event                
                                             0010 5    Events               
                                             0011 10   Events               
                                             0012 50   Events               
                                             0013 100  Events               
                                                 
                                                                              

    


         
         CAPTAIN                                                    Page 13
                                        Using CAPTAIN With the Demo Program
         



    You will now be asked to enter a serial number.  Enter the  number 
    that was displayed on the Client PC <ENTER> 
    
CAPN  Installations  #09   92.03.16X
                                                                              
  Inst Client & Location                   Product & Authorization   Date/Exp 
ĳ
  0013 0005 ABC Inc.                       0006 Debtors system       92.02.26 
       0001 Accounts Server                0003 30 Days              92.03.07 
                                                                              
  0014 0005 ABC Inc.                       0006 Debtors system       92.02.26 
       0002 Steve's laptop                 0002 10 Days              93.04.01 
                                                                              
  0015 00                                                             2.02.26 
       00 DEMOͻ 2.02.26 
          Serial Number on Client PC         :               0              
          Date / Time   on Client PC         :                              
                                                                            
                                                                            
                                                                            
          Authorization Number (For Client)  :                              
          Accepted at site? (Yes/No/Exit)    :                              
          ͼ         
                                                                              

    

    An  authorization number will be displayed on the central PC which 
    should then be entered at the CLIENT PC <ENTER>

    After  entering  the  authorization number on the  client  PC  the 
    client PC will then return to the menu.

    Back at the central PC enter Y to indicate that the  authorization 
    number was accepted and <ENTER>

    We now have, on the Client PC, an authorized system (capndemo). If 
    you  use the first menu option now,  it will show that capndemo is 
    authorized.

    EVENTS

    Events  are treated in a very similar way to products.  To ask for 
    more  of a specific event,  the client must get  an  authorization 
    number from central.

    Events  are  a "second level" of authorization,  in that you  must 
    specify both a product and an event name on the client PC, and the 
    product must already be authorized,  before you can authorize  any 
    events related to the product.

    On  the  central PC,  each event should be recorded as a  separate 
    "product".  The  authorization  type  used should be  one  of  the 
    "event" authorizations (1 event, 5 events, etc.).

         
         CAPTAIN                                                    Page 14
                                        Using CAPTAIN With Your Application
         



                   USING CAPTAIN WITH YOUR APPLICATION

    Using CAPTAIN with your application is essentially the same as the 
    demonstration,  except  that the user will not have the option  of 
    choosing  system names or event names.  You will  hard-code  these 
    into your application to meet the requirements.

    Remember  that the code provided in the examples uses the simplest 
    screen accessing methods - to show the use of the functions. It is 
    highly recommended that you modify the supplied code to provide an 
    adequate user interface for your clients.


    PLEASE NOTE
    To maintain compatability with both Summer 87 and 5.01,  the set() 
    function has not been used to restore the SET DATE and SET CENTURY 
    settings.

    Therefore,   certain   CAPTAIN  functions  will  return  to   your 
    application with the following settings...
          SET DATE ANSI
          SET CENTURY OFF

    Please  reset  these  to your requirements  (if  necessary)  after 
    returning from capn????() functions in your application.






























         
         CAPTAIN                                                    Page 15
                                                          CAPTAIN Functions
         



                            CAPTAIN FUNCTIONS


    SYSTEM AUTHORIZATION FUNCTIONS

    CAPNCHEK()            Check for authorization

    CAPNMAKE()            Make new authorization records

    CAPNGET()             Get a serial number

    CAPNTEST()            Verify authorization against serial number
                          
                          
                          
    EVENT MANIPULATION FUNCTIONS
                          
    CAPNCNTR()            Read event counter
                          
    CAPNCNTW()            Write event counter
                          
    CAPNGET()             Get a serial number
                          
    CAPNCNTM()            Verify authorization against serial number



    GENERATE AUTHORIZATION CODES

    CAPNAUTH()            Generate an authorization number

























         
         CAPTAIN                                                    Page 16
                                                          CAPTAIN Functions
         



    CAPNCHEK()

    Check for authorization of a system ID.

    Syntax
    CAPNCHEK(<sysID>) -> cValue

    Arguments
    <sysID>   is  the  ID  of  the product  to  be  checked.  Must  be 
              character type.  Maximum of 10 characters. Should be the 
              same as the Product ID used in the CAPN system database.

    Returns
    A  character  type  return  value  with  the  leftmost   character  
    indicating the success of the function as follows...

    '0'    -  the  system  is authorized.  The drive letter where  the 
              authorization  information was found is returned as  the 
              2nd  and 3rd characters of the return string ('C:'  'D:' 
              etc)

    '1'    -  no authorization for this system ID has been found

    '2'    -  invalid system date on client PC (date < 1992)

    '3'    -  authorization  has expired.  The drive letter where  the 
              authorization  information was found is returned as  the 
              2nd  and 3rd characters of the return string ('C:'  'D:' 
              etc)

    '4'    -  invalid  system  date on client PC (the date is  earlier 
              than the last authorization check and indicates that the 
              client is trying to back date his system date to prevent 
              expiry of the authorization

    '9'    -  an   error   occurred   while   attempting   to   access 
              SERIALNO.DBF in the \CAPTAIN directory


    Description
    CAPNCHEK()  performs the basic test to see if the application  has 
    been  authorized  to be used on this computer.  Depending  on  the 
    return value,  you would continue with the application,  abort, or 
    use   other  CAPTAIN  functions  to  attempt  to   authorize   the 
    application.

    See CAPNEG1.PRG and CAPNDEMO.PRG for examples








         
         CAPTAIN                                                    Page 17
                                                          CAPTAIN Functions
         



    CAPNMAKE()

    To  create  the  necessary authorization files  on  the  specified 
    drive.

    Syntax
    CAPNMAKE(<sysID>, <drive>) -> cValue

    Arguments
    <sysID>   is  the  ID of the product to  be  authorized.  Must  be 
              character type.  Maximum of 10 characters. Should be the 
              same as the Product ID used in the CAPN system database.

    <drive>   is  the drive letter specifying the disk drive where you 
              want  the authorization information to be  stored.  This 
              must  be  a 2 character field with drive  letter  and  a 
              colon (C:  D:  etc). A: and B: will not be accepted. You 
              may specify a network drive (F:  G: etc) if you want the 
              authorization to be on a network.

    Returns
    A single character type return value indicating the success of the 
    function as follows...

    '0'    -  creation of the authorization files was successful.

    '6'    -  the  authorization  files could not be created  on  this 
              drive.

    '5'    -  invalid disk drive letter.

    '9'    -  an   error   occurred   while   attempting   to   access 
              SERIALNO.DBF in the \CAPTAIN directory


    Description
    CAPNMAKE()   creates  the  necessary  files  and  records  on  the 
    specified drive to be able to record authorization information for 
    one or more product IDs.

    A  file SERIALNO.DBF is created in a directory called \CAPTAIN  on 
    the specified drive.

    See CAPNEG1.PRG and CAPNDEMO.PRG for examples











         
         CAPTAIN                                                    Page 18
                                                          CAPTAIN Functions
         



    CAPNGET()

    To  get a new serial number for the authorization process.

    Syntax
    CAPNGET(<sysID>) -> cValue

    Arguments
    <sysID>   is  the  ID of the product to  be  authorized.  Must  be 
              character type.  Maximum of 10 characters. Should be the 
              same as the Product ID used in the CAPN system database.

    Returns
    A character string which is the string of the serial number.

    Description
    Before requesting an authorization number from the central PC  you 
    must  first have a serial number to be entered to the central CAPN 
    system.

    See CAPNEG1.PRG and CAPNDEMO.PRG for examples


































         
         CAPTAIN                                                    Page 19
                                                          CAPTAIN Functions
         



    CAPNTEST()

    Test   the  validity  of  the  authorization  number  and   update 
    authorization information.

    Syntax
    CAPNTEST(<sysID>, <drive>, <serial>, <auth>) -> cValue

    Arguments
    <sysID>   is  the  ID  of  the product  to  be  checked.  Must  be 
              character type.  Maximum of 10 characters. Should be the 
              same as the Product ID used in the CAPN system database.

    <drive>   is  the drive letter specifying the disk drive where you 
              want  the authorization information to be  stored.  This 
              must  be  a 2 character field with drive  letter  and  a 
              colon (C:  D:  etc). A: and B: will not be accepted. You 
              may specify a network drive (F:  G: etc) if you want the 
              authorization to be on a network.

    <serial>  this is the same serial number that was generated by the 
              CAPNGET() function. This is a character string.

    <auth>    this  is  the authorization number that the  client  has 
              entered  (he gets this by phoning you).  This must be  a 
              character   string   containing   the   value   of   the 
              authorization number


    Returns
    A  character  type  return  value  with  the  leftmost   character  
    indicating the success of the function as follows...

    '0'    -  the authorization process has been successful

    '9'    -  an   error   occurred   while   attempting   to   access 
              SERIALNO.DBF in the \CAPTAIN directory

    Any other return value indicates an invalid authorization  attempt 
    (this suggests that the client is guessing numbers).


    Description
    CAPNTEST()  checks to see if the authorization number is valid and 
    also determines the expiry date selected by the developer.

    If  an  authorization  attempt  fails  on  an  already  authorized 
    product, then the product will no longer be authorized.

    See CAPNEG1.PRG and CAPNDEMO.PRG for examples





         
         CAPTAIN                                                    Page 20
                                                          CAPTAIN Functions
         



    CAPNCNTR()

    Read an event counter.

    Syntax
    CAPNCNTR(<sysID>, <event>) -> nValue

    Arguments
    <sysID>   is  the  ID  of  the product  to  be  checked.  Must  be 
              character type.  Maximum of 10 characters. Should be the 
              same as the Product ID used in the CAPN system database.

    <event>   this  is the name of the event counter that you want  to 
              read.


    Returns
    A  numeric  type return value which contains the current value  of 
    the  event  counter.  A  negative  value  indicates  an  error  as 
    follows...

    -1     -  the  system  specified by <sysID> is not authorized  for 
              use on this computer

    -2     -  a network read or write error has occurred

    -3     -  the event counter has been corrupted. This suggests that 
              the client is trying to bypass the event counter system.

    Description
    CAPNCNTR() will give you the current value of an event counter. It 
    is  expected  that  the  specified  system  ID  has  already  been 
    authorized using the other CAPTAIN procedures.

    See CAPNEG2.PRG and CAPNDEMO.PRG for examples




















         
         CAPTAIN                                                    Page 21
                                                          CAPTAIN Functions
         



    CAPNCNTW()

    Write to an event counter. (or create a new event counter)

    Syntax
    CAPNCNTW(<sysID>, <event>, <newcount>) -> nValue

    Arguments
    <sysID>   is  the  ID  of  the product  to  be  checked.  Must  be 
              character type.  Maximum of 10 characters. Should be the 
              same as the Product ID used in the CAPN system database.

    <event>   this  is the name of the event counter that you want  to 
              write.

    <newcount> is the new value that you want in the event counter.


    Returns
    A  numeric  type return value which indicates the success  of  the 
    write function as follows...

    0      -  successful write

    -1     -  the  system  specified by <sysID> is not authorized  for 
              use on this computer

    -2     -  a network read or write error has occurred

    -3     -  error writing to the event counter

    Description
    CAPNCNTW()  will  write a new value to an  event  counter.  It  is 
    expected  that the specified system ID has already been authorized 
    using the other CAPTAIN procedures.

    See CAPNEG2.PRG and CAPNDEMO.PRG for examples


















         
         CAPTAIN                                                    Page 22
                                                          CAPTAIN Functions
         



    CAPNCNTM()

    Test  the  validity of the authorization number for an  event  and 
    return the number of new events that have been authorized. 

    Syntax
    CAPNCNTM(<event>, <serial>, <auth>) -> nValue

    Arguments
    <event>   this  is the name of the event counter that you want  to 
              authorize.

    <serial>  this is the same serial number that was generated by the 
              CAPNGET() function. This is a character string.

    <auth>    this  is  the authorization number that the  client  has 
              entered  (he gets this by phoning you).  This must be  a 
              character   string   containing   the   value   of   the 
              authorization number


    Returns
    A numeric type return value which indicates the increment that has 
    been authorized for this event.

    Description
    CAPNCNTM()  checks to see if the authorization number is valid and 
    also determines the number of events selected by the developer.

    See CAPNEG2.PRG and CAPNDEMO.PRG for examples

























         
         CAPTAIN                                                    Page 23
                                                          CAPTAIN Functions
         



    CAPNAUTH()

    To generate an authorization code from a serial number.

    Syntax
    CAPNAUTH(<sysID>, <exptype>, <serial>) -> Array

    Arguments
    <sysID>   is  the  ID  of  the product  to  be  checked.  Must  be 
              character type.  Maximum of 10 characters. Should be the 
              same as the Product ID used in the CAPN system database.

    <exptype> specifies  the type of authorization required.  Must  be 
              numeric type. Must be one of the following values...
               1  -  1  Day expiry
               2  -  10 Days expiry
               3  -  30 Days expiry
               4  -  60 Days expiry     
               5  -  90 Days expiry     
               6  -  120 Days expiry    
               7  -  1 Year (400 days)  
               8  -  Forever!           
               9  -  1    Event         
              10  -  5    Events        
              11  -  10   Events        
              12  -  50   Events        
              13  -  100  Events        
              14  -  500  Events        
              15  -  1000 Events        

    <serial>  this is the same serial number that was generated by the 
              CAPNGET() function. This is numeric.

    Returns
    An array of 4 elements is returned.

    Array[1] indicates the success of the operation... (numeric)
          0     -  successful
         -1     -  demo version of CAPTAIN (exp must be 1, 2, 9 or 10)
         -2     -  demo version of CAPTAIN (exp must be 1, 2, 9 or 10)
         -3     -  <sysID> does not match <serial>
         -4     -  date  on client PC differs by 100 days or more from 
                   date on authorizing PC (an authorization number  is 
                   NOT generated)
         -5     -  date  on  client PC differs by 8 days or more  from 
                   date on authorizing PC (an authorization number  IS 
                   generated)

    Array[2] contains the authorization code (numeric).
    Array[3] contains the date on the client PC (date).
    Array[4] contains the time on the client PC (character).




         
         CAPTAIN                                                    Page 24
                                                          CAPTAIN Functions
         



    Description

    CAPNAUTH()  is  provided  as a compiled (5.01)  object  module  in 
    CAPNINT.OBJ.

    This  function has been provided for developers who wish to  write 
    their  own  authorization  and installation  recording  module  to 
    replace CAPN.EXE.

    Within  your  module  (the one that replaces  CAPN.EXE)  you  must 
    determine  the product ID and the expiration  type  required.  The 
    serial  number will be entered (after asking the client to read it 
    out from your application running on the client's PC) and then you 
    call CAPNAUTH() with these parameters to generate an authorization 
    code - which should be then read out to the client so he can enter 
    it to your application.







































         
         CAPTAIN                                                    Page 25
                                                            Sample Programs
         



                            SAMPLE PROGRAMS


    The  first sample program (CAPNEG1.PRG) includes the basic  system 
    verification methods to be used by your applications.

    This  program  can  be  compiled and  linked  (with  CAPN5.LIB  or 
    CAPN87.LIB) by itself - to be used as a demonstration. 

    You  could  also include this code segment at the  start  of  your 
    application  (with  the appropriate change to the system name)  to 
    provide the authorization mechanism for your application.


* CAPNEG1.PRG

* EXAMPLES TO DEMONSTRATE USE OF CAPTAIN SYSTEM AUTHORIZATION FUNCTIONS
*                                        ------
*
* Include this source code at the start of the first .prg of
* your application and change "msystem = 'capncode'" to indicate
* the name of the software you are protecting
* e.g. "msystem = 'Protect-me'"

* This system name must be the same as the Product ID for the product
* (in the products file in CAPN)

msystem = 'capncode'                    && max 10 characters

clear
cdrive = ''

do while .t. 
   cret = capnchek(msystem)            && see if already authorized
   if left(cret,1) = '9'               && can not access serialno.dbf
      @ 10,10 say 'Error accessing SERIALNO.DBF'
      wait
      cancel
   elseif left(cret,1) = '2'           && invalid date
      @ 10,10 say 'Invalid System Date'
      wait
      cancel
   elseif left(cret,1) = '4'           && back dating!
      @ 10,10 say 'Invalid System Date - Earlier than last use!'
      wait
      cancel
   elseif left(cret,1) = '0'           && all OK
      cdrive = substr(cret,2,2)
      exit
   elseif left(cret,1) = '3'           && authorization has expired
      cdrive = substr(cret,2,2)
      @ 10,10 say 'Software Authorization has expired!'
   elseif left(cret,1) = '1'           && no registration found
   endif

         
         CAPTAIN                                                    Page 26
                                                            Sample Programs
         




   if empty(cdrive)
      cdrive = 'C'
      @ 11,10 say 'Enter disk drive for authorization: ' ;
      get cdrive picture '@! A' valid(!(cdrive $ 'AB'))
      read
      if lastkey() = 27
         cancel
      endif
      cdrive = cdrive + ':'

      cret = capnmake(msystem,cdrive)
      if cret = '6'
         @ 12,10 say 'Can not create CAPTAIN directory or files on ';
         + cdrive + '!'
         wait
         cancel
      elseif cret = '5'
         @ 12,10 say 'Invalid disk drive letter!'
         wait
         cancel
      elseif left(cret,1) = '9'        && can not access serialno.dbf
         @ 12,10 say 'Error accessing SERIALNO.DBF'
         wait
         cancel
      endif
   endif

   cseed = capnget(msystem)            && get seed number
   cauth = 0
   @ 12,10 say 'System to be Authorized is : '
   @ 12,39 say msystem
   @ 13,10 say 'System serial number is    : '
   @ 13,39 say val(cseed) picture '999 999 999 999'
   @ 14,10 say 'Enter Authorization Number : ' 
   @ 14,39 get cauth picture '999 999 999 999'
   @ 15,10 say '(Phone software dealer)'
   read
   if lastkey() = 27
      cancel
   endif
   cauth = str(cauth,12)
   cret = capntest(msystem,cdrive, cseed, cauth)
   if cret = '0'
      exit
   elseif left(cret,1) = '9'           && can not access serialno.dbf
      @ 16,10 say 'Error accessing SERIALNO.DBF'
      wait
      cancel
   endif
   @ 16,10 say 'Invalid authorization!'
   wait
   cancel                              
enddo

         
         CAPTAIN                                                    Page 27
                                                            Sample Programs
         




    The  second sample program (CAPNEG2.PRG) includes the basic  event 
    verification methods to be used by your applications.

    This  program  can  be  compiled and  linked  (with  CAPN5.LIB  or 
    CAPN87.LIB) by itself - to be used as a demonstration. 

    You could include parts of this program in your application at the 
    points where you want to manipulate any event counters.



* CAPNEG2.PRG  

* EXAMPLES TO DEMONSTRATE USE OF CAPTAIN EVENT AUTHORIZATION FUNCTIONS
*                                        -----
*
* compile and link this program
*
*     clipper capneg2
*     blinker fi capneg2 li capn5
*

* This system name must be the same as the Product ID for the product
* (in the products file in CAPN)

* this program will only work if a product with an ID of 'capncode'
* has already been authorized (see capneg1.prg).

msys = 'capncode'
clear
mevent = 'COUNT1'                                && maximum 8 characters

do while .t.
   y = capncntr(msys,mevent)               && read contents of counter
   if y = -1
      @ 23,10 say 'System '+msys+' has not been authorized!'
      wait
      cancel
   elseif y = -2
      @ 23,10 say 'Network Error!'
      wait
      cancel
   elseif y = -3
      @ 23,10 say 'Event Counter '+mevent+' has been corrupted!'
      wait
      cancel                                               
   endif

   @ 6,10 say 'Available events = ' + str(y)
   mans = ' '
   @ 8,10 say 'Use one up?        ' get mans picture '@!'
   read
   mans = upper(mans)

         
         CAPTAIN                                                    Page 28
                                                            Sample Programs
         




   if mans = 'E' .or. lastkey() = 27
      exit
   endif

   if !(mans $ 'YNE')
      loop
   endif             

   if mans = 'Y'
      y = capncntw(msys,mevent,y-1)      && write back the counter less 1
      if y = -1
         @ 23,10 say 'System '+msys+' has not been authorized!'
         wait
         cancel
      elseif y = -2
         @ 23,10 say 'Network Error!'
         wait
         cancel
      elseif y = -3
         @ 23,10 say 'Error writing to Event Counter '+mevent+'!'
         wait
         cancel                                               
      endif
   endif                                         

   mans = ' '
   @ 10,10 say 'Ask for more?      ' get mans picture '@!' valid(mans $ 'YN')
   read
   if mans = 'Y'         
      cseed = capnget(mevent)            && get seed number
      cauth = 0

      @ 12,10 say 'Event to be Authorized is  : '
      @ 12,39 say mevent
      @ 13,10 say 'Event serial number is     : '
      @ 13,39 say val(cseed) picture '999 999 999 999'
      @ 14,10 say 'Enter Authorization Number : ' 
      @ 14,39 get cauth picture '999 999 999 999'
      @ 15,10 say '(Phone software dealer)'
      read
      if lastkey() = 27
         cancel
      endif
      cauth = str(cauth,12)










         
         CAPTAIN                                                    Page 29
                                                            Sample Programs
         




*   determine how many additional events have been authorized
*
      newevents = capncntm(mevent, cseed, cauth)

      y = capncntr(msys,mevent)                && read counter again
      if y = -1
         @ 23,10 say 'System '+msys+' has not been authorized!'
         wait
         cancel
      elseif y = -2
         @ 23,10 say 'Network Error!'
         wait
         cancel
      elseif y = -3
         @ 23,10 say 'Event Counter '+mevent+' has been corrupted!'
         wait
         cancel                                               
      endif
      y = capncntw(msys,mevent,y+newevents)     && update the counter
      if y = -1
         @ 23,10 say 'System '+msys+' has not been authorized!'
         wait
         cancel
      elseif y = -2
         @ 23,10 say 'Network Error!'
         wait
         cancel
      elseif y = -3
         @ 23,10 say 'Error writing to Event Counter '+mevent+'!'
         wait
         cancel                                               
      endif
      @ 12,10 clear to 15,75
   endif       
enddo



















         
         CAPTAIN                                                    Page 30
                                                            Sample Programs
         




    The   third  sample  program  (CAPNDEMO.PRG)  covers  a   complete 
    demonstration of all of the CAPTAIN functions.

    This  program  can  be  compiled and  linked  (with  CAPN5.LIB  or 
    CAPN87.LIB) - to be used as a demonstration. 

    This  program displays itself (capndemo.prg),  in a window on  the 
    screen as it is processing,  to show you exactly what is happening 
    internally during the authorization process.

* CAPNDEMO.PRG

* CAPTAIN
* SOFTWARE LICENCE CONTROL SYSTEM

* DEMONSTRATION PROGRAM

clear
private menuitems[7]
menuitems[1] = 'Check if a System is Authorized'
menuitems[2] = 'Request Authorization of a System'
menuitems[3] = 'Show Contents of an Event Counter'
menuitems[4] = 'Reduce Event Counter by 1'
menuitems[5] = 'Request Authorization of More Events'
menuitems[6] = 'Write to an Event Counter'
menuitems[7] = 'Exit to DOS'

msystem = space(10)
mevent  = space(8)
mcnt    = 0
cdrive = ' '
mr = 12
mc = 41

keyson()

@ 1,0 to 24,79
set color to n/w
@ 2,1 say ;
'            CAPTAIN  -  SOFTWARE LICENCE CONTROL   (Demonstration)            ' 
set color to
@ 3,1 to 13,38 double
@ 13,18 say chr(24)
@ 13,21 say chr(25)
@ 3,40 to 13,78 double

@ 14,1 to 23,78 double
@ 23,34  say 'PgUp'
@ 23,42  say 'PgDn'
mprg = memoread('capndemo.prg')                  && get this prg in
public prgrow
prgrow = 1
showprg2(prgrow)

         
         CAPTAIN                                                    Page 31
                                                            Sample Programs
         




mch = 1
do while .t.
   keysoff()
   mch = achoice(4,2,10,37,menuitems,,,mch)
   if mch = 0 .or. mch = 7
      exit
   endif
   keyson()

   if mch = 1
      mch1()
   elseif mch = 2
      mch2()
   elseif mch = 3
      mch3()
   elseif mch = 4
      mch4()
   elseif mch = 5
      mch5()
   elseif mch = 6
      mch6()
   endif
enddo   
@ 24,0 say chr(192)
quit





























         
         CAPTAIN                                                    Page 32
                                                            Sample Programs
         




function mch1
   * check system
   scrollup(2)
   showprg(1)
   @ mr,mc say 'Enter System name : ' get msystem picture '@K XXXXXXXXXX'
   read                                                       
   if empty(msystem)
      return(.t.)
   endif

   showprg(1)
   cret = capnchek(msystem)            && see if already authorized
   if left(cret,1) = '9'               && can not access serialno.dbf
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Error accessing SERIALNO.DBF'
      scrollup(1)
      @ mr,mc say 'System NOT AUTHORIZED!'
   elseif left(cret,1) = '2'           && invalid date
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Invalid System Date'
      scrollup(1)
      @ mr,mc say 'System NOT AUTHORIZED!'
   elseif left(cret,1) = '4'           && back dating!
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Invalid System Date - Earlier than last use!'
      scrollup(1)
      @ mr,mc say 'System NOT AUTHORIZED!'
   elseif left(cret,1) = '0'           && all OK
      showprg(-1)
      cdrive = substr(cret,2,2)
      scrollup(1)
      @ mr,mc say 'System AUTHORIZED on drive '+cdrive
   elseif left(cret,1) = '3'           && authorization has expired
      showprg(-1)
      cdrive = substr(cret,2,2)
      scrollup(1)
      @ mr,mc say 'Software Authorization has expired!'
      scrollup(1)
      @ mr,mc say 'System NOT AUTHORIZED!'
   elseif left(cret,1) = '1'           && no registration found
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'No Authorization found!'
      scrollup(1)
      @ mr,mc say 'System NOT AUTHORIZED!'
   endif
return(.t.)




         
         CAPTAIN                                                    Page 33
                                                            Sample Programs
         




function mch2
   scrollup(2)
   showprg(1)
   @ mr,mc say 'Enter Disk Drive  : ' get cdrive ;
               picture '@K!A X' valid(!(cdrive $ 'AB'))
   read                                                       
   if empty(cdrive)
      return(.t.)
   endif
   cdrive = substr(cdrive,1,1) + ':'
   scrollup(1)
   showprg(1)
   @ mr,mc say 'Enter System name : ' get msystem picture '@K XXXXXXXXXX'
   read                                                       
   if empty(msystem)
      return(.t.)
   endif

   cret = capnmake(msystem,cdrive)
   if cret = '6'
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Can not create CAPTAIN files on ' + cdrive + '!'
      return(.t.)
   elseif cret = '5'
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Invalid disk drive letter!'
      return(.t.)
   elseif left(cret,1) = '9'        && can not access serialno.dbf
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Error accessing SERIALNO.DBF'
      return(.t.)
   endif

   cseed = capnget(msystem)            && get seed number
   cauth = 0
















         
         CAPTAIN                                                    Page 34
                                                            Sample Programs
         




   scrollup(1)
   showprg(1)
   @ mr,mc say 'Serial number is  : '
   @ mr,mc+20 say val(cseed) picture '999 999 999 999'
   scrollup(1)
   @ mr,mc say 'Enter Authorization Number : ' 
   scrollup(1)
   @ mr,mc+20 get cauth picture '999 999 999 999'
   read
   if lastkey() = 27
      return(.t.)
   endif
   cauth = str(cauth,12)
   showprg(1)
   cret = capntest(msystem,cdrive, cseed, cauth)
   if cret = '0'
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Authorization Complete!'
      return(.t.)
   elseif left(cret,1) = '9'           && can not access serialno.dbf
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Error accessing SERIALNO.DBF'
      return(.t.)
   endif
   scrollup(1)
   showprg(1)
   @ mr,mc say 'Invalid authorization!'
return(.t.)
























         
         CAPTAIN                                                    Page 35
                                                            Sample Programs
         




function mch3
   scrollup(2)
   showprg(1)
   @ mr,mc say 'Enter System name : ' get msystem picture '@K XXXXXXXXXX'
   read                                                       
   if empty(msystem)
      return(.t.)
   endif
   scrollup(1)
   showprg(1)
   @ mr,mc say 'Enter Event name  : ' get mevent picture '@K XXXXXXXX'
   read                                                       
   if empty(mevent)
      return(.t.)
   endif

   showprg(1)
   y = capncntr(msystem,mevent)               && read contents of counter
   if y = -1
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'System '+msystem+' not authorized!'
   elseif y = -2
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Network Error!'
   elseif y = -3
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Event Counter '+mevent+' corrupted!'
   else
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Available events = ' + str(y,6)
   endif
return(.t.)


















         
         CAPTAIN                                                    Page 36
                                                            Sample Programs
         




function mch4
   scrollup(2)
   showprg(1)
   @ mr,mc say 'Enter System name : ' get msystem picture '@K XXXXXXXXXX'
   read                                                       
   if empty(msystem)
      return(.t.)
   endif
   scrollup(1)
   showprg(1)
   @ mr,mc say 'Enter Event name  : ' get mevent picture '@K XXXXXXXX'
   read                                                       
   if empty(mevent)
      return(.t.)
   endif

   showprg(1)
   y = capncntr(msystem,mevent)               && read contents of counter
   if y = -1
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'System '+msystem+' not authorized!'
      return(.t.)
   elseif y = -2
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Network Error!'
      return(.t.)
   elseif y = -3
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Event Counter '+mevent+' corrupted!'
      return(.t.)
   else
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Available events = ' + str(y,6)
   endif
















         
         CAPTAIN                                                    Page 37
                                                            Sample Programs
         




   y = y - 1
   showprg(1)
   z = capncntw(msystem,mevent,y)                && write counter
   if z = -1
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'System '+msys+' not authorized!'
   elseif z = -2
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Network Error!'
   elseif z = -3
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Error writing to Event '+mevent+'!'
   else
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Now Available    = ' + str(y,6)
   endif
return(.t.)

































         
         CAPTAIN                                                    Page 38
                                                            Sample Programs
         




function mch5
   scrollup(2)
   showprg(1)
   @ mr,mc say 'Enter System name : ' get msystem picture '@K XXXXXXXXXX'
   read                                                       
   if empty(msystem)
      return(.t.)
   endif
   scrollup(1)
   showprg(1)
   @ mr,mc say 'Enter Event name  : ' get mevent picture '@K XXXXXXXX'
   read                                                       
   if empty(mevent)
      return(.t.)
   endif
   cseed = capnget(mevent)            && get seed number
   cauth = 0
   scrollup(1)
   showprg(1)
   @ mr,mc say 'Serial number is  : '
   @ mr,mc+20 say val(cseed) picture '999 999 999 999'
   scrollup(1)
   @ mr,mc say 'Enter Authorization Number : ' 
   scrollup(1)
   @ mr,mc+20 get cauth picture '999 999 999 999'
   read
   if lastkey() = 27
      return(.t.)
   endif
   cauth = str(cauth,12)
   showprg(1)
   newevents = capncntm(mevent, cseed, cauth)
   y = capncntr(msystem,mevent)               && read contents of counter
   if y = -1
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'System '+msystem+' not authorized!'
      return(.t.)
   elseif y = -2
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Network Error!'
      return(.t.)
   elseif y = -3
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Event Counter '+mevent+' corrupted!'
      return(.t.)
   else
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Available events = ' + str(y,6)
   endif

         
         CAPTAIN                                                    Page 39
                                                            Sample Programs
         




   y = y + newevents

   showprg(1)
   z = capncntw(msystem,mevent,y)                && write counter
   if z = -1
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'System '+msys+' not authorized!'
   elseif z = -2
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Network Error!'
   elseif z = -3
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Error writing to Event '+mevent+'!'
   else
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Now Available    = ' + str(y,6)
   endif
return(.t.)       
































         
         CAPTAIN                                                    Page 40
                                                            Sample Programs
         




function mch6
   scrollup(2)
   showprg(1)
   @ mr,mc say 'Enter System name : ' get msystem picture '@K XXXXXXXXXX'
   read                                                       
   if empty(msystem)
      return(.t.)
   endif
   scrollup(1)
   showprg(1)
   @ mr,mc say 'Enter Event name  : ' get mevent picture '@K XXXXXXXX'
   read                                                       
   if empty(mevent)
      return(.t.)
   endif
   scrollup(1)
   showprg(1)
   @ mr,mc say 'Enter Event Count : ' get mcnt picture '999999'
   read                                                       
   y = mcnt

   showprg(1)
   z = capncntw(msystem,mevent,y)                && write counter
   if z = -1
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'System '+msys+' not authorized!'
   elseif z = -2
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Network Error!'
   elseif z = -3
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Error writing to Event '+mevent+'!'
   else
      showprg(-1)
      scrollup(1)
      @ mr,mc say 'Now Available    = ' + str(y,6)
   endif
return(.t.)













         
         CAPTAIN                                                    Page 41
                                                            Sample Programs
         




function scrollup
   parameters slines
   for mx = 1 to slines
      scroll(4,41,12,77,1)
      @ 12,41 clear to 12,77
   next
return(.t.)

function showprg
   parameters moffset
   prgrow = procline(1) + moffset
   keyboard chr(27)
   memoedit(mprg,15,2,22,77,.f.,,120,,prgrow)
return(.t.)

function showprg2
   parameters moffset
   prgrow = moffset
   keyboard chr(27)
   memoedit(mprg,15,2,22,77,.f.,,120,,prgrow)
return(.t.)

function prgup
   prgrow = prgrow - 1
   if prgrow < 1
      prgrow = 1
   endif            
   showprg2(prgrow)
return(.t.)

function prgdown
   prgrow = prgrow + 1
   showprg2(prgrow)
return(.t.)

function prgpgup
   prgrow = prgrow - 7
   if prgrow < 1
      prgrow = 1
   endif            
   showprg2(prgrow)
return(.t.)

function prgpgdn
   prgrow = prgrow + 7
   showprg2(prgrow)
return(.t.)










   
   CAPTAIN                                                    Page 42
                                                       Sample Programs
   




function keyson
   set key  5  to prgup                             && up arrow
   set key 24  to prgdown                           && down arrow
   set key 18  to prgpgup                           && page up
   set key  3  to prgpgdn                           && page down
return(.t.)

function keysoff
   set key  5  to 
   set key 24  to 
   set key 18  to prgpgup                           && page up
   set key  3  to prgpgdn                           && page down
return(.t.)









































         
         CAPTAIN                                                    Page 43
                                                          Licence Agreement
         



                            LICENCE AGREEMENT

    1    Definitions

         Software  shall  mean the computer program contained  in  the 
         disks in this package, together with any updates subsequently 
         provided by Think Computers

         Documentation  shall  mean  all  of  the  printed   materials 
         provided   in  this  package  or  later  supplied  by   Think 
         Computers.

         Software  copies  shall  mean  actual copies of  all  or  any 
         portion  of  the  Software  and  shall  include  updates  and 
         backups.

    2    Licence

         Think Computers agrees to grant the user a non-exclusive  and 
         non-transferable licence to use the Software contained herein 
         for  an  unlimited duration.  The rights granted  herein  are 
         limited   to  use  of  the  Software,   Software  Copies  and 
         Documentation as defined within the Agreement. All rights not 
         specifically granted in this Agreement are reserved by  Think 
         Computers.

    3    Permitted Uses

         The licensee may use the software in the following ways:

         - Load  the  software  into  RAM  and  use  it  on  a  single 
           workstation or terminal,

         - Install  the Software onto a permanent storage  device  - a 
           hard or fixed disk drive,

         - Make  copies of the software for backup purposes only,  and 
           the Licensee must keep possession of them at all times.

    4    Prohibited Uses

         The Licensee may not:

         - Distribute the Software or Documentation to others

         - Under any circumstances attempt to rewrite, decompile, dis-
           assemble   or  reverse-engineer  any  of  the  Software  or 
           Software Copies.

         - Reproduce,  transmit,  transcribe,  store  in  a  retrieval 
           system, or translate into any language the Documentation in 
           any  form by any means without the written consent  of  the 
           copywrite holders.


         
         CAPTAIN                                                    Page 44
                                                          Licence Agreement
         



    5    Limitations

         This  Licence  grants  the  user limited rights  to  use  the 
         Software,  Software  Copies  and Documentation  as  expressly 
         provided in the licence. Think Computers retains title to all 
         the Software, SOftware Copies and Documentation. The Licensee 
         agrees   to  protect  the  Software,   Software  Copies   and 
         Documentation,    from   unauthorized    publication,    use, 
         reproduction or distribution.

    6    Term

         This  licence  is  effective from the date  you  receive  the 
         Software  and Documentation,  and continues until you destroy 
         the entire contents of this package and any Software Copies.

         This  licence will terminate if the Licensee fails to  comply 
         with  any  term  or condition of  the  Agreement.  Upon  such 
         breach,  Think Computers reserves the right to terminate  the 
         licence  and seek any remedies which may be available to  the 
         company.  Upon  notice of termination,  the Licensee will  be 
         required   to   return  all  copies  of  the   Software   and 
         Documentation to Think Computers.  In these circumstances the 
         Licensee  will not be entitled to a refund of any amount paid 
         for the licence to use the the Software and Documentation.

    7    Limited Warranty

         Think  Computers warrants to the original licensee  that  the 
         original  magnetic media is free from defects in material and 
         workmanship  under normal use and service,  for a  period  of 
         thirty  (30)  days from the date of purchase as evidenced  by 
         your  receipt or invoice.  Think Computers' entire  liability 
         and  your  exclusive remedy shall be by  replacement  of  the 
         defective  disk,  provided  the  disk is  returned  to  Think 
         Computers with a copy of your dated receipt or invoice.

         Think  Computers  shall not be liable to the Licensee or  any 
         other  person for any  special,  consequential,  indirect  or 
         other similar damages or claims including loss of profits, or 
         any other commercial damage caused or imagined to have been.

         Think  Computers specifically disclaims all other warranties, 
         expressed    or   implied.    Think   Computers   makes    no 
         representations   or   warranties   with   respect   to   the 
         merchantability or fitness of the Software for any particular 
         purpose,  business  or  application.  Implied  warranties  of 
         merchantability are expressly and specifically disclaimed.

         In  no event shall Think Computers' liability for damages  to 
         you or any other person exceed the price paid for the licence 
         to use the Software, regardless of the form of the claim.



         
         CAPTAIN                                                    Page 45
                                                          Licence Agreement
         



    8    Updates and Revisions

         Think  Computers reserves the right to modify and/or  enhance 
         the  software  and its documentation  without  obligation  to 
         notify any person or organization of such changes.

    9    Acknowledgement

         You acknowledge that you have read this agreement, understand 
         it  and  agree  to  be bound by  its  terms  and  conditions. 
         Furthermore,   you  agree  that  this  is  the  complete  and 
         exclusive  statement  of agreement between us and  superseded 
         all proir agreements,  verbal or written,  any proposals  and 
         other  communications  between  us relating  to  the  subject 
         matter in this Agreement.








































         
         CAPTAIN                                                    Page 46

