home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual Foxpro 6.0 (Ent. Edition) / Vf6ent Extractor.EXE / API / SAMPLES / NEWVAR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-05-26  |  1.5 KB  |  66 lines

  1. /*
  2. **
  3. *
  4. * NEWVAR.C - Sample API routine.
  5. *
  6. * Copyright (c) 1989-1993 Microsoft Corporation as an unpublished
  7. * licensed proprietary work.  All rights reserved.
  8. *
  9. * Description:
  10. *    This is an example of an API rooutine that creates a FoxPro memory
  11. *    variable (success) via the use _NewVar.
  12. *    The variable that is created is numeric with the value of zero.
  13. *
  14. *        The variable is created in the routine SetUp using _NewVar
  15. *        then it is given a type and a value using _Store and a Value
  16. *        structure that represents an integer 0.
  17. *
  18. *               If the variable can not be created, the error is reported by
  19. *              a call to _Error.
  20. *
  21. *               The variable is released by _Release in CleanUp when unloading
  22. *              the API routine.
  23. *
  24. *
  25. */
  26.  
  27. #include  <pro_ext.h>
  28. Locator loc;
  29. Value   val;
  30.  
  31. void FAR SetUp()
  32. {
  33.         int created;
  34.  
  35.     val.ev_type='I';
  36.     val.ev_width=5;
  37.     val.ev_long=0;
  38.  
  39.     loc.l_subs=0;
  40.  
  41.         created= _NewVar("success",&loc,NV_PUBLIC);
  42.  
  43.         if(created>0)
  44.             created = _Store(&loc, &val);       /* Initialize the varible. */
  45.         else
  46.             _Error(created);            /* An error occured when creating it. */
  47.  
  48.  
  49.  
  50.  
  51. }
  52.  
  53. void FAR CleanUp()
  54. {
  55.     _Release(loc.l_NTI);
  56. }
  57. FoxInfo myFoxInfo[] ={
  58.         {"SETUP", (FPFI) SetUp, CALLONLOAD, ""},
  59.     {"CLEANUP", (FPFI) CleanUp,CALLONUNLOAD ,""},
  60. };
  61.  
  62.  
  63. FoxTable _FoxTable = {
  64.     (FoxTable FAR *)0, sizeof(myFoxInfo) / sizeof(FoxInfo), myFoxInfo
  65. };
  66.