PageRenderTime 63ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/Spss/SpssThinWrapper.cs

#
C# | 3465 lines | 543 code | 214 blank | 2708 comment | 7 complexity | 74346f8ced511f804400947569d80be8 MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. using System;
  2. using System.Runtime.InteropServices;
  3. using System.IO;
  4. using System.Diagnostics;
  5. using System.Runtime.CompilerServices;
  6. namespace Spss
  7. {
  8. #region Enumerables
  9. /// <summary>
  10. /// Error/warning codes that calls to SPSS methods can return.
  11. /// </summary>
  12. public enum ReturnCode : int
  13. {
  14. /// <summary>
  15. /// No error
  16. /// </summary>
  17. SPSS_OK = 0,
  18. #region Error codes that calls to SPSS methods can return.
  19. /// <summary>
  20. /// Error opening file
  21. /// </summary>
  22. SPSS_FILE_OERROR = 1,
  23. /// <summary>
  24. /// File write error
  25. /// </summary>
  26. SPSS_FILE_WERROR = 2,
  27. /// <summary>
  28. /// Error reading the file
  29. /// </summary>
  30. SPSS_FILE_RERROR = 3,
  31. /// <summary>
  32. /// File table full (too many open SPSS data files)
  33. /// </summary>
  34. SPSS_FITAB_FULL = 4,
  35. /// <summary>
  36. /// The file handle is not valid
  37. /// </summary>
  38. SPSS_INVALID_HANDLE = 5,
  39. /// <summary>
  40. /// Data file contains no variables
  41. /// </summary>
  42. SPSS_INVALID_FILE = 6,
  43. /// <summary>
  44. /// Insufficient memory
  45. /// </summary>
  46. SPSS_NO_MEMORY = 7,
  47. /// <summary>
  48. /// File is open for reading, not writing
  49. /// </summary>
  50. SPSS_OPEN_RDMODE = 8,
  51. /// <summary>
  52. /// The file is open for writing, not reading
  53. /// </summary>
  54. SPSS_OPEN_WRMODE = 9,
  55. /// <summary>
  56. /// The variable name is not valid
  57. /// </summary>
  58. SPSS_INVALID_VARNAME = 10,
  59. /// <summary>
  60. /// No variables defined in the dictionary
  61. /// </summary>
  62. SPSS_DICT_EMPTY = 11,
  63. /// <summary>
  64. /// A variable with the given name does not exist
  65. /// </summary>
  66. SPSS_VAR_NOTFOUND = 12,
  67. /// <summary>
  68. /// There is already a variable with the same name
  69. /// </summary>
  70. SPSS_DUP_VAR = 13,
  71. /// <summary>
  72. /// The variable is not numeric
  73. /// OR
  74. /// At least one variable in the list is not numeric
  75. /// OR
  76. /// The specified variable has string values
  77. /// </summary>
  78. SPSS_NUME_EXP = 14,
  79. /// <summary>
  80. /// The variable is numeric
  81. /// </summary>
  82. SPSS_STR_EXP = 15,
  83. /// <summary>
  84. /// The variable is a long string (length > 8)
  85. /// </summary>
  86. SPSS_SHORTSTR_EXP = 16,
  87. /// <summary>
  88. /// Invalid length code (varLength is negative or
  89. /// exceeds 255)
  90. /// </summary>
  91. SPSS_INVALID_VARTYPE = 17,
  92. /// <summary>
  93. /// Invalid missing values specification ( missingFormat
  94. /// is invalid or the lower limit of range is greater than the
  95. /// upper limit)
  96. /// </summary>
  97. SPSS_INVALID_MISSFOR = 18,
  98. /// <summary>
  99. /// Invalid compression switch (other than 0 or 1)
  100. /// </summary>
  101. SPSS_INVALID_COMPSW = 19,
  102. /// <summary>
  103. /// The print format specification is invalid or is
  104. /// incompatible with the variable type
  105. /// </summary>
  106. SPSS_INVALID_PRFOR = 20,
  107. /// <summary>
  108. /// The write format specification is invalid or is
  109. /// incompatible with the variable type
  110. /// </summary>
  111. SPSS_INVALID_WRFOR = 21,
  112. /// <summary>
  113. /// Invalid date
  114. /// OR
  115. /// The date value (spssDate) is negative
  116. /// </summary>
  117. SPSS_INVALID_DATE = 22,
  118. /// <summary>
  119. /// Invalid time
  120. /// </summary>
  121. SPSS_INVALID_TIME = 23,
  122. /// <summary>
  123. /// Fewer than two variables in list
  124. /// OR
  125. /// Number of variables ( numVars) is zero or negative
  126. /// </summary>
  127. SPSS_NO_VARIABLES = 24,
  128. /// <summary>
  129. /// The list of values contains duplicates
  130. /// </summary>
  131. SPSS_DUP_VALUE = 27,
  132. /// <summary>
  133. /// The given case weight variable is invalid. This error
  134. /// signals an internal problem in the implementation
  135. /// of the DLL and should never occur.
  136. /// </summary>
  137. SPSS_INVALID_CASEWGT = 28,
  138. /// <summary>
  139. /// Dictionary has already been written with
  140. /// spssCommitHeader
  141. /// </summary>
  142. SPSS_DICT_COMMIT = 30,
  143. /// <summary>
  144. /// Dictionary of the output file has not yet been written
  145. /// with <see cref="SpssThinWrapper.spssCommitHeaderDelegate"/>.
  146. /// </summary>
  147. SPSS_DICT_NOTCOMMIT = 31,
  148. /// <summary>
  149. /// File is not a valid SPSS data file (no type 2 record)
  150. /// </summary>
  151. SPSS_NO_TYPE2 = 33,
  152. /// <summary>
  153. /// There is no type7, subtype3 record present. This
  154. /// code should be regarded as a warning even though
  155. /// it is positive. Files without this record are valid.
  156. /// </summary>
  157. SPSS_NO_TYPE73 = 41,
  158. /// <summary>
  159. /// The date variable information is invalid
  160. /// </summary>
  161. SPSS_INVALID_DATEINFO = 45,
  162. /// <summary>
  163. /// File is not a valid SPSS data file (missing type 999
  164. /// record)
  165. /// </summary>
  166. SPSS_NO_TYPE999 = 46,
  167. /// <summary>
  168. /// The value is longer than the length of the variable
  169. /// </summary>
  170. SPSS_EXC_STRVALUE = 47,
  171. /// <summary>
  172. /// Unable to free because arguments are illegal or
  173. /// inconsistent (for example, negative numLabels)
  174. /// </summary>
  175. SPSS_CANNOT_FREE = 48,
  176. /// <summary>
  177. /// Buffer value is too short to hold the value
  178. /// </summary>
  179. SPSS_BUFFER_SHORT = 49,
  180. /// <summary>
  181. /// Current case is not valid. This may be because no
  182. /// spssReadCaseRecord calls have been made yet or
  183. /// because the most recent call failed with error or encountered
  184. /// the end of file.
  185. /// </summary>
  186. SPSS_INVALID_CASE = 50,
  187. /// <summary>
  188. /// Internal data structures of the DLL are invalid. This
  189. /// signals an error in the DLL.
  190. /// </summary>
  191. SPSS_INTERNAL_VLABS = 51,
  192. /// <summary>
  193. /// File created on an incompatible system.
  194. /// </summary>
  195. SPSS_INCOMPAT_APPEND = 52,
  196. /// <summary>
  197. /// Undocumented by SPSS.
  198. /// </summary>
  199. SPSS_INTERNAL_D_A = 53,
  200. /// <summary>
  201. /// Error accessing the temporary file
  202. /// </summary>
  203. SPSS_FILE_BADTEMP = 54,
  204. /// <summary>
  205. /// spssGetDEWFirst was never called
  206. /// </summary>
  207. SPSS_DEW_NOFIRST = 55,
  208. /// <summary>
  209. /// measureLevel is not in the legal range, or is
  210. /// SPSS_MLVL_RAT and the variable is a string variable.
  211. /// </summary>
  212. SPSS_INVALID_MEASURELEVEL = 56,
  213. /// <summary>
  214. /// Parameter subtype not between 1 and
  215. /// MAX7SUBTYPE
  216. /// </summary>
  217. SPSS_INVALID_7SUBTYPE = 57,
  218. /// <summary>
  219. /// Existing multiple response set definitions are invalid
  220. /// </summary>
  221. SPSS_INVALID_MRSETDEF = 70,
  222. /// <summary>
  223. /// The multiple response set name is invalid
  224. /// </summary>
  225. SPSS_INVALID_MRSETNAME = 71,
  226. /// <summary>
  227. /// The multiple response set name is a duplicate
  228. /// </summary>
  229. SPSS_DUP_MRSETNAME = 72,
  230. /// <summary>
  231. /// Undocumented by SPSS.
  232. /// </summary>
  233. SPSS_BAD_EXTENSION = 73,
  234. #endregion
  235. #region Warning codes returned by functions
  236. /// <summary>
  237. /// Label length exceeds 64, truncated and used (warning)
  238. /// </summary>
  239. SPSS_EXC_LEN64 = -1,
  240. /// <summary>
  241. /// Variable label’s length exceeds 120, truncated and
  242. /// used (warning)
  243. /// </summary>
  244. SPSS_EXC_LEN120 = -2,
  245. /// <summary>
  246. /// ... (warning)
  247. /// </summary>
  248. SPSS_EXC_VARLABEL = -2,
  249. /// <summary>
  250. /// Label length exceeds 60, truncated and used (warning)
  251. /// </summary>
  252. SPSS_EXC_LEN60 = -4,
  253. /// <summary>
  254. /// ... (warning)
  255. /// </summary>
  256. SPSS_EXC_VALLABEL = -4,
  257. /// <summary>
  258. /// End of the file reached, no more cases (warning)
  259. /// </summary>
  260. SPSS_FILE_END = -5,
  261. /// <summary>
  262. /// There is no variable sets information in the file (warning)
  263. /// </summary>
  264. SPSS_NO_VARSETS = -6,
  265. /// <summary>
  266. /// The variable sets information is empty (warning)
  267. /// </summary>
  268. SPSS_EMPTY_VARSETS = -7,
  269. /// <summary>
  270. /// The variable has no labels (warning) (warning)
  271. /// </summary>
  272. SPSS_NO_LABELS = -8,
  273. /// <summary>
  274. /// There is no label for the given value (warning)
  275. /// </summary>
  276. SPSS_NO_LABEL = -9,
  277. /// <summary>
  278. /// A case weight variable has not been defined for this file (warning)
  279. /// </summary>
  280. SPSS_NO_CASEWGT = -10,
  281. /// <summary>
  282. /// There is no TRENDS date variable information in the file (warning)
  283. /// </summary>
  284. SPSS_NO_DATEINFO = -11,
  285. /// <summary>
  286. /// No definitions on the file (warning)
  287. /// </summary>
  288. SPSS_NO_MULTRESP = -12,
  289. /// <summary>
  290. /// The string contains no definitions (warning)
  291. /// </summary>
  292. SPSS_EMPTY_MULTRESP = -13,
  293. /// <summary>
  294. /// File contains no DEW information (warning)
  295. /// </summary>
  296. SPSS_NO_DEW = -14,
  297. /// <summary>
  298. /// Zero bytes to be written (warning)
  299. /// </summary>
  300. SPSS_EMPTY_DEW = -15,
  301. #endregion
  302. }
  303. /// <summary>
  304. /// Missing Value Type codes
  305. /// </summary>
  306. public enum MissingValueFormatCode : int
  307. {
  308. /// <summary>
  309. /// Indicates that no discrete missing values will be defined.
  310. /// </summary>
  311. SPSS_NO_MISSVAL = 0,
  312. /// <summary>
  313. /// Indicates that 1 discrete missing values will be defined.
  314. /// </summary>
  315. SPSS_ONE_MISSVAL = 1,
  316. /// <summary>
  317. /// Indicates that 2 discrete missing values will be defined.
  318. /// </summary>
  319. SPSS_TWO_MISSVAL = 2,
  320. /// <summary>
  321. /// Indicates that 3 discrete missing values will be defined.
  322. /// </summary>
  323. SPSS_THREE_MISSVAL = 3,
  324. /// <summary>
  325. /// missingVal1 and missingVal2 are taken as the upper and lower limits,
  326. /// respectively, of the range, and missingVal3 is ignored
  327. /// </summary>
  328. SPSS_MISS_RANGE = -2,
  329. /// <summary>
  330. /// missingval1 and missingVal2 are taken as limits of the range and missingVal3 is taken
  331. /// as the discrete missing value.
  332. /// </summary>
  333. SPSS_MISS_RANGEANDVAL = -3,
  334. }
  335. /// <summary>
  336. /// Format Type codes
  337. /// </summary>
  338. public enum FormatTypeCode : int
  339. {
  340. /// <summary>
  341. /// Alphanumeric
  342. /// </summary>
  343. SPSS_FMT_A = 1,
  344. /// <summary>
  345. /// Alphanumeric hexadecimal
  346. /// </summary>
  347. SPSS_FMT_AHEX = 2,
  348. /// <summary>
  349. /// F Format with commas
  350. /// </summary>
  351. SPSS_FMT_COMMA = 3,
  352. /// <summary>
  353. /// Commas and floating dollar sign
  354. /// </summary>
  355. SPSS_FMT_DOLLAR = 4,
  356. /// <summary>
  357. /// Default Numeric Format
  358. /// </summary>
  359. SPSS_FMT_F = 5,
  360. /// <summary>
  361. /// Int16 binary
  362. /// </summary>
  363. SPSS_FMT_IB = 6,
  364. /// <summary>
  365. /// Positive Int16 binary - hex
  366. /// </summary>
  367. SPSS_FMT_PIBHEX = 7,
  368. /// <summary>
  369. /// Packed decimal
  370. /// </summary>
  371. SPSS_FMT_P = 8,
  372. /// <summary>
  373. /// Positive Int16 binary unsigned
  374. /// </summary>
  375. SPSS_FMT_PIB = 9,
  376. /// <summary>
  377. /// Positive Int16 binary unsigned
  378. /// </summary>
  379. SPSS_FMT_PK = 10,
  380. /// <summary>
  381. /// Floating poInt32 binary
  382. /// </summary>
  383. SPSS_FMT_RB = 11,
  384. /// <summary>
  385. /// Floating poInt32 binary hex
  386. /// </summary>
  387. SPSS_FMT_RBHEX = 12,
  388. /// <summary>
  389. /// Zoned decimal
  390. /// </summary>
  391. SPSS_FMT_Z = 15,
  392. /// <summary>
  393. /// N Format- unsigned with leading 0s
  394. /// </summary>
  395. SPSS_FMT_N = 16,
  396. /// <summary>
  397. /// E Format- with explicit power of 10
  398. /// </summary>
  399. SPSS_FMT_E = 17,
  400. /// <summary>
  401. /// Date format dd-mmm-yyyy
  402. /// </summary>
  403. SPSS_FMT_DATE = 20,
  404. /// <summary>
  405. /// Time format hh:mm:ss.s
  406. /// </summary>
  407. SPSS_FMT_TIME = 21,
  408. /// <summary>
  409. /// Date and Time
  410. /// </summary>
  411. SPSS_FMT_DATE_TIME = 22,
  412. /// <summary>
  413. /// Date format dd-mmm-yyyy
  414. /// </summary>
  415. SPSS_FMT_ADATE = 23,
  416. /// <summary>
  417. /// Julian date - yyyyddd
  418. /// </summary>
  419. SPSS_FMT_JDATE = 24,
  420. /// <summary>
  421. /// Date-time dd hh:mm:ss.s
  422. /// </summary>
  423. SPSS_FMT_DTIME = 25,
  424. /// <summary>
  425. /// Day of the week
  426. /// </summary>
  427. SPSS_FMT_WKDAY = 26,
  428. /// <summary>
  429. /// Month
  430. /// </summary>
  431. SPSS_FMT_MONTH = 27,
  432. /// <summary>
  433. /// mmm yyyy
  434. /// </summary>
  435. SPSS_FMT_MOYR = 28,
  436. /// <summary>
  437. /// q Q yyyy
  438. /// </summary>
  439. SPSS_FMT_QYR = 29,
  440. /// <summary>
  441. /// ww WK yyyy
  442. /// </summary>
  443. SPSS_FMT_WKYR = 30,
  444. /// <summary>
  445. /// Percent - F followed by %
  446. /// </summary>
  447. SPSS_FMT_PCT = 31,
  448. /// <summary>
  449. /// Like COMMA, switching dot for comma
  450. /// </summary>
  451. SPSS_FMT_DOT = 32,
  452. /// <summary>
  453. /// User Programmable currency format
  454. /// </summary>
  455. SPSS_FMT_CCA = 33,
  456. /// <summary>
  457. /// User Programmable currency format
  458. /// </summary>
  459. SPSS_FMT_CCB = 34,
  460. /// <summary>
  461. /// User Programmable currency format
  462. /// </summary>
  463. SPSS_FMT_CCC = 35,
  464. /// <summary>
  465. /// User Programmable currency format
  466. /// </summary>
  467. SPSS_FMT_CCD = 36,
  468. /// <summary>
  469. /// User Programmable currency format
  470. /// </summary>
  471. SPSS_FMT_CCE = 37,
  472. /// <summary>
  473. /// Date in dd/mm/yyyy style
  474. /// </summary>
  475. SPSS_FMT_EDATE = 38,
  476. /// <summary>
  477. /// Date in yyyy/mm/dd style
  478. /// </summary>
  479. SPSS_FMT_SDATE = 39,
  480. }
  481. /// <summary>
  482. /// Measurement Level codes
  483. /// </summary>
  484. public enum MeasurementLevelCode : int
  485. {
  486. /// <summary>
  487. /// Unknown
  488. /// </summary>
  489. SPSS_MLVL_UNK = 0,
  490. /// <summary>
  491. /// Nominal
  492. /// </summary>
  493. SPSS_MLVL_NOM = 1,
  494. /// <summary>
  495. /// Ordinal
  496. /// </summary>
  497. SPSS_MLVL_ORD = 2,
  498. /// <summary>
  499. /// Scale (Ratio)
  500. /// </summary>
  501. SPSS_MLVL_RAT = 3,
  502. }
  503. /// <summary>
  504. /// Alignment codes
  505. /// </summary>
  506. public enum AlignmentCode : int
  507. {
  508. /// <summary>
  509. /// Left aligned
  510. /// </summary>
  511. SPSS_ALIGN_LEFT = 0,
  512. /// <summary>
  513. /// Right aligned
  514. /// </summary>
  515. SPSS_ALIGN_RIGHT = 1,
  516. /// <summary>
  517. /// Centered
  518. /// </summary>
  519. SPSS_ALIGN_CENTER = 2,
  520. }
  521. /// <summary>
  522. /// Diagnostics regarding var names
  523. /// </summary>
  524. public enum VarNameDiagnostic : int
  525. {
  526. /// <summary>
  527. /// Valid standard name
  528. /// </summary>
  529. SPSS_NAME_OK = 0,
  530. /// <summary>
  531. /// Valid scratch var name
  532. /// </summary>
  533. SPSS_NAME_SCRATCH = 1,
  534. /// <summary>
  535. /// Valid system var name
  536. /// </summary>
  537. SPSS_NAME_SYSTEM = 2,
  538. /// <summary>
  539. /// Empty or longer than SPSS_MAX_VARNAME
  540. /// </summary>
  541. SPSS_NAME_BADLTH = 3,
  542. /// <summary>
  543. /// Invalid character or imbedded blank
  544. /// </summary>
  545. SPSS_NAME_BADCHAR = 4,
  546. /// <summary>
  547. /// Name is a reserved word
  548. /// </summary>
  549. SPSS_NAME_RESERVED = 5,
  550. /// <summary>
  551. /// Invalid initial character
  552. /// </summary>
  553. SPSS_NAME_BADFIRST = 6,
  554. }
  555. /// <summary>
  556. /// Definitions of "type 7" records
  557. /// </summary>
  558. public enum Type7Record : int
  559. {
  560. /// <summary>
  561. /// Documents (actually type 6
  562. /// </summary>
  563. SPSS_T7_DOCUMENTS = 0,
  564. /// <summary>
  565. /// VAX Data Entry - dictionary version
  566. /// </summary>
  567. SPSS_T7_VAXDE_DICT = 1,
  568. /// <summary>
  569. /// VAX Data Entry - data
  570. /// </summary>
  571. SPSS_T7_VAXDE_DATA = 2,
  572. /// <summary>
  573. /// Source system characteristics
  574. /// </summary>
  575. SPSS_T7_SOURCE = 3,
  576. /// <summary>
  577. /// Source system floating pt constants
  578. /// </summary>
  579. SPSS_T7_HARDCONST = 4,
  580. /// <summary>
  581. /// Variable sets
  582. /// </summary>
  583. SPSS_T7_VARSETS = 5,
  584. /// <summary>
  585. /// Trends date information
  586. /// </summary>
  587. SPSS_T7_TRENDS = 6,
  588. /// <summary>
  589. /// Multiple response groups
  590. /// </summary>
  591. SPSS_T7_MULTRESP = 7,
  592. /// <summary>
  593. /// Windows Data Entry data
  594. /// </summary>
  595. SPSS_T7_DEW_DATA = 8,
  596. /// <summary>
  597. /// TextSmart data
  598. /// </summary>
  599. SPSS_T7_TEXTSMART = 10,
  600. /// <summary>
  601. /// Msmt level, col width, &amp; alignment
  602. /// </summary>
  603. SPSS_T7_MSMTLEVEL = 11,
  604. /// <summary>
  605. /// Windows Data Entry GUID
  606. /// </summary>
  607. SPSS_T7_DEW_GUID = 12,
  608. /// <summary>
  609. /// Extended variable names
  610. /// </summary>
  611. SPSS_T7_XVARNAMES = 13,
  612. }
  613. #endregion
  614. /// <summary>
  615. /// A very thin SpssSafeWrapper that provides access to all the functions
  616. /// exposed from the SPSSIO*.dll library provided with SPSS 20.
  617. /// </summary>
  618. // <remarks>
  619. // <para>Each method in SPSSIO32/64.DLL is represented exactly once by this class.</para>
  620. // <para>Those methods that require the use of pointers for memory management
  621. // reasons are marked <c>unsafe</c>, and have <c>protected</c> access for
  622. // proper handling by a descending class.
  623. // Those methods that require string marshaling are marked <c>protected</c>,
  624. // because they require special string buffers to be created and trimmed for
  625. // correct access.
  626. // Both types of protected methods should be wrapped and appropriately
  627. // handled by a <see cref="SpssSafeWrapper"/>descending class</see>.</para>
  628. // </remarks>
  629. public class SpssThinWrapper
  630. {
  631. //Locations of the 32 bit spss and support dll's relative to the applications directory.
  632. const String spssio32 = @"win32\spssio32.dll";
  633. //Location of the 64 bit spss and support dll's relative to the applications directory.
  634. const String spssio64 = @"win64\spssio64.dll";
  635. #region Maximum lengths of SPSS data file objects
  636. /// <summary>
  637. /// Maximum length of a variable name
  638. /// </summary>
  639. public const int SPSS_MAX_VARNAME = 64;
  640. /// <summary>
  641. /// Short (compatibility) variable name.
  642. /// </summary>
  643. public const int SPSS_MAX_SHORTVARNAME = 8;
  644. /// <summary>
  645. /// Maximum length of a short string variable
  646. /// </summary>
  647. public const int SPSS_MAX_SHORTSTRING = 8;
  648. /// <summary>
  649. /// Maximum length of a file label string
  650. /// </summary>
  651. public const int SPSS_MAX_IDSTRING = 64;
  652. /// <summary>
  653. /// (old) Maximum length of a long string variable
  654. /// </summary>
  655. public const int SPSS_MAX_LONGSTRING = 255;
  656. /// <summary>
  657. /// Maximum length of a long string variable.
  658. /// </summary>
  659. public const int SPSS_MAX_VERYLONGSTRING = 32 * 1024;
  660. /// <summary>
  661. /// Maximum length of a value label
  662. /// </summary>
  663. public const int SPSS_MAX_VALLABEL = 60;
  664. /// <summary>
  665. /// Maximum length of a variable label
  666. /// </summary>
  667. public const int SPSS_MAX_VARLABEL = 256;
  668. /// <summary>
  669. /// Maximum record 7 subtype
  670. /// </summary>
  671. public const int SPSS_MAX_7SUBTYPE = 32;
  672. #endregion
  673. /// <summary>
  674. /// Closes an SPSS file that was opened using <see cref="spssOpenAppendDelegate"/>.
  675. /// </summary>
  676. /// <param name="handle">
  677. /// Handle to the data file.
  678. /// </param>
  679. /// <returns>
  680. /// <see cref="ReturnCode.SPSS_OK"/>,
  681. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  682. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>, or
  683. /// <see cref="ReturnCode.SPSS_FILE_WERROR"/>.
  684. /// </returns>
  685. /// <remarks>
  686. /// This function closes the data file associated with handle, which must have been opened
  687. /// for appending cases using <see cref="spssOpenAppendDelegate"/>. The file handle handle becomes invalid
  688. /// and no further operations can be performed using it.
  689. /// </remarks>
  690. public delegate ReturnCode spssCloseAppendDelegate(int handle);
  691. public static spssCloseAppendDelegate spssCloseAppendImpl;
  692. /// <summary>
  693. /// Closes an SPSS file that was opened using <see cref="spssOpenReadDelegate"/>.
  694. /// </summary>
  695. /// <param name="handle"></param>
  696. /// <returns>
  697. /// <see cref="ReturnCode.SPSS_OK"/>,
  698. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  699. /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>.
  700. /// </returns>
  701. /// <remarks>
  702. /// This function closes the data file associated with handle, which must have been opened
  703. /// for reading using <see cref="spssOpenReadDelegate"/>. The file handle handle becomes
  704. /// invalid and no further operations can be performed using it.
  705. /// </remarks>
  706. public delegate ReturnCode spssCloseReadDelegate(int handle);
  707. public static spssCloseReadDelegate spssCloseReadImpl;
  708. /// <summary>
  709. /// Closes an SPSS file that was opened using <see cref="spssOpenWriteDelegate"/>.
  710. /// </summary>
  711. /// <param name="handle"></param>
  712. /// <returns>
  713. /// <see cref="ReturnCode.SPSS_OK"/>,
  714. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  715. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  716. /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>, or
  717. /// <see cref="ReturnCode.SPSS_FILE_WERROR"/>.
  718. /// </returns>
  719. /// <remarks>
  720. /// This function closes the data file associated with handle, which must have been opened
  721. /// for writing using <see cref="spssOpenWriteDelegate"/>. The file handle handle becomes invalid
  722. /// and no further operations can be performed using it.
  723. /// </remarks>
  724. public delegate ReturnCode spssCloseWriteDelegate(int handle);
  725. public static spssCloseWriteDelegate spssCloseWriteImpl;
  726. /// <summary>
  727. /// Writes a case to an SPSS data file after its values have been set.
  728. /// </summary>
  729. /// <param name="handle"></param>
  730. /// <returns>
  731. /// <see cref="ReturnCode.SPSS_OK"/>,
  732. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  733. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  734. /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>, or
  735. /// <see cref="ReturnCode.SPSS_FILE_WERROR"/>.
  736. /// </returns>
  737. /// <remarks>
  738. /// This function writes a case to the data file specified by the handle. It must be called after
  739. /// setting the values of variables through <see cref="spssSetValueNumericDelegate"/> and
  740. /// <see cref="spssSetValueCharDelegate"/>.
  741. /// Any variables left unset will get the system-missing value if they are numeric and all
  742. /// blanks if they are strings. Unless spssCommitCaseRecord is called, the case will not be
  743. /// written out.
  744. /// </remarks>
  745. public delegate ReturnCode spssCommitCaseRecordDelegate(int handle);
  746. public static spssCommitCaseRecordDelegate spssCommitCaseRecordImpl;
  747. /// <summary>
  748. /// Writes the data dictionary to the data file. To be used after dictionary defining
  749. /// functions are called, and before cases are written.
  750. /// </summary>
  751. /// <param name="handle"></param>
  752. /// <returns>
  753. /// <see cref="ReturnCode.SPSS_OK"/>,
  754. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  755. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  756. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  757. /// <see cref="ReturnCode.SPSS_DICT_EMPTY"/>,
  758. /// <see cref="ReturnCode.SPSS_FILE_WERROR"/>,
  759. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>, or
  760. /// <see cref="ReturnCode.SPSS_INTERNAL_VLABS"/>.
  761. /// </returns>
  762. /// <remarks>
  763. /// This function writes the data dictionary to the data file associated with handle. Before
  764. /// any case data can be written, the dictionary must be committed; once the dictionary has
  765. /// been committed, no further changes can be made to it.
  766. /// </remarks>
  767. public delegate ReturnCode spssCommitHeaderDelegate(int handle);
  768. public static spssCommitHeaderDelegate spssCommitHeaderImpl;
  769. /// <summary>
  770. /// Converts a day/month/year into SPSS format.
  771. /// </summary>
  772. /// <returns>
  773. /// <see cref="ReturnCode.SPSS_OK"/>, or
  774. /// <see cref="ReturnCode.SPSS_INVALID_DATE"/>.
  775. /// </returns>
  776. /// <remarks>
  777. /// This function converts a Gregorian date expressed as day-month-year to the internal
  778. /// SPSS date format. The time portion of the date variable is set to 0:00. To set the time
  779. /// portion of the date variable to another value, use spssConvertTime and add the resulting
  780. /// value to *spssDate. Dates before October 15, 1582, are considered invalid.
  781. /// </remarks>
  782. public delegate ReturnCode spssConvertDateDelegate(int day, int month, int year, out double spssDate);
  783. public static spssConvertDateDelegate spssConvertDateImpl;
  784. /// <summary>
  785. /// Extracts the date from an SPSS date field.
  786. /// </summary>
  787. /// <returns>
  788. /// <see cref="ReturnCode.SPSS_OK"/>, or
  789. /// <see cref="ReturnCode.SPSS_INVALID_DATE"/>.
  790. /// </returns>
  791. /// <remarks>
  792. /// This function converts the date (as distinct from time) portion of a value in internal SPSS
  793. /// date format to Gregorian style.
  794. /// </remarks>
  795. public delegate ReturnCode spssConvertSPSSDateDelegate(out int day, out int month, out int year, double spssDate);
  796. public static spssConvertSPSSDateDelegate spssConvertSPSSDateImpl;
  797. /// <summary>
  798. /// Extracts the time of day from an SPSS date field.
  799. /// </summary>
  800. /// <returns>
  801. /// <see cref="ReturnCode.SPSS_OK"/>, or
  802. /// <see cref="ReturnCode.SPSS_INVALID_TIME"/>.
  803. /// </returns>
  804. /// <remarks>
  805. /// This function breaks a value in internal SPSS date format into a day number (since October
  806. /// 14, 1582) plus the hour, minute, and second values. Note that the seconds value is
  807. /// stored in a double since it may have a fractional part.
  808. /// </remarks>
  809. public delegate ReturnCode spssConvertSPSSTimeDelegate(out int day, out int hourh, out int minute, out double second, double spssDate);
  810. public static spssConvertSPSSTimeDelegate spssConvertSPSSTimeImpl;
  811. /// <summary>
  812. /// Converts a time of day to the SPSS time format.
  813. /// </summary>
  814. /// <returns>
  815. /// <see cref="ReturnCode.SPSS_OK"/>, or
  816. /// <see cref="ReturnCode.SPSS_INVALID_TIME"/>.
  817. /// </returns>
  818. /// <remarks>
  819. /// This function converts a time given as day, hours, minutes, and seconds to the internal
  820. /// SPSS format. The day value is the number of days since October 14, 1582, and is typically
  821. /// zero, especially when this function is used in conjunction with spssConvertDate.
  822. /// Note that the seconds value is stored in a double since it may have a fractional part.
  823. /// </remarks>
  824. public delegate ReturnCode spssConvertTimeDelegate(int day, int hour, int minute, double second, out double spssTime);
  825. public static spssConvertTimeDelegate spssConvertTimeImpl;
  826. /// <summary>
  827. /// Copies stored documents from one file to another.
  828. /// </summary>
  829. /// <returns>
  830. /// <see cref="ReturnCode.SPSS_OK"/>,
  831. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  832. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>, or
  833. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>.
  834. /// </returns>
  835. /// <remarks>
  836. /// This function copies stored documents, if any, from the file associated with fromHandle
  837. /// to that associated with toHandle. The latter must be open for output. If the target file already
  838. /// has documents, they are discarded. If the source file has no documents, the target
  839. /// will be set to have none, too.
  840. /// </remarks>
  841. public delegate ReturnCode spssCopyDocumentsDelegate(int fromHandle, int toHandle);
  842. public static spssCopyDocumentsDelegate spssCopyDocumentsImpl;
  843. /// <summary>
  844. /// Frees memory allocated by <see cref="spssGetDateVariablesDelegate"/>.
  845. /// </summary>
  846. /// <param name="dateInfo">
  847. /// Vector of date variable indexes.
  848. /// </param>
  849. /// <returns>
  850. /// Always returns <see cref="ReturnCode.SPSS_OK"/> indicating success.
  851. /// </returns>
  852. /// <remarks>
  853. /// This function is called to return the memory allocated by <see cref="spssGetDateVariablesDelegate"/>.
  854. /// </remarks>
  855. [CLSCompliant(false)]
  856. unsafe protected delegate ReturnCode spssFreeDateVariablesDelegate(int* dateInfo);
  857. [CLSCompliant(false)]
  858. protected static spssFreeDateVariablesDelegate spssFreeDateVariablesImpl;
  859. /// <summary>
  860. /// Frees memory allocated by <see cref="spssGetMultRespDefsDelegate"/>.
  861. /// </summary>
  862. /// <param name="mrespDefs">
  863. /// ASCII string containing the definitions.
  864. /// </param>
  865. /// <returns>
  866. /// The function always succeeds and always returns <see cref="ReturnCode.SPSS_OK"/>.
  867. /// </returns>
  868. /// <remarks>
  869. /// This function releases the memory which was acquired by <see cref="spssGetMultRespDefsDelegate"/>.
  870. /// </remarks>
  871. [CLSCompliant(false)]
  872. unsafe protected delegate ReturnCode spssFreeMultRespDefsDelegate(char* mrespDefs);
  873. [CLSCompliant(false)]
  874. protected static spssFreeMultRespDefsDelegate spssFreeMultRespDefsImpl;
  875. /// <summary>
  876. /// Frees memory allocated by <see cref="spssGetVarCValueLabelsDelegate"/>.
  877. /// </summary>
  878. /// <param name="values">
  879. /// Array of pointers to values returned by <see cref="spssGetVarCValueLabelsDelegate"/>
  880. /// </param>
  881. /// <param name="labels">
  882. /// Array of pointers to labels returned by <see cref="spssGetVarCValueLabelsDelegate"/>
  883. /// </param>
  884. /// <param name="numLabels">
  885. /// Number of values or labels returned by <see cref="spssGetVarCValueLabelsDelegate"/>
  886. /// </param>
  887. /// <returns>
  888. /// <see cref="ReturnCode.SPSS_OK"/> or
  889. /// <see cref="ReturnCode.SPSS_CANNOT_FREE"/>
  890. /// </returns>
  891. /// <remarks>
  892. /// This function frees the two arrays and the value and label strings allocated on the heap
  893. /// by <see cref="spssGetVarCValueLabelsDelegate"/>.
  894. /// </remarks>
  895. [CLSCompliant(false)]
  896. unsafe protected delegate ReturnCode spssFreeVarCValueLabelsDelegate(char** values, char** labels, int numLabels);
  897. [CLSCompliant(false)]
  898. protected static spssFreeVarCValueLabelsDelegate spssFreeVarCValueLabelsImpl;
  899. /// <summary>
  900. /// Frees memory allocated by <see cref="spssGetVariableSetsDelegate"/>.
  901. /// </summary>
  902. /// <param name="varSets">
  903. /// The string defining the variable sets
  904. /// </param>
  905. /// <returns>
  906. /// Always returns <see cref="ReturnCode.SPSS_OK"/> indicating success.
  907. /// </returns>
  908. /// <remarks>
  909. /// This function is called to return the memory allocated by <see cref="spssGetVariableSetsDelegate"/>.
  910. /// </remarks>
  911. [CLSCompliant(false)]
  912. unsafe protected delegate ReturnCode spssFreeVariableSetsDelegate(char* varSets);
  913. [CLSCompliant(false)]
  914. protected static spssFreeVariableSetsDelegate spssFreeVariableSetsImpl;
  915. /// <summary>
  916. /// Frees memory allocated by <see cref="spssGetVarNamesDelegate"/>.
  917. /// </summary>
  918. /// <param name="varNames">
  919. /// Array of pointers to names returned by <see cref="spssGetVarNamesDelegate"/>
  920. /// </param>
  921. /// <param name="varTypes">
  922. /// Array of variable types returned by <see cref="spssGetVarNamesDelegate"/>
  923. /// </param>
  924. /// <param name="numVars">
  925. /// Number of variables returned by <see cref="spssGetVarNamesDelegate"/>
  926. /// </param>
  927. /// <returns>
  928. /// <see cref="ReturnCode.SPSS_OK"/> or
  929. /// <see cref="ReturnCode.SPSS_CANNOT_FREE"/>.
  930. /// </returns>
  931. /// <remarks>
  932. /// This function frees the two arrays and the name strings allocated on the heap by
  933. /// <see cref="spssGetVarNamesDelegate"/>.
  934. /// </remarks>
  935. [CLSCompliant(false)]
  936. unsafe protected delegate ReturnCode spssFreeVarNamesDelegate(char** varNames, int* varTypes, int numVars);
  937. [CLSCompliant(false)]
  938. protected static spssFreeVarNamesDelegate spssFreeVarNamesImpl;
  939. /// <summary>
  940. /// Frees memory allocated by <see cref="spssGetVarNValueLabelsDelegate"/>.
  941. /// </summary>
  942. /// <param name="values">
  943. /// Array of values returned by <see cref="spssGetVarNValueLabelsDelegate"/>
  944. /// </param>
  945. /// <param name="labels">
  946. /// Array of pointers to labels returned by <see cref="spssGetVarNValueLabelsDelegate"/>
  947. /// </param>
  948. /// <param name="numLabels">
  949. /// Number of values or labels returned by <see cref="spssGetVarNValueLabelsDelegate"/>
  950. /// </param>
  951. /// <returns>
  952. /// <see cref="ReturnCode.SPSS_OK"/> or
  953. /// <see cref="ReturnCode.SPSS_CANNOT_FREE"/>
  954. /// </returns>
  955. /// <remarks>
  956. /// This function frees the two arrays and the value and label strings allocated on the heap
  957. /// by <see cref="spssGetVarCValueLabelsDelegate"/>.
  958. /// </remarks>
  959. [CLSCompliant(false)]
  960. unsafe protected delegate ReturnCode spssFreeVarNValueLabelsDelegate(double* values, char** labels, int numLabels);
  961. [CLSCompliant(false)]
  962. protected static spssFreeVarNValueLabelsDelegate spssFreeVarNValueLabels;
  963. /// <summary>
  964. /// Reports the number of bytes taken up by any one case.
  965. /// </summary>
  966. /// <param name="handle">
  967. /// Handle to the data file
  968. /// </param>
  969. /// <param name="caseSize">
  970. /// Pointer to size of case in bytes
  971. /// </param>
  972. /// <returns>
  973. /// <see cref="ReturnCode.SPSS_OK"/>,
  974. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  975. /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>.
  976. /// </returns>
  977. /// <remarks>
  978. /// This function reports the size of a raw case record for the file associated with handle.
  979. /// The case size is reported in bytes and is meant to be used in conjunction with the lowlevel
  980. /// case input/output procedures <see cref="spssWholeCaseInDelegate"/> and
  981. /// <see cref="spssWholeCaseOutDelegate"/>.
  982. /// </remarks>
  983. public delegate ReturnCode spssGetCaseSizeDelegate(int handle, out int caseSize);
  984. public static spssGetCaseSizeDelegate spssGetCaseSizeImpl;
  985. /// <summary>
  986. /// Reports the name of the case weight variable.
  987. /// </summary>
  988. /// <param name="handle">
  989. /// Handle to the data file
  990. /// </param>
  991. /// <param name="varName">
  992. /// Pointer to the buffer to hold name of the case weight variable
  993. /// </param>
  994. /// <returns>
  995. /// <see cref="ReturnCode.SPSS_OK"/>,
  996. /// <see cref="ReturnCode.SPSS_NO_CASEWGT"/>,
  997. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  998. /// <see cref="ReturnCode.SPSS_INVALID_CASEWGT"/>.
  999. /// </returns>
  1000. /// <remarks>
  1001. /// This function reports the name of the case weight variable. The name is copied to the
  1002. /// buffer pointed to by varName as a null-terminated string. Since a variable name can be
  1003. /// up to <see cref="SPSS_MAX_VARNAME"/> characters in length, the size of the buffer
  1004. /// must be at least <see cref="SPSS_MAX_VARNAME"/>+1.
  1005. /// </remarks>
  1006. protected delegate ReturnCode spssGetCaseWeightVarDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName);
  1007. protected static spssGetCaseWeightVarDelegate spssGetCaseWeightVarImpl;
  1008. /// <summary>
  1009. /// Gets the compression attribute of a data file.
  1010. /// </summary>
  1011. /// <param name="handle">
  1012. /// Handle to the data file
  1013. /// </param>
  1014. /// <param name="compSwitch">
  1015. /// Pointer to compression attribute. Upon return, *compSwitch is 1 if
  1016. /// the file is compressed; 0 otherwise.
  1017. /// </param>
  1018. /// <returns>
  1019. /// <see cref="ReturnCode.SPSS_OK"/> or
  1020. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
  1021. /// </returns>
  1022. /// <remarks>
  1023. /// This function reports the compression attribute of an SPSS data file.
  1024. /// </remarks>
  1025. public delegate ReturnCode spssGetCompressionDelegate(int handle, out int compSwitch);
  1026. public static spssGetCompressionDelegate spssGetCompressionImpl;
  1027. /// <summary>
  1028. /// Reports TRENDS date variable information.
  1029. /// </summary>
  1030. /// <param name="handle">
  1031. /// Handle to the data file
  1032. /// </param>
  1033. /// <param name="numofElements">
  1034. /// Number of elements in allocated array
  1035. /// </param>
  1036. /// <param name="dateInfo">
  1037. /// Pointer to first element of the allocated array
  1038. /// </param>
  1039. /// <returns>
  1040. /// <see cref="ReturnCode.SPSS_OK"/>,
  1041. /// <see cref="ReturnCode.SPSS_NO_DATEINFO"/>,
  1042. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  1043. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  1044. /// </returns>
  1045. /// <remarks>
  1046. /// This function reports the TRENDS date variable information, if any, in an SPSS data file.
  1047. /// It places the information in a dynamically allocated long array, sets *numofElements to
  1048. /// the number of elements in the array, and sets *dateInfo to point to the array. The caller is
  1049. /// expected to free the array by calling <see cref="spssFreeDateVariablesDelegate"/> when it is no longer needed.
  1050. /// The variable information is copied directly from record 7, subtype 3. Its first six elements
  1051. /// comprise the "fixed" information, followed by a sequence of one or more three-element
  1052. /// groups.
  1053. /// </remarks>
  1054. [CLSCompliant(false)]
  1055. unsafe protected delegate ReturnCode spssGetDateVariablesDelegate(int handle, out int numofElements, out int* dateInfo);
  1056. [CLSCompliant(false)]
  1057. protected static spssGetDateVariablesDelegate spssGetDateVariablesImpl;
  1058. /// <summary>
  1059. /// Retrieves the first block of SPSS Data Entry information from a data file.
  1060. /// </summary>
  1061. /// <param name="handle">
  1062. /// Handle to the data file
  1063. /// </param>
  1064. /// <param name="data">
  1065. /// Returned as data from the file
  1066. /// </param>
  1067. /// <param name="maxData">
  1068. /// Maximum bytes to return
  1069. /// </param>
  1070. /// <param name="nData">
  1071. /// Returned as number of bytes returned
  1072. /// </param>
  1073. /// <returns>
  1074. /// <see cref="ReturnCode.SPSS_OK"/>,
  1075. /// <see cref="ReturnCode.SPSS_NO_DEW"/>,
  1076. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  1077. /// <see cref="ReturnCode.SPSS_FILE_BADTEMP"/>.
  1078. /// </returns>
  1079. /// <remarks>
  1080. /// The client can retrieve DEW information (file information that is private to the SPSS
  1081. /// Data Entry product) from a file in whatever increments are convenient. The first such
  1082. /// increment is retrieved by calling spssGetDEWFirst, and subsequent segments are
  1083. /// retrieved by calling spssGetDEWNext as many times as necessary. As with
  1084. /// spssGetDEWInfo, spssGetDEWFirst will return SPSS_NO_DEW if the file was written
  1085. /// with a byte order that is the reverse of that of the host.
  1086. /// </remarks>
  1087. protected delegate ReturnCode spssGetDEWFirstDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string data, int maxData, out int nData);
  1088. protected static spssGetDEWFirstDelegate spssGetDEWFirstImpl;
  1089. /// <summary>
  1090. /// Gets the Data Entry GUID from a data file.
  1091. /// </summary>
  1092. /// <param name="handle">
  1093. /// Handle to the data file
  1094. /// </param>
  1095. /// <param name="asciiGUID">
  1096. /// Returned as the file's GUID in character form or a null string if the
  1097. /// file contains no GUID
  1098. /// </param>
  1099. /// <returns>
  1100. /// <see cref="ReturnCode.SPSS_OK"/> or
  1101. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
  1102. /// </returns>
  1103. /// <remarks>
  1104. /// Data Entry for Windows maintains a GUID in character form as a uniqueness indicator.
  1105. /// Two files have identical dictionaries and DEW information if they have the same
  1106. /// GUID. Note that the spssOpenWriteCopy function will not copy the source file’s
  1107. /// GUID. spssGetDEWGUID allows the client to read a file’s GUID, if any. The client
  1108. /// supplies a 257 byte string in which the null-terminated GUID is returned.
  1109. /// </remarks>
  1110. protected delegate ReturnCode spssGetDEWGUIDDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string asciiGUID);
  1111. protected static spssGetDEWGUIDDelegate spssGetDEWGUIDImpl;
  1112. /// <summary>
  1113. /// Gets the length and hash of the Data Entry information in a data file.
  1114. /// </summary>
  1115. /// <param name="handle">
  1116. /// Handle to the data file
  1117. /// </param>
  1118. /// <param name="Length">
  1119. /// Returned as the length in bytes
  1120. /// </param>
  1121. /// <param name="HashTotal">
  1122. /// Returned as the hash total
  1123. /// </param>
  1124. /// <returns>
  1125. /// <see cref="ReturnCode.SPSS_OK"/>,
  1126. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  1127. /// <see cref="ReturnCode.SPSS_NO_DEW"/>.
  1128. /// </returns>
  1129. /// <remarks>
  1130. /// This function can be called before actually retrieving DEW information (file
  1131. /// information that is private to the SPSS Data Entry product) from a file, to obtain some
  1132. /// attributes of that information--specifically its length in bytes and its hash total. The
  1133. /// hash total is, by convention, contained in the last four bytes to be written. Because it is
  1134. /// not cognizant of the structure of the DEW information, the I/O DLL is unable to correct
  1135. /// the byte order of numeric information generated on a foreign host. As a result, the
  1136. /// DEW information is discarded if the file has a byte order that is the reverse of that of
  1137. /// the host, and calls to spssGetDEWInfo will return SPSS_NO_DEW.
  1138. /// </remarks>
  1139. public delegate ReturnCode spssGetDEWInfoDelegate(int handle, out int Length, out int HashTotal);
  1140. public static spssGetDEWInfoDelegate spssGetDEWInfoImpl;
  1141. /// <summary>
  1142. /// Retrieves the next block of SPSS Data Entry information from a data file.
  1143. /// </summary>
  1144. /// <param name="handle">
  1145. /// Handle to the data file
  1146. /// </param>
  1147. /// <param name="data">
  1148. /// Returned as data from the file
  1149. /// </param>
  1150. /// <param name="maxData">
  1151. /// Maximum bytes to return
  1152. /// </param>
  1153. /// <param name="nData">
  1154. /// Returned as number of bytes returned
  1155. /// </param>
  1156. /// <returns>
  1157. /// <see cref="ReturnCode.SPSS_OK"/>,
  1158. /// <see cref="ReturnCode.SPSS_DEW_NOFIRST"/>,
  1159. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  1160. /// <see cref="ReturnCode.SPSS_FILE_BADTEMP"/>.
  1161. /// </returns>
  1162. /// <remarks>
  1163. /// The client can retrieve DEW information (file information that is private to the SPSS
  1164. /// Data Entry product) from a file in whatever increments are convenient. The first such
  1165. /// increment is retrieved by calling <see cref="spssGetDEWFirstDelegate"/>, and subsequent segments are
  1166. /// retrieved by calling spssGetDEWNext as many times as necessary. As with
  1167. /// <see cref="spssGetDEWInfoDelegate"/>, <see cref="spssGetDEWFirstDelegate"/> will return SPSS_NO_DEW if the file was written
  1168. /// with a byte order that is the reverse of that of the host.
  1169. /// </remarks>
  1170. protected delegate ReturnCode spssGetDEWNextDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string data, int maxData, out int nData);
  1171. protected static spssGetDEWNextDelegate spssGetDEWNextImpl;
  1172. /// <summary>
  1173. /// Estimates number of cases in a data file.
  1174. /// </summary>
  1175. /// <param name="handle">
  1176. /// Handle to the data file
  1177. /// </param>
  1178. /// <param name="caseCount">
  1179. /// Returned as estimated n of cases
  1180. /// </param>
  1181. /// <returns>
  1182. /// <see cref="ReturnCode.SPSS_OK"/>,
  1183. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1184. /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>, or
  1185. /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>.
  1186. /// </returns>
  1187. /// <remarks>
  1188. /// Although not strictly required for direct access input, this function helps in reading
  1189. /// SPSS data files from releases earlier than 6.0. Some of these data files did not contain
  1190. /// number of cases information, and <see cref="spssGetNumberofCasesDelegate"/> will return -1 cases. This
  1191. /// function will return a precise number for uncompressed files and an estimate (based on
  1192. /// overall file size) for compressed files. It cannot be used on files open for appending data.
  1193. /// </remarks>
  1194. public delegate ReturnCode spssGetEstimatedNofCasesDelegate(int handle, out int caseCount);
  1195. public static spssGetEstimatedNofCasesDelegate spssGetEstimatedNofCasesImpl;
  1196. /// <summary>
  1197. /// Gets the number of cases in a data file.
  1198. /// </summary>
  1199. /// <param name="handle">
  1200. /// Handle to the data file
  1201. /// </param>
  1202. /// <param name="caseCount">
  1203. /// Pointer to number of cases
  1204. /// </param>
  1205. /// <returns>
  1206. /// <see cref="ReturnCode.SPSS_OK"/>,
  1207. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  1208. /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>.
  1209. /// </returns>
  1210. /// <remarks>
  1211. /// This function reports the number of cases present in a data file open for reading.
  1212. /// </remarks>
  1213. public delegate ReturnCode spssGetNumberofCasesDelegate(int handle, out int caseCount);
  1214. public static spssGetNumberofCasesDelegate spssGetNumberofCasesImpl;
  1215. /// <summary>
  1216. /// Gets the file label of a data file.
  1217. /// </summary>
  1218. /// <param name="handle">
  1219. /// Handle to the data file
  1220. /// </param>
  1221. /// <param name="id">
  1222. /// File label buffer
  1223. /// </param>
  1224. /// <returns>
  1225. /// <see cref="ReturnCode.SPSS_OK"/> or
  1226. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
  1227. /// </returns>
  1228. /// <remarks>
  1229. /// This function copies the file label of the SPSS data file associated with <paramref>handle</paramref> into the
  1230. /// buffer pointed to by id. The label is at most 64 characters long and null-terminated.
  1231. /// Thus, the size of the buffer should be at least 65. If an input data file is associated with
  1232. /// the handle, the label will be exactly 64 characters long, padded with blanks as
  1233. /// necessary.
  1234. /// </remarks>
  1235. protected delegate ReturnCode spssGetIdStringDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string id);
  1236. protected static spssGetIdStringDelegate spssGetIdStringImpl;
  1237. /// <summary>
  1238. /// Retrieves the definitions from a data file.
  1239. /// </summary>
  1240. /// <param name="handle">
  1241. /// Handle to the data file
  1242. /// </param>
  1243. /// <param name="mrespDefs">
  1244. /// Returned as a pointer to a string
  1245. /// </param>
  1246. /// <returns>
  1247. /// <see cref="ReturnCode.SPSS_OK"/>,
  1248. /// <see cref="ReturnCode.SPSS_NO_MULTRESP"/>,
  1249. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  1250. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  1251. /// </returns>
  1252. /// <remarks>
  1253. /// This function retrieves the definitions from an SPSS data file. The definitions are stored
  1254. /// as a null-terminated ASCII string which is very similar to that containing the variable
  1255. /// set definitions. The memory allocated by this function to contain the string must be freed
  1256. /// by calling <see cref="spssFreeMultRespDefsDelegate"/>. If the file contains no multiple response definitions,
  1257. /// *mrespDefs is set to NULL, and the function returns the warning code
  1258. /// <see cref="ReturnCode.SPSS_NO_MULTRESP"/>.
  1259. /// </remarks>
  1260. [CLSCompliant(false)]
  1261. unsafe protected delegate ReturnCode spssGetMultRespDefsDelegate(int handle, out char* mrespDefs);
  1262. [CLSCompliant(false)]
  1263. protected static spssGetMultRespDefsDelegate spssGetMultRespDefsImpl;
  1264. /// <summary>
  1265. /// Gets the number of variables in a data file.
  1266. /// </summary>
  1267. /// <param name="handle">
  1268. /// Handle to the data file
  1269. /// </param>
  1270. /// <param name="numVars">
  1271. /// Pointer to number of variables
  1272. /// </param>
  1273. /// <returns>
  1274. /// <see cref="ReturnCode.SPSS_OK"/>,
  1275. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1276. /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>, or
  1277. /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>.
  1278. /// </returns>
  1279. /// <remarks>
  1280. /// This function reports the number of variables present in a data file.
  1281. /// </remarks>
  1282. public delegate ReturnCode spssGetNumberofVariablesDelegate(int handle, out int numVars);
  1283. public static spssGetNumberofVariablesDelegate spssGetNumberofVariables;
  1284. /// <summary>
  1285. /// Gets information on the running version of SPSS, and the hosting computer.
  1286. /// </summary>
  1287. /// <param name="handle">
  1288. /// Handle to the data file.
  1289. /// </param>
  1290. /// <param name="relInfo">
  1291. /// Array of int in which release- and machine-specific data will be
  1292. /// stored. This array must have at least eight elements.
  1293. /// </param>
  1294. /// <returns>
  1295. /// <see cref="ReturnCode.SPSS_OK"/>,
  1296. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  1297. /// <see cref="ReturnCode.SPSS_NO_TYPE73"/>.
  1298. /// </returns>
  1299. /// <remarks>
  1300. /// This function reports release- and machine-specific information about the file
  1301. /// associated with handle. The information consists of an array of eight int values copied
  1302. /// from record type 7, subtype 3 of the file, and is useful primarily for debugging. The
  1303. /// array elements are, in order, release number (index 0), release subnumber (1), special
  1304. /// release identifier number (2), machine code (3), floating-point representation code (4),
  1305. /// compression scheme code (5), big/little-endian code (6), and character representation
  1306. /// code (7).
  1307. /// </remarks>
  1308. protected delegate ReturnCode spssGetReleaseInfoDelegate(int handle, [MarshalAs(UnmanagedType.LPArray, SizeConst = 8)] int[] relInfo);
  1309. protected static spssGetReleaseInfoDelegate spssGetReleaseInfoImpl;
  1310. /// <summary>
  1311. /// Gets the name of the system that created a data file.
  1312. /// </summary>
  1313. /// <param name="handle">
  1314. /// Handle to the data file
  1315. /// </param>
  1316. /// <param name="sysName">
  1317. /// The originating system name
  1318. /// </param>
  1319. /// <returns>
  1320. /// <see cref="ReturnCode.SPSS_OK"/> or
  1321. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
  1322. /// </returns>
  1323. /// <remarks>
  1324. /// This function returns the name of the system under which the file was created. It is a
  1325. /// 40-byte blank-padded character field corresponding to the last 40 bytes of record type
  1326. /// 1. Thus, in order to accommodate the information, the parameter
  1327. /// <paramref>sysName</paramref> must be at least 41 bytes in length plus the
  1328. /// terminating null character.
  1329. /// </remarks>
  1330. protected delegate ReturnCode spssGetSystemStringDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string sysName);
  1331. protected static spssGetSystemStringDelegate spssGetSystemStringImpl;
  1332. /// <summary>
  1333. /// Gets the data created by TextSmart.
  1334. /// </summary>
  1335. /// <param name="handle">
  1336. /// Handle to the data file
  1337. /// </param>
  1338. /// <param name="textInfo">
  1339. /// Buffer for text data
  1340. /// </param>
  1341. /// <returns>
  1342. /// <see cref="ReturnCode.SPSS_OK"/> or
  1343. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
  1344. /// </returns>
  1345. /// <remarks>
  1346. /// This function places the text data created by TextSmart as a null-terminated string in
  1347. /// the user-supplied buffer <paramref>textInfo</paramref>. The buffer is assumed to be
  1348. /// at least 256 characters long; the text data may be up to 255 characters long.
  1349. /// If text data are not present in the file, the first character in
  1350. /// <paramref>textInfo</paramref> is set to NULL.
  1351. /// </remarks>
  1352. protected delegate ReturnCode spssGetTextInfoDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string textInfo);
  1353. protected static spssGetTextInfoDelegate spssGetTextInfoImpl;
  1354. /// <summary>
  1355. /// Gets the creation date of a data file, as recorded in the file itself.
  1356. /// </summary>
  1357. /// <param name="handle">
  1358. /// Handle to the data file
  1359. /// </param>
  1360. /// <param name="fileDate">
  1361. /// File creation dat…

Large files files are truncated, but you can click here to view the full file