home *** CD-ROM | disk | FTP | other *** search
/ HomeWare 14 / HOMEWARE14.bin / prog / ks94an.arj / VAR2FILE.HDR < prev    next >
Text File  |  1994-04-24  |  3KB  |  91 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _Var2File(xValue, cFileName) --> cFileName
  8.  
  9. PARAMETERS:
  10.  
  11. xValue : Any variable of type C,D,N,L or an array of elements of these types.
  12.  
  13. SHORT:
  14.  
  15. Store data variables of any type, including arrays, to file.
  16.  
  17. DESCRIPTION:
  18.  
  19. _Var2File() stores variables in a file format such that the
  20. _File2Var() function can restore them.
  21.  
  22. This makes it possible to pass data between two entirely different and
  23. separate programs.  Of course, this same thing might be easily done with a
  24. database file or .MEM file, but then again, that would require a database to
  25. exist, or a .MEM file (ruling out LOCALS being passed).  Besides, neither of
  26. these two methods could pass a LOCAL multi-dimentional, multi-data-type array
  27. intact to another program *at runtime!*
  28.  
  29. Variables may also be arrays, and arrays can be of mixed types and
  30. multi dimensional.
  31.  
  32. If the file name is not specified, then a file name of the first
  33. eight characters of the calling proc or function are used as the default
  34. file name and an extension of ".V2F" is given.
  35.  
  36. NOTE:
  37.  
  38. _Var2File() will ignore any variable or any array element that is
  39. not character, numeric, date, logical or another array of the same!!
  40.  
  41. Code blocks are right out!  Same for Memos and "objects."
  42.  
  43. Any attempt to use _Var2File() with these unsupported data types will
  44. render unpredictable results and incur the wrath of the terrible and
  45. fearsome DP/IS gods who will exact such horrendous punishment on you that
  46. you will ever despair of using undocumented features again.  You have
  47. been warned!
  48.  
  49. EXAMPLE:
  50.  
  51. cData = "ABC"
  52.  
  53. _Var2File(cData,"FILE.EXT")
  54.  
  55. Result: a disk file called FILE.EXT is created and contains "ABC" in a
  56. format that can later be read by _File2Var().
  57.  
  58.  
  59. Example - allowing current proc/func name to name the target file:
  60. *****************************************************************
  61.  
  62. #define ENGAGE(x)  _Var2File(x)
  63.  
  64. FUNCTION EngageWarp(nWarpFactor)
  65. LOCAL    cData = "Make it so, Number One!"
  66.  
  67. _Var2File(cData,"DIRECTIVE.DAT")
  68.  
  69. ENGAGE(nWarpFactor)
  70.  
  71. RETURN(NIL)
  72.  
  73. *****************************************************************
  74.  
  75. In this example, the variable "cData" ends up in a file called
  76. DIRECTIV.DAT, because that's where we told it to put it.  But,
  77. nWarpFactor ends up in a different file that derives it's name from the
  78. name of the procedure/function that called it (which in this case, happens
  79. to be: ENGAGEWA.V2F.)
  80.  
  81. (If you do not see this, note that the #define statement will
  82. be preprocessesed into _Var2File(x) - Thus, even if the file name
  83. was specified, it would be ignored because the PP will not pass it to
  84. the actual _Var2File() function. And any time that you do not specify the
  85. file name, the default file name applies.)
  86.  
  87. Note that sucessive calls specifying the same file name overwrite any
  88. existing file by that name.
  89.  
  90. ******************************************************************************/
  91.