PageRenderTime 34ms CodeModel.GetById 16ms 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
  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 date
  1362. /// </param>
  1363. /// <param name="fileTime">
  1364. /// File creation time
  1365. /// </param>
  1366. /// <returns>
  1367. /// <see cref="ReturnCode.SPSS_OK"/> or
  1368. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
  1369. /// </returns>
  1370. /// <remarks>
  1371. /// This function returns the creation date of the file as recorded in the file itself. The creation
  1372. /// date is a null-terminated 9-byte character field in dd mmm yy format (27 Feb 96),
  1373. /// and the receiving field must be at least 10 bytes in length. The creation time is a nullterminated
  1374. /// 8-byte character field in hh:mm:ss format (13:12:15), and the receiving field
  1375. /// must be at least 9 bytes in length.
  1376. /// </remarks>
  1377. protected delegate ReturnCode spssGetTimeStampDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string fileDate, [MarshalAs(UnmanagedType.VBByRefStr)] ref string fileTime);
  1378. protected static spssGetTimeStampDelegate spssGetTimeStampImpl;
  1379. /// <summary>
  1380. /// Gets the string value of a variable.
  1381. /// </summary>
  1382. /// <param name="handle">
  1383. /// Handle to the data file
  1384. /// </param>
  1385. /// <param name="varHandle">
  1386. /// Handle of the variable
  1387. /// </param>
  1388. /// <param name="value">
  1389. /// Buffer for the value of the string variable
  1390. /// </param>
  1391. /// <param name="valueSize">
  1392. /// Size of value
  1393. /// </param>
  1394. /// <returns>
  1395. /// <see cref="ReturnCode.SPSS_OK"/>,
  1396. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1397. /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>,
  1398. /// <see cref="ReturnCode.SPSS_INVALID_CASE"/>,
  1399. /// <see cref="ReturnCode.SPSS_STR_EXP"/>, or
  1400. /// <see cref="ReturnCode.SPSS_BUFFER_SHORT"/>.
  1401. /// </returns>
  1402. /// <remarks>
  1403. /// This function gets the value of a string variable for the current case, which is the case
  1404. /// read by the most recent call to <see cref="spssReadCaseRecordDelegate"/>.
  1405. /// The value is returned as a null-terminated
  1406. /// string in the caller-provided buffer value; the length of the string is the length
  1407. /// of the string variable. Argument valueSize is the allocated size of the buffer value,
  1408. /// which must be at least the length of the variable plus 1.
  1409. /// </remarks>
  1410. protected delegate ReturnCode spssGetValueCharDelegate(int handle, double varHandle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string value, int valueSize);
  1411. protected static spssGetValueCharDelegate spssGetValueCharImpl;
  1412. /// <summary>
  1413. /// Gets the numeric value of a variable.
  1414. /// </summary>
  1415. /// <param name="handle">
  1416. /// Handle to the data file
  1417. /// </param>
  1418. /// <param name="varHandle">
  1419. /// Handle of the variable
  1420. /// </param>
  1421. /// <param name="value">
  1422. /// Pointer to the value of the numeric variable
  1423. /// </param>
  1424. /// <returns>
  1425. /// <see cref="ReturnCode.SPSS_OK"/>,
  1426. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1427. /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>,
  1428. /// <see cref="ReturnCode.SPSS_INVALID_CASE"/>, or
  1429. /// <see cref="ReturnCode.SPSS_NUME_EXP"/>.
  1430. /// </returns>
  1431. /// <remarks>
  1432. /// This function gets the value of a numeric variable for the current case, which is the case
  1433. /// read by the most recent call to <see cref="spssReadCaseRecordDelegate"/>.
  1434. /// </remarks>
  1435. public delegate ReturnCode spssGetValueNumericDelegate(int handle, double varHandle, out double value);
  1436. public static spssGetValueNumericDelegate spssGetValueNumericImpl;
  1437. /// <summary>
  1438. /// Gets the alignment of a variable.
  1439. /// </summary>
  1440. /// <param name="handle">
  1441. /// Handle to the data file
  1442. /// </param>
  1443. /// <param name="varName">
  1444. /// Variable name
  1445. /// </param>
  1446. /// <param name="alignment">
  1447. /// Pointer to alignment.
  1448. /// Set to <see cref="AlignmentCode.SPSS_ALIGN_LEFT"/>,
  1449. /// <see cref="AlignmentCode.SPSS_ALIGN_RIGHT"/>, or
  1450. /// <see cref="AlignmentCode.SPSS_ALIGN_CENTER"/>
  1451. /// </param>
  1452. /// <returns>
  1453. /// <see cref="ReturnCode.SPSS_OK"/>,
  1454. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1455. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
  1456. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  1457. /// </returns>
  1458. /// <remarks>
  1459. /// This function reports the value of the alignment attribute of a variable.
  1460. /// </remarks>
  1461. protected delegate ReturnCode spssGetVarAlignmentDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out AlignmentCode alignment);
  1462. protected static spssGetVarAlignmentDelegate spssGetVarAlignmentImpl;
  1463. /// <summary>
  1464. /// Gets the missing values of a short string variable.
  1465. /// </summary>
  1466. /// <param name="handle">
  1467. /// Handle to the data file
  1468. /// </param>
  1469. /// <param name="varName">
  1470. /// Variable name
  1471. /// </param>
  1472. /// <param name="missingFormat">
  1473. /// Pointer to missing value format code
  1474. /// </param>
  1475. /// <param name="missingVal1">
  1476. /// Buffer for first missing value
  1477. /// </param>
  1478. /// <param name="missingVal2">
  1479. /// Buffer for second missing value
  1480. /// </param>
  1481. /// <param name="missingVal3">
  1482. /// Buffer for third missing value
  1483. /// </param>
  1484. /// <returns>
  1485. /// <see cref="ReturnCode.SPSS_OK"/>,
  1486. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1487. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  1488. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  1489. /// <see cref="ReturnCode.SPSS_STR_EXP"/>, or
  1490. /// <see cref="ReturnCode.SPSS_SHORTSTR_EXP"/>.
  1491. /// </returns>
  1492. /// <remarks>
  1493. /// This function reports the missing values of a short string variable. The value of
  1494. /// *<paramref>missingFormat</paramref> will be in the range 0–3, indicating
  1495. /// the number of missing values. The
  1496. /// appropriate number of missing values is copied to the buffers <paramref>missingVal1</paramref>,
  1497. /// <paramref>missingVal2</paramref>, and <paramref>missingVal3</paramref>.
  1498. /// The lengths of the null-terminated missing value strings
  1499. /// will be the length of the short string variable in question. Since the latter can be at most
  1500. /// 8 characters long, 9-character buffers are adequate for any short string variable.
  1501. /// </remarks>
  1502. protected delegate ReturnCode spssGetVarCMissingValuesDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out MissingValueFormatCode missingFormat, [MarshalAs(UnmanagedType.VBByRefStr)] ref string missingVal1, [MarshalAs(UnmanagedType.VBByRefStr)] ref string missingVal2, [MarshalAs(UnmanagedType.VBByRefStr)] ref string missingVal3);
  1503. protected static spssGetVarCMissingValuesDelegate spssGetVarCMissingValuesImpl;
  1504. /// <summary>
  1505. /// Gets the width of a variable.
  1506. /// </summary>
  1507. /// <param name="handle">
  1508. /// Handle to the data file
  1509. /// </param>
  1510. /// <param name="varName">
  1511. /// Variable name
  1512. /// </param>
  1513. /// <param name="columnWidth">
  1514. /// Pointer to column width. Non-negative
  1515. /// </param>
  1516. /// <returns>
  1517. /// <see cref="ReturnCode.SPSS_OK"/>,
  1518. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1519. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
  1520. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  1521. /// </returns>
  1522. /// <remarks>
  1523. /// This function reports the value of the column width attribute of a variable. A value of
  1524. /// zero is special and means that the SPSS Data Editor, which is the primary user of this
  1525. /// attribute, will set an appropriate width using its own algorithm.
  1526. /// </remarks>
  1527. protected delegate ReturnCode spssGetVarColumnWidthDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out int columnWidth);
  1528. protected static spssGetVarColumnWidthDelegate spssGetVarColumnWidthImpl;
  1529. /// <summary>
  1530. /// Gets the value label for a variable.
  1531. /// </summary>
  1532. /// <param name="handle">
  1533. /// Handle to the data file
  1534. /// </param>
  1535. /// <param name="varName">
  1536. /// Variable name
  1537. /// </param>
  1538. /// <param name="value">
  1539. /// Short string value for which the label is wanted
  1540. /// </param>
  1541. /// <param name="label">
  1542. /// Label for the value
  1543. /// </param>
  1544. /// <returns>
  1545. /// <see cref="ReturnCode.SPSS_OK"/>,
  1546. /// <see cref="ReturnCode.SPSS_NO_LABELS"/>,
  1547. /// <see cref="ReturnCode.SPSS_NO_LABEL"/>,
  1548. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1549. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  1550. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  1551. /// <see cref="ReturnCode.SPSS_STR_EXP"/>,
  1552. /// <see cref="ReturnCode.SPSS_SHORTSTR_EXP"/>, or
  1553. /// <see cref="ReturnCode.SPSS_EXC_STRVALUE"/>.
  1554. /// </returns>
  1555. /// <remarks>
  1556. /// This function gets the value label for a given value of a short string variable. The label is
  1557. /// copied as a null-terminated string into the buffer label, whose size must be at least 61 to
  1558. /// hold the longest possible value label (60 characters plus the null terminator). To get value
  1559. /// labels more than 60 characters long, use the <see cref="spssGetVarCValueLabelLongDelegate"/> function.
  1560. /// </remarks>
  1561. protected delegate ReturnCode spssGetVarCValueLabelDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, [MarshalAs(UnmanagedType.VBByRefStr)] ref string value, [MarshalAs(UnmanagedType.VBByRefStr)] ref string label);
  1562. protected static spssGetVarCValueLabelDelegate spssGetVarCValueLabelImpl;
  1563. /// <summary>
  1564. /// Gets a value label of a string variable.
  1565. /// </summary>
  1566. /// <param name="handle">
  1567. /// Handle to the data file
  1568. /// </param>
  1569. /// <param name="varName">
  1570. /// Null-terminated variable name
  1571. /// </param>
  1572. /// <param name="value">
  1573. /// Null-terminated value for which label is requested
  1574. /// </param>
  1575. /// <param name="labelBuff">
  1576. /// Returned as null-terminated label
  1577. /// </param>
  1578. /// <param name="lenBuff">
  1579. /// Overall size of labelBuff in bytes
  1580. /// </param>
  1581. /// <param name="lenLabel">
  1582. /// Returned as bytes stored excluding terminator
  1583. /// </param>
  1584. /// <returns>
  1585. /// <see cref="ReturnCode.SPSS_OK"/>,
  1586. /// <see cref="ReturnCode.SPSS_NO_LABELS"/>,
  1587. /// <see cref="ReturnCode.SPSS_NO_LABEL"/>,
  1588. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1589. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  1590. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  1591. /// <see cref="ReturnCode.SPSS_STR_EXP"/>,
  1592. /// <see cref="ReturnCode.SPSS_SHORTSTR_EXP"/>, or
  1593. /// <see cref="ReturnCode.SPSS_EXC_STRVALUE"/>.
  1594. /// </returns>
  1595. /// <remarks>
  1596. /// This function returns a null-terminated value label corresponding to one value of a
  1597. /// specified variable whose values are short strings. The function permits the client to
  1598. /// limit the number of bytes (including the null terminator) stored and returns the number
  1599. /// of data bytes (excluding the null terminator) actually stored. If an error is detected, the
  1600. /// label is returned as a null string, and the length is returned as 0.
  1601. /// </remarks>
  1602. protected delegate ReturnCode spssGetVarCValueLabelLongDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, [MarshalAs(UnmanagedType.VBByRefStr)] ref string value, [MarshalAs(UnmanagedType.VBByRefStr)] ref string labelBuff, int lenBuff, out int lenLabel);
  1603. protected static spssGetVarCValueLabelLongDelegate spssGetVarCValueLabelLongImpl;
  1604. /// <summary>
  1605. /// Gets the list of response values and labels for a variable.
  1606. /// </summary>
  1607. /// <param name="handle">
  1608. /// Handle to the data file
  1609. /// </param>
  1610. /// <param name="varName">
  1611. /// Variable name
  1612. /// </param>
  1613. /// <param name="values">
  1614. /// Pointer to array of pointers to values
  1615. /// </param>
  1616. /// <param name="labels">
  1617. /// Pointer to array of pointers to labels
  1618. /// </param>
  1619. /// <param name="numLabels">
  1620. /// Pointer to number of values or labels
  1621. /// </param>
  1622. /// <returns>
  1623. /// <see cref="ReturnCode.SPSS_OK"/>,
  1624. /// <see cref="ReturnCode.SPSS_NO_LABELS"/>,
  1625. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1626. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  1627. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  1628. /// <see cref="ReturnCode.SPSS_STR_EXP"/>,
  1629. /// <see cref="ReturnCode.SPSS_SHORTSTR_EXP"/>, or
  1630. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  1631. /// </returns>
  1632. /// <remarks>
  1633. /// This function gets the set of labeled values and associated labels for a short string variable.
  1634. /// The number of values is returned as *numLabels. Values are stored into an array
  1635. /// of *numLabels pointers, each pointing to a char string containing a null-terminated
  1636. /// value, and *values is set to point to the first element of the array. Each value string is as
  1637. /// long as the variable. The corresponding labels are structured as an array of *numLabels
  1638. /// pointers, each pointing to a char string containing a null-terminated label, and *labels is
  1639. /// set to point to the first element of the array.
  1640. /// The two arrays and the value and label strings are allocated on the heap. When they
  1641. /// are no longer needed, <see cref="spssFreeVarCValueLabelsDelegate"/> should be called to free the memory.
  1642. /// </remarks>
  1643. [CLSCompliant(false)]
  1644. unsafe protected delegate ReturnCode spssGetVarCValueLabelsDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out char** values, out char** labels, out int numLabels);
  1645. [CLSCompliant(false)]
  1646. protected static spssGetVarCValueLabelsDelegate spssGetVarCValueLabelsImpl;
  1647. /// <summary>
  1648. /// Gets the handle for a named variable.
  1649. /// </summary>
  1650. /// <param name="handle">
  1651. /// Handle to the data file
  1652. /// </param>
  1653. /// <param name="varName">
  1654. /// Variable name
  1655. /// </param>
  1656. /// <param name="varHandle">
  1657. /// Pointer to handle for the variable. Note that the variable handle is
  1658. /// a double, and not int or long.
  1659. /// </param>
  1660. /// <returns>
  1661. /// <see cref="ReturnCode.SPSS_OK"/>,
  1662. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1663. /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>,
  1664. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  1665. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
  1666. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  1667. /// </returns>
  1668. /// <remarks>
  1669. /// This function returns a handle for a variable, which can then be used to read or write
  1670. /// (depending on how the file was opened) values of the variable. If handle is associated
  1671. /// with an output file, the dictionary must be written with <see cref="spssCommitHeaderDelegate"/>
  1672. /// before variable handles can be obtained via spssGetVarHandle.
  1673. /// </remarks>
  1674. protected delegate ReturnCode spssGetVarHandleDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out double varHandle);
  1675. protected static spssGetVarHandleDelegate spssGetVarHandleImpl;
  1676. /// <summary>
  1677. /// Gets variable sets information in a data file.
  1678. /// </summary>
  1679. /// <param name="handle">
  1680. /// Handle to the data file
  1681. /// </param>
  1682. /// <param name="varSets">
  1683. /// Pointer to pointer to variable sets string
  1684. /// </param>
  1685. /// <returns>
  1686. /// <see cref="ReturnCode.SPSS_OK"/>,
  1687. /// <see cref="ReturnCode.SPSS_NO_VARSETS"/>,
  1688. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
  1689. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  1690. /// </returns>
  1691. /// <remarks>
  1692. /// This function reports the variable sets information in the data file. Variable sets
  1693. /// information is stored in a null-terminated string and a pointer to the string is returned
  1694. /// in *<paramref>varSets</paramref>. Since the variable sets string is allocated
  1695. /// on the heap, the caller should free
  1696. /// it by calling <see cref="spssFreeVariableSetsDelegate"/> when it is no longer needed.
  1697. /// </remarks>
  1698. [CLSCompliant(false)]
  1699. unsafe protected delegate ReturnCode spssGetVariableSetsDelegate(int handle, out char* varSets);
  1700. [CLSCompliant(false)]
  1701. protected static spssGetVariableSetsDelegate spssGetVariableSetsImpl;
  1702. /// <summary>
  1703. /// Gets the name and type of a variable.
  1704. /// </summary>
  1705. /// <param name="handle">
  1706. /// Handle to the data file
  1707. /// </param>
  1708. /// <param name="iVar">
  1709. /// Zero origin variable number
  1710. /// </param>
  1711. /// <param name="varName">
  1712. /// Returned as the variable name
  1713. /// </param>
  1714. /// <param name="varType">
  1715. /// Returned as the variable type
  1716. /// </param>
  1717. /// <returns>
  1718. /// <see cref="ReturnCode.SPSS_OK"/>,
  1719. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1720. /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>,
  1721. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>, or
  1722. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  1723. /// </returns>
  1724. /// <remarks>
  1725. /// This function gets the name and type of one of the variables present in a data file. It
  1726. /// serves the same purpose as <see cref="spssGetVarNamesDelegate"/> but returns the information one variable
  1727. /// at a time and, therefore, can be passed to a Visual Basic program. The storage to receive
  1728. /// the variable name must be at least 9 bytes in length because the name is returned as a
  1729. /// null-terminated string. The type code is an integer in the range 0–255, 0 indicating a numeric
  1730. /// variable and a positive value indicating a string variable of that size.
  1731. /// </remarks>
  1732. public delegate ReturnCode spssGetVarInfoDelegate(int handle, int iVar, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out int varType);
  1733. public static spssGetVarInfoDelegate spssGetVarInfoImpl;
  1734. /// <summary>
  1735. /// Gets the variable label for some named variable.
  1736. /// </summary>
  1737. /// <param name="handle">
  1738. /// Handle to the data file
  1739. /// </param>
  1740. /// <param name="varName">
  1741. /// Variable name
  1742. /// </param>
  1743. /// <param name="varLabel">
  1744. /// Variable label buffer
  1745. /// </param>
  1746. /// <returns>
  1747. /// <see cref="ReturnCode.SPSS_OK"/>,
  1748. /// <see cref="ReturnCode.SPSS_NO_LABEL"/>,
  1749. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1750. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
  1751. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  1752. /// </returns>
  1753. /// <remarks>
  1754. /// This function copies the label of variable varName into the buffer pointed to by
  1755. /// varLabel. Since the variable label is at most 120 characters long and null terminated, the
  1756. /// size of the buffer should be at least 121. To get labels more than 120 characters long, use
  1757. /// the spssGetVarLabelLong function.
  1758. /// </remarks>
  1759. //! TODO Check if change of 3rd parameter works (changed out to ref as otherwise Marshal.GetDelegateForFunctionPointer fails).
  1760. public delegate ReturnCode spssGetVarLabelDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varLabel);
  1761. public static spssGetVarLabelDelegate spssGetVarLabelImplImpl;
  1762. /// <summary>
  1763. /// Gets the variable label for some named variable.
  1764. /// </summary>
  1765. /// <param name="handle">
  1766. /// Handle to the data file
  1767. /// </param>
  1768. /// <param name="varName">
  1769. /// Null-terminated variable name
  1770. /// </param>
  1771. /// <param name="labelBuff">
  1772. /// Buffer to receive the null-terminated label
  1773. /// </param>
  1774. /// <param name="lenBuff">
  1775. /// Overall size of labelBuff in bytes
  1776. /// </param>
  1777. /// <param name="lenLabel">
  1778. /// Returned as bytes stored excluding terminator
  1779. /// </param>
  1780. /// <returns>
  1781. /// <see cref="ReturnCode.SPSS_OK"/>,
  1782. /// <see cref="ReturnCode.SPSS_NO_LABEL"/>,
  1783. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1784. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
  1785. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  1786. /// </returns>
  1787. /// <remarks>
  1788. /// This function returns the null-terminated label associated with the specified variable but
  1789. /// restricts the number of bytes (including the null terminator) returned to lenBuff bytes.
  1790. /// This length can be conveniently specified as sizeof(labelBuff). The function also returns
  1791. /// the number of data bytes (this time excluding the null terminator) stored. If an error is
  1792. /// detected, the label is returned as a null string, and the length is returned as 0.
  1793. /// </remarks>
  1794. public delegate ReturnCode spssGetVarLabelLongDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, [MarshalAs(UnmanagedType.VBByRefStr)] ref string labelBuff, int lenBuff, out int lenLabel);
  1795. public static spssGetVarLabelLongDelegate spssGetVarLabelLongImpl;
  1796. /// <summary>
  1797. /// Gets the measurement level of a variable.
  1798. /// </summary>
  1799. /// <param name="handle">
  1800. /// Handle to the data file
  1801. /// </param>
  1802. /// <param name="varName">
  1803. /// Variable name
  1804. /// </param>
  1805. /// <param name="measureLevel">
  1806. /// Pointer to measurement level. Set to
  1807. /// <see cref="MeasurementLevelCode.SPSS_MLVL_NOM"/>,
  1808. /// <see cref="MeasurementLevelCode.SPSS_MLVL_ORD"/>, or
  1809. /// <see cref="MeasurementLevelCode.SPSS_MLVL_RAT"/>,
  1810. /// for nominal, ordinal, and scale (ratio), respectively
  1811. /// </param>
  1812. /// <returns>
  1813. /// <see cref="ReturnCode.SPSS_OK"/>,
  1814. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1815. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
  1816. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  1817. /// </returns>
  1818. /// <remarks>
  1819. /// This function reports the value of the measurement level attribute of a variable.
  1820. /// </remarks>
  1821. protected delegate ReturnCode spssGetVarMeasureLevelDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out int measureLevel);
  1822. protected static spssGetVarMeasureLevelDelegate spssGetVarMeasureLevelImpl;
  1823. /// <summary>
  1824. /// Gets the missing values of a numeric variable.
  1825. /// </summary>
  1826. /// <param name="handle">
  1827. /// Handle to the data file
  1828. /// </param>
  1829. /// <param name="varName">
  1830. /// Variable name
  1831. /// </param>
  1832. /// <param name="missingFormat">
  1833. /// Pointer to missing value format code
  1834. /// </param>
  1835. /// <param name="missingVal1">
  1836. /// Buffer for first missing value
  1837. /// </param>
  1838. /// <param name="missingVal2">
  1839. /// Buffer for second missing value
  1840. /// </param>
  1841. /// <param name="missingVal3">
  1842. /// Buffer for third missing value
  1843. /// </param>
  1844. /// <returns>
  1845. /// <see cref="ReturnCode.SPSS_OK"/>,
  1846. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1847. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  1848. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
  1849. /// <see cref="ReturnCode.SPSS_NUME_EXP"/>.
  1850. /// </returns>
  1851. /// <remarks>
  1852. /// This function reports the missing values of a numeric variable. The value of
  1853. /// *<paramref>missingFormat</paramref> determines the interpretation of *<paramref>missingVal1</paramref>, *<paramref>missingVal2</paramref>, and
  1854. /// *<paramref>missingVal3</paramref>. If *missingFormat is SPSS_MISS_RANGE, *<paramref>missingVal1</paramref> and *<paramref>missingVal2</paramref>
  1855. /// represent the upper and lower limits, respectively, of the range, and *<paramref>missingVal3</paramref> is not
  1856. /// used. If *missingFormat is SPSS_MISS_RANGEANDVAL, *<paramref>missingVal1</paramref> and *<paramref>missingVal2</paramref>
  1857. /// represent the range and *<paramref>missingVal3</paramref> is the discrete missing value. If *missingFormat is
  1858. /// neither of the above, it will be in the range 0–3, indicating the number of discrete missing
  1859. /// values present. (The macros SPSS_NO_MISSVAL, SPSS_ONE_MISSVAL,
  1860. /// SPSS_TWO_MISSVAL, and SPSS_THREE_MISSVAL may be used as synonyms for 0–3.)
  1861. /// </remarks>
  1862. protected delegate ReturnCode spssGetVarNMissingValuesDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out MissingValueFormatCode missingFormat, out double missingVal1, out double missingVal2, out double missingVal3);
  1863. protected static spssGetVarNMissingValuesDelegate spssGetVarNMissingValuesImpl;
  1864. /// <summary>
  1865. /// Gets the value label for a given value of a numeric variable.
  1866. /// </summary>
  1867. /// <param name="handle">
  1868. /// Handle to the data file
  1869. /// </param>
  1870. /// <param name="varName">
  1871. /// Variable name
  1872. /// </param>
  1873. /// <param name="value">
  1874. /// Numeric value for which the label is wanted
  1875. /// </param>
  1876. /// <param name="label">
  1877. /// Label for the value
  1878. /// </param>
  1879. /// <returns>
  1880. /// <see cref="ReturnCode.SPSS_OK"/>,
  1881. /// <see cref="ReturnCode.SPSS_NO_LABELS"/>,
  1882. /// <see cref="ReturnCode.SPSS_NO_LABEL"/>,
  1883. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1884. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  1885. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
  1886. /// <see cref="ReturnCode.SPSS_NUME_EXP"/>.
  1887. /// </returns>
  1888. /// <remarks>
  1889. /// This function gets the value label for a given value of a numeric variable. The label is
  1890. /// copied as a null-terminated string into the buffer label, whose size must be at least 61 to
  1891. /// hold the longest possible value label (60 characters) plus the terminator. To get value labels
  1892. /// more than 60 characters long, use the <see cref="spssGetVarNValueLabelLongDelegate"/> function.
  1893. /// </remarks>
  1894. protected delegate ReturnCode spssGetVarNValueLabelDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, double value, [MarshalAs(UnmanagedType.VBByRefStr)] ref string label);
  1895. protected static spssGetVarNValueLabelDelegate spssGetVarNValueLabelImpl;
  1896. /// <summary>
  1897. /// Gets the value label for a given value of a numeric variable.
  1898. /// </summary>
  1899. /// <param name="handle">
  1900. /// Handle to the data file
  1901. /// </param>
  1902. /// <param name="varName">
  1903. /// Null-terminated variable name
  1904. /// </param>
  1905. /// <param name="value">
  1906. /// Value for which label is requested
  1907. /// </param>
  1908. /// <param name="labelBuff">
  1909. /// Returned as null-terminated label
  1910. /// </param>
  1911. /// <param name="lenBuff">
  1912. /// Overall size of labelBuff in bytes
  1913. /// </param>
  1914. /// <param name="lenLabel">
  1915. /// Returned as bytes stored excluding terminator
  1916. /// </param>
  1917. /// <returns>
  1918. /// <see cref="ReturnCode.SPSS_OK"/>,
  1919. /// <see cref="ReturnCode.SPSS_NO_LABELS"/>,
  1920. /// <see cref="ReturnCode.SPSS_NO_LABEL"/>,
  1921. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1922. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  1923. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
  1924. /// <see cref="ReturnCode.SPSS_NUME_EXP"/>.
  1925. /// </returns>
  1926. /// <remarks>
  1927. /// This function returns a null-terminated value label corresponding to one value of a specified
  1928. /// numeric variable. It permits the client to limit the number of bytes (including the
  1929. /// null terminator) stored and returns the number of data bytes (excluding the null terminator)
  1930. /// actually stored. If an error is detected, the label is returned as a null string, and the
  1931. /// length is returned as 0.
  1932. /// </remarks>
  1933. protected delegate ReturnCode spssGetVarNValueLabelLongDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, double value, [MarshalAs(UnmanagedType.VBByRefStr)] ref string labelBuff, int lenBuff, out int lenLabel);
  1934. protected static spssGetVarNValueLabelLongDelegate spssGetVarNValueLabelLong;
  1935. /// <summary>
  1936. /// Gets a list of all response values and labels for a numeric variable.
  1937. /// </summary>
  1938. /// <param name="handle">
  1939. /// Handle to the data file
  1940. /// </param>
  1941. /// <param name="varName">
  1942. /// Variable name
  1943. /// </param>
  1944. /// <param name="values">
  1945. /// Pointer to array of double values
  1946. /// </param>
  1947. /// <param name="labels">
  1948. /// Pointer to array of pointers to labels
  1949. /// </param>
  1950. /// <param name="numLabels">
  1951. /// Pointer to number of values or labels
  1952. /// </param>
  1953. /// <returns>
  1954. /// <see cref="ReturnCode.SPSS_OK"/>,
  1955. /// <see cref="ReturnCode.SPSS_NO_LABELS"/>,
  1956. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1957. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  1958. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  1959. /// <see cref="ReturnCode.SPSS_NUME_EXP"/>, or
  1960. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  1961. /// </returns>
  1962. /// <remarks>
  1963. /// This function gets the set of labeled values and associated labels for a numeric variable.
  1964. /// The number of values is returned as *numLabels. Values are stored into an array of
  1965. /// *numLabels double elements, and *values is set to point to the first element of the array.
  1966. /// The corresponding labels are structured as an array of *numLabels pointers, each pointing
  1967. /// to a char string containing a null-terminated label, and *labels is set to point to the
  1968. /// first element of the array.
  1969. /// The two arrays and the label strings are allocated on the heap. When they are no longer
  1970. /// needed, <see cref="spssFreeVarNValueLabelsDelegate"/> should be called to free the memory.
  1971. /// </remarks>
  1972. [CLSCompliant(false)]
  1973. unsafe protected delegate ReturnCode spssGetVarNValueLabelsDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out double* values, out char** labels, out int numLabels);
  1974. [CLSCompliant(false)]
  1975. protected static spssGetVarNValueLabelsDelegate spssGetVarNValueLabelsImpl;
  1976. /// <summary>
  1977. /// Gets print formatting information for a variable.
  1978. /// </summary>
  1979. /// <param name="handle">
  1980. /// Handle to the data file
  1981. /// </param>
  1982. /// <param name="varName">
  1983. /// Variable name
  1984. /// </param>
  1985. /// <param name="printType">
  1986. /// Pointer to print format type code (file spssdio.h defines macros of
  1987. /// the form <see cref="FormatTypeCode">SPSS_FMT_...</see> for all valid format type codes)
  1988. /// </param>
  1989. /// <param name="printDec">
  1990. /// Pointer to number of digits after the decimal
  1991. /// </param>
  1992. /// <param name="printWidth">
  1993. /// Pointer to print format width
  1994. /// </param>
  1995. /// <returns>
  1996. /// <see cref="ReturnCode.SPSS_OK"/>,
  1997. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  1998. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
  1999. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  2000. /// </returns>
  2001. /// <remarks>
  2002. /// This function reports the print format of a variable. Format type, number of decimal
  2003. /// places, and field width are returned as *<paramref>printType</paramref>,
  2004. /// *<paramref>printDec</paramref>, and *<paramref>printWid</paramref>, respectively.
  2005. /// </remarks>
  2006. protected delegate ReturnCode spssGetVarPrintFormatDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out FormatTypeCode printType, out int printDec, out int printWidth);
  2007. protected static spssGetVarPrintFormatDelegate spssGetVarPrintFormatImpl;
  2008. /// <summary>
  2009. /// Gets the names and types of all variables in a data file.
  2010. /// </summary>
  2011. /// <param name="handle">
  2012. /// Handle to the data file
  2013. /// </param>
  2014. /// <param name="numVars">
  2015. /// Pointer to number of variables
  2016. /// </param>
  2017. /// <param name="varNames">
  2018. /// Pointer to array of pointers to variable names
  2019. /// </param>
  2020. /// <param name="varTypes">
  2021. /// Pointer to array of variable types
  2022. /// </param>
  2023. /// <returns>
  2024. /// <see cref="ReturnCode.SPSS_OK"/>,
  2025. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2026. /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>, or
  2027. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2028. /// </returns>
  2029. /// <remarks>
  2030. /// This function gets the names and types of all the variables present in a data file. The
  2031. /// number of variables is returned as *numVars. Variable names are structured as an array
  2032. /// of *numVars pointers, each pointing to a char string containing a variable name, and
  2033. /// *varNames is set to point to the first element of the array. Variable types are stored into
  2034. /// a corresponding array of *numVars in elements, and *varTypes is set to point to the first
  2035. /// element of the array. The type code is an integer in the range 0–255, 0 indicating a numeric
  2036. /// variable and a positive value indicating a string variable of that size.
  2037. /// The two arrays and the variable name strings are allocated on the heap. When they
  2038. /// are no longer needed, <see cref="spssFreeVarNamesDelegate"/> should be called to free the memory.
  2039. /// </remarks>
  2040. [CLSCompliant(false)]
  2041. unsafe protected delegate ReturnCode spssGetVarNamesDelegate(int handle, out int numVars, out char** varNames, out int* varTypes);
  2042. [CLSCompliant(false)]
  2043. protected static spssGetVarNamesDelegate spssGetVarNamesImpl;
  2044. /// <summary>
  2045. /// Gets the write format of a variable.
  2046. /// </summary>
  2047. /// <param name="handle">
  2048. /// Handle to the data file
  2049. /// </param>
  2050. /// <param name="varName">
  2051. /// Variable name
  2052. /// </param>
  2053. /// <param name="writeType">
  2054. /// Pointer to write format type code (file spssdio.h defines macros of
  2055. /// the form <see cref="FormatTypeCode">SPSS_FMT_...</see> for all valid format type codes)
  2056. /// </param>
  2057. /// <param name="writeDec">
  2058. /// Pointer to number of digits after the decimal
  2059. /// </param>
  2060. /// <param name="writeWidth">
  2061. /// Pointer to write format width
  2062. /// </param>
  2063. /// <returns>
  2064. /// <see cref="ReturnCode.SPSS_OK"/>,
  2065. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2066. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
  2067. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  2068. /// </returns>
  2069. /// <remarks>
  2070. /// This function reports the write format of a variable. Format type, number of decimal
  2071. /// places, and field width are returned as *writeType, *writeDec, and *writeWid,
  2072. /// respectively.
  2073. /// </remarks>
  2074. protected delegate ReturnCode spssGetVarWriteFormatDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, out FormatTypeCode writeType, out int writeDec, out int writeWidth);
  2075. protected static spssGetVarWriteFormatDelegate spssGetVarWriteFormatImpl;
  2076. /// <summary>
  2077. /// Gets the missing value for the system.
  2078. /// </summary>
  2079. /// <param name="missVal">
  2080. /// Returned as the system missing value
  2081. /// </param>
  2082. /// <remarks>
  2083. /// This function accesses the same information as <see cref="spssSysmisValDelegate"/> but returns the
  2084. /// information via a parameter rather than on the stack as the function result. The problem
  2085. /// being addressed is that not all languages return doubles from functions in the same
  2086. /// fashion.
  2087. /// </remarks>
  2088. public delegate void spssHostSysmisValDelegate(out double missVal);
  2089. public static spssHostSysmisValDelegate spssHostSysmisValImpl;
  2090. /// <summary>
  2091. /// Gets the lowest and highest values used for numeric missing values on the system.
  2092. /// </summary>
  2093. /// <param name="lowest">
  2094. /// Pointer to "lowest" value
  2095. /// </param>
  2096. /// <param name="highest">
  2097. /// Pointer to "highest" value
  2098. /// </param>
  2099. /// <remarks>
  2100. /// This function returns the "lowest" and "highest" values used for numeric missing value
  2101. /// ranges on the host system. It may be called at any time.
  2102. /// </remarks>
  2103. public delegate void spssLowHighValDelegate(out double lowest, out double highest);
  2104. public static spssLowHighValDelegate spssLowHighValImpl;
  2105. /// <summary>
  2106. /// Opens an SPSS file for appending cases.
  2107. /// </summary>
  2108. /// <param name="fileName">
  2109. /// Name of the file
  2110. /// </param>
  2111. /// <param name="handle">
  2112. /// Pointer to handle to be returned
  2113. /// </param>
  2114. /// <returns>
  2115. /// <see cref="ReturnCode.SPSS_OK"/>,
  2116. /// <see cref="ReturnCode.SPSS_FITAB_FULL"/>,
  2117. /// <see cref="ReturnCode.SPSS_FILE_OERROR"/>,
  2118. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>,
  2119. /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>,
  2120. /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>,
  2121. /// <see cref="ReturnCode.SPSS_NO_TYPE2"/>,
  2122. /// <see cref="ReturnCode.SPSS_NO_TYPE999"/>, or
  2123. /// <see cref="ReturnCode.SPSS_INCOMPAT_APPEND"/>.
  2124. /// </returns>
  2125. /// <remarks>
  2126. /// This function opens an SPSS data file for appending cases and returns a handle that
  2127. /// should be used for subsequent operations on the file.
  2128. /// </remarks>
  2129. protected delegate ReturnCode spssOpenAppendDelegate([MarshalAs(UnmanagedType.VBByRefStr)] ref string fileName, out int handle);
  2130. protected static spssOpenAppendDelegate spssOpenAppendImpl;
  2131. /// <summary>
  2132. /// Opens an SPSS file for reading.
  2133. /// </summary>
  2134. /// <param name="fileName">
  2135. /// Name of the file
  2136. /// </param>
  2137. /// <param name="handle">
  2138. /// Pointer to handle to be returned
  2139. /// </param>
  2140. /// <returns>
  2141. /// <see cref="ReturnCode.SPSS_OK"/>,
  2142. /// <see cref="ReturnCode.SPSS_FITAB_FULL"/>,
  2143. /// <see cref="ReturnCode.SPSS_FILE_OERROR"/>,
  2144. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>,
  2145. /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>,
  2146. /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>,
  2147. /// <see cref="ReturnCode.SPSS_NO_TYPE2"/>, or
  2148. /// <see cref="ReturnCode.SPSS_NO_TYPE999"/>.
  2149. /// </returns>
  2150. /// <remarks>
  2151. /// This function opens an SPSS data file for reading and returns a handle that should be
  2152. /// used for subsequent operations on the file.
  2153. /// </remarks>
  2154. protected delegate ReturnCode spssOpenReadDelegate([MarshalAs(UnmanagedType.VBByRefStr)] ref string fileName, out int handle);
  2155. protected static spssOpenReadDelegate spssOpenReadImpl;
  2156. /// <summary>
  2157. /// Creates an SPSS file, and prepares for writing.
  2158. /// </summary>
  2159. /// <param name="fileName">
  2160. /// Name of the file
  2161. /// </param>
  2162. /// <param name="handle">
  2163. /// Pointer to handle to be returned
  2164. /// </param>
  2165. /// <returns>
  2166. /// <see cref="ReturnCode.SPSS_OK"/>,
  2167. /// <see cref="ReturnCode.SPSS_FITAB_FULL"/>,
  2168. /// <see cref="ReturnCode.SPSS_FILE_OERROR"/>,
  2169. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>,
  2170. /// </returns>
  2171. /// <remarks>
  2172. /// This function opens a file in preparation for creating a new SPSS data file and returns a
  2173. /// handle that should be used for subsequent operations on the file.
  2174. /// </remarks>
  2175. protected delegate ReturnCode spssOpenWriteDelegate([MarshalAs(UnmanagedType.VBByRefStr)] ref string fileName, out int handle);
  2176. /// <summary>
  2177. /// <see cref="spssOpenWriteDelegate"/>
  2178. /// </summary>
  2179. protected static spssOpenWriteDelegate spssOpenWriteImpl;
  2180. /// <summary>
  2181. /// Creates a new SPSS data file, with a dictionary copied from an existing file.
  2182. /// </summary>
  2183. /// <param name="fileName">
  2184. /// Name of the new file
  2185. /// </param>
  2186. /// <param name="dictFileName">
  2187. /// Name of existing file
  2188. /// </param>
  2189. /// <param name="handle">
  2190. /// Pointer to handle to be returned
  2191. /// </param>
  2192. /// <returns>
  2193. /// <see cref="ReturnCode.SPSS_OK"/>,
  2194. /// <see cref="ReturnCode.SPSS_FITAB_FULL"/>,
  2195. /// <see cref="ReturnCode.SPSS_FILE_OERROR"/>,
  2196. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>,
  2197. /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>,
  2198. /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>,
  2199. /// <see cref="ReturnCode.SPSS_NO_TYPE2"/>, or
  2200. /// <see cref="ReturnCode.SPSS_NO_TYPE999"/>.
  2201. /// </returns>
  2202. /// <remarks>
  2203. /// This function opens a file in preparation for creating a new SPSS data file and initializes
  2204. /// its dictionary from that of an existing SPSS data file. It is useful when you want to modify
  2205. /// the dictionary or data of an existing file or replace all of its data. The typical sequence
  2206. /// of operations is to call <see cref="spssOpenWriteCopyDelegate"/> (newFileName, oldFileName, ...) to open a
  2207. /// new file initialized with a copy of the old file’s dictionary, then <see cref="spssOpenReadDelegate"/> (oldFile-
  2208. /// Name, ...) to open the old file to access its data.
  2209. /// </remarks>
  2210. protected delegate ReturnCode spssOpenWriteCopyDelegate([MarshalAs(UnmanagedType.VBByRefStr)] ref string fileName, [MarshalAs(UnmanagedType.VBByRefStr)] ref string dictFileName, out int handle);
  2211. protected static spssOpenWriteCopyDelegate spssOpenWriteCopyImpl;
  2212. /// <summary>
  2213. /// Gets a value indicating whether a data file contains a specific "type 7" record.
  2214. /// </summary>
  2215. /// <param name="fromHandle">
  2216. /// Handle to the data file
  2217. /// </param>
  2218. /// <param name="subType">
  2219. /// Specific subtype record
  2220. /// </param>
  2221. /// <param name="bFound">
  2222. /// Returned set if the specified subtype was encountered
  2223. /// </param>
  2224. /// <returns>
  2225. /// <see cref="ReturnCode.SPSS_OK"/>,
  2226. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2227. /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>, or
  2228. /// <see cref="ReturnCode.SPSS_INVALID_7SUBTYPE"/>.
  2229. /// </returns>
  2230. /// <remarks>
  2231. /// This function can be used to determine whether a file opened for reading or append
  2232. /// contains a specific "type 7" record. The following type 7 subtypes might be of interest:
  2233. /// <list type="bullet">
  2234. /// <item>Subtype 3. Release information</item>
  2235. /// <item>Subtype 4. Floating point constants including the system missing value</item>
  2236. /// <item>Subtype 5. Variable set definitions</item>
  2237. /// <item>Subtype 6. Date variable information</item>
  2238. /// <item>Subtype 7. Multiple response set definitions</item>
  2239. /// <item>Subtype 8. Data Entry for Windows (DEW) information</item>
  2240. /// <item>Subtype 10. TextSmart information</item>
  2241. /// <item>Subtype 11. Measurement level, column width, and alignment for each variable</item>
  2242. /// </list>
  2243. /// </remarks>
  2244. public delegate ReturnCode spssQueryType7Delegate(int fromHandle, int subType, out int bFound);
  2245. public static spssQueryType7Delegate spssQueryType7Impl;
  2246. /// <summary>
  2247. /// Reads the next case from a data file in preparation for reading its values.
  2248. /// </summary>
  2249. /// <param name="handle">
  2250. /// Handle to the data file
  2251. /// </param>
  2252. /// <returns>
  2253. /// <see cref="ReturnCode.SPSS_OK"/>,
  2254. /// <see cref="ReturnCode.SPSS_FILE_END"/>,
  2255. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2256. /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>, or
  2257. /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>.
  2258. /// </returns>
  2259. /// <remarks>
  2260. /// This function reads the next case from a data file into internal buffers. Values of individual
  2261. /// variables for the case may then be obtained by calling the
  2262. /// <see cref="spssGetValueNumericDelegate"/> and
  2263. /// <see cref="spssGetValueCharDelegate"/> procedures.
  2264. /// </remarks>
  2265. public delegate ReturnCode spssReadCaseRecordDelegate(int handle);
  2266. public static spssReadCaseRecordDelegate spssReadCaseRecord;
  2267. /// <summary>
  2268. /// Prepares SPSS to read data values from a specific case.
  2269. /// </summary>
  2270. /// <param name="handle">
  2271. /// Handle to the data file
  2272. /// </param>
  2273. /// <param name="caseNumber">
  2274. /// Zero origin case number
  2275. /// </param>
  2276. /// <returns>
  2277. /// <see cref="ReturnCode.SPSS_OK"/>,
  2278. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2279. /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>,
  2280. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>,
  2281. /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>, or
  2282. /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>.
  2283. /// </returns>
  2284. /// <remarks>
  2285. /// This function sets the file pointer of an input file so that the next data case read will be
  2286. /// the one specified via the caseNumber parameter. A zero origin scheme is used. That
  2287. /// is, the first case is number 0. The next case can be read by calling either
  2288. /// <see cref="spssWholeCaseInDelegate"/> or <see cref="spssReadCaseRecordDelegate"/>.
  2289. /// If the specified case is greater than or equal to the
  2290. /// number of cases in the file, the call to the input function will return
  2291. /// <see cref="ReturnCode.SPSS_FILE_END"/>.
  2292. /// </remarks>
  2293. public delegate ReturnCode spssSeekNextCaseDelegate(int handle, int caseNumber);
  2294. public static spssSeekNextCaseDelegate spssSeekNextCase;
  2295. /// <summary>
  2296. /// Sets the case weight variable in a data file.
  2297. /// </summary>
  2298. /// <param name="handle">
  2299. /// Handle to the data file
  2300. /// </param>
  2301. /// <param name="varName">
  2302. /// The name of the case weight variable
  2303. /// </param>
  2304. /// <returns>
  2305. /// <see cref="ReturnCode.SPSS_OK"/>,
  2306. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2307. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2308. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2309. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  2310. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  2311. /// <see cref="ReturnCode.SPSS_NUME_EXP"/>, or
  2312. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2313. /// </returns>
  2314. /// <remarks>
  2315. /// This function defines variable varName as the case weight variable for the data file
  2316. /// specified by the handle.
  2317. /// </remarks>
  2318. protected delegate ReturnCode spssSetCaseWeightVarDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName);
  2319. protected static spssSetCaseWeightVarDelegate spssSetCaseWeightVarImpl;
  2320. /// <summary>
  2321. /// Sets the compression attribute of a data file.
  2322. /// </summary>
  2323. /// <param name="handle">
  2324. /// Handle to the data file
  2325. /// </param>
  2326. /// <param name="compSwitch">
  2327. /// Compression switch
  2328. /// </param>
  2329. /// <returns>
  2330. /// <see cref="ReturnCode.SPSS_OK"/>,
  2331. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2332. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2333. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>, or
  2334. /// <see cref="ReturnCode.SPSS_INVALID_COMPSW"/>.
  2335. /// </returns>
  2336. /// <remarks>
  2337. /// This function sets the compression attribute of an SPSS data file. Compression is set
  2338. /// on if compSwitch is one and off if it is zero. If this function is not called, the output file
  2339. /// will be uncompressed by default.
  2340. /// </remarks>
  2341. public delegate ReturnCode spssSetCompressionDelegate(int handle, int compSwitch);
  2342. public static spssSetCompressionDelegate spssSetCompression;
  2343. /// <summary>
  2344. /// Sets the Trends date variable information.
  2345. /// </summary>
  2346. /// <param name="handle">
  2347. /// Handle to the data file
  2348. /// </param>
  2349. /// <param name="numofElements">
  2350. /// Size of the array dateInfo
  2351. /// </param>
  2352. /// <param name="dateInfo">
  2353. /// Array containing date variables information
  2354. /// </param>
  2355. /// <returns>
  2356. /// <see cref="ReturnCode.SPSS_OK"/>,
  2357. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2358. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2359. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2360. /// <see cref="ReturnCode.SPSS_INVALID_DATEINFO"/>, or
  2361. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2362. /// </returns>
  2363. /// <remarks>
  2364. /// This function sets the Trends date variable information. The array at dateInfo is
  2365. /// assumed to have numofElements elements that correspond to the data array portion of
  2366. /// record 7, subtype 3. Its first six elements comprise the “fixed” information, followed
  2367. /// by a sequence of one or more three-element groups. Since very little validity checking
  2368. /// is done on the input array, this function should be used with caution and is
  2369. /// recommended only for copying Trends information from one file to another.
  2370. /// </remarks>
  2371. [CLSCompliant(false)]
  2372. unsafe protected delegate ReturnCode spssSetDateVariablesDelegate(int handle, int numofElements, int* dateInfo);
  2373. [CLSCompliant(false)]
  2374. protected static spssSetDateVariablesDelegate spssSetDateVariablesImpl;
  2375. /// <summary>
  2376. /// Sets the first block of Data Entry information.
  2377. /// </summary>
  2378. /// <param name="handle">
  2379. /// Handle to the data file
  2380. /// </param>
  2381. /// <param name="data">
  2382. /// Pointer to the data to be written
  2383. /// </param>
  2384. /// <param name="nBytes">
  2385. /// Number of bytes to write
  2386. /// </param>
  2387. /// <returns>
  2388. /// <see cref="ReturnCode.SPSS_OK"/>,
  2389. /// <see cref="ReturnCode.SPSS_EMPTY_DEW"/>,
  2390. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2391. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2392. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2393. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>, or
  2394. /// <see cref="ReturnCode.SPSS_FILE_BADTEMP"/>.
  2395. /// </returns>
  2396. /// <remarks>
  2397. /// DEW information (file information which is private to the SPSS Data Entry product)
  2398. /// can be delivered to the I/O DLL in whatever segments are convenient for the client.
  2399. /// The spssSetDEWFirst function is called to deliver the first such segment, and
  2400. /// subsequent segments are delivered by calling spssSetDEWNext as many times as
  2401. /// necessary.
  2402. /// </remarks>
  2403. protected delegate ReturnCode spssSetDEWFirstDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string data, int nBytes);
  2404. protected static spssSetDEWFirstDelegate spssSetDEWFirstImpl;
  2405. /// <summary>
  2406. /// Sets the unique Data Entry uniqueness GUID.
  2407. /// </summary>
  2408. /// <param name="handle">
  2409. /// Handle to the data file
  2410. /// </param>
  2411. /// <param name="asciiGUID">
  2412. /// The GUID (as a null-terminated string) to be stored on the file
  2413. /// </param>
  2414. /// <returns>
  2415. /// <see cref="ReturnCode.SPSS_OK"/>,
  2416. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2417. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2418. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>, or
  2419. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2420. /// </returns>
  2421. /// <remarks>
  2422. /// This function stores the Data Entry for Windows uniqueness indicator on the data file.
  2423. /// It should only be used by the DEW product.
  2424. /// </remarks>
  2425. protected delegate ReturnCode spssSetDEWGUIDDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string asciiGUID);
  2426. protected static spssSetDEWGUIDDelegate spssSetDEWGUIDImpl;
  2427. /// <summary>
  2428. /// Sets the next block of information for Data Entry.
  2429. /// </summary>
  2430. /// <param name="handle">
  2431. /// Handle to the data file
  2432. /// </param>
  2433. /// <param name="data">
  2434. /// Pointer to the data to be written
  2435. /// </param>
  2436. /// <param name="nBytes">
  2437. /// Number of bytes to write
  2438. /// </param>
  2439. /// <returns>
  2440. /// <see cref="ReturnCode.SPSS_OK"/>,
  2441. /// <see cref="ReturnCode.SPSS_DEW_NOFIRST"/>,
  2442. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2443. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2444. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2445. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>, or
  2446. /// <see cref="ReturnCode.SPSS_FILE_BADTEMP"/>.
  2447. /// </returns>
  2448. /// <remarks>
  2449. /// The DEW information (file information that is private to the SPSS Data Entry product)
  2450. /// can be delivered to the I/O DLL in whatever segments are convenient for the client.
  2451. /// The spssSetDEWFirst function is called to deliver the first such segment, and
  2452. /// subsequent segments are delivered by calling spssSetDEWNext as many times as
  2453. /// necessary.
  2454. /// </remarks>
  2455. protected delegate ReturnCode spssSetDEWNextDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string data, int nBytes);
  2456. protected static spssSetDEWNextDelegate spssSetDEWNextImpl;
  2457. /// <summary>
  2458. /// Sets the file label of a data file.
  2459. /// </summary>
  2460. /// <param name="handle">
  2461. /// Handle to the data file
  2462. /// </param>
  2463. /// <param name="id">
  2464. /// File label. The length of the string should not exceed 64 characters
  2465. /// </param>
  2466. /// <returns>
  2467. /// <see cref="ReturnCode.SPSS_OK"/>,
  2468. /// <see cref="ReturnCode.SPSS_EXC_LEN64"/>
  2469. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2470. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>, or
  2471. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>.
  2472. /// </returns>
  2473. /// <remarks>
  2474. /// This function sets the file label of the output SPSS data file associated with handle to
  2475. /// the given string id.
  2476. /// </remarks>
  2477. protected delegate ReturnCode spssSetIdStringDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string id);
  2478. protected static spssSetIdStringDelegate spssSetIdStringImpl;
  2479. /// <summary>
  2480. /// Sets multiple response definitions to a data file.
  2481. /// </summary>
  2482. /// <param name="handle">
  2483. /// Handle to the data file.
  2484. /// </param>
  2485. /// <param name="mrespDefs">
  2486. /// ascii string containing definitions.
  2487. /// </param>
  2488. /// <returns>
  2489. /// <see cref="ReturnCode.SPSS_OK"/>,
  2490. /// <see cref="ReturnCode.SPSS_EMPTY_MULTRESP"/>
  2491. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2492. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2493. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>, or
  2494. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2495. /// </returns>
  2496. /// <remarks>
  2497. /// this function is used to write multiple response definitions to the file. the definitions
  2498. /// consist of a single null-terminated ascii string which is similar to that containing the
  2499. /// variable set definitions.
  2500. /// </remarks>
  2501. protected delegate ReturnCode spssSetMultRespDefsDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string mrespDefs);
  2502. protected static spssSetMultRespDefsDelegate spssSetMultRespDefsImpl;
  2503. /// <summary>
  2504. /// Sets the text data from the null-terminated string in textInfo.
  2505. /// </summary>
  2506. /// <param name="handle">
  2507. /// Handle to the data file
  2508. /// </param>
  2509. /// <param name="textInfo">
  2510. /// Text data
  2511. /// </param>
  2512. /// <returns>
  2513. /// <see cref="ReturnCode.SPSS_OK"/>,
  2514. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2515. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2516. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>, or
  2517. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2518. /// </returns>
  2519. /// <remarks>
  2520. /// This function sets the text data from the null-terminated string in textInfo. If the string is
  2521. /// longer than 255 characters, only the first 255 are (quietly) used. If textInfo contains the
  2522. /// empty string, existing text data, if any, is deleted.
  2523. /// </remarks>
  2524. protected delegate ReturnCode spssSetTextInfoDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string textInfo);
  2525. protected static spssSetTextInfoDelegate spssSetTextInfoImpl;
  2526. /// <summary>
  2527. /// Sets the value of a string variable.
  2528. /// </summary>
  2529. /// <param name="handle">
  2530. /// Handle to the data file
  2531. /// </param>
  2532. /// <param name="varHandle">
  2533. /// Handle to the variable
  2534. /// </param>
  2535. /// <param name="value">
  2536. /// Value of the variable as a null-terminated string. The length of the
  2537. /// string (ignoring trailing blanks, if any) should be less than or equal
  2538. /// to the length of the variable.
  2539. /// </param>
  2540. /// <returns>
  2541. /// <see cref="ReturnCode.SPSS_OK"/>,
  2542. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2543. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2544. /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>,
  2545. /// <see cref="ReturnCode.SPSS_STR_EXP"/>, or
  2546. /// <see cref="ReturnCode.SPSS_EXC_STRVALUE"/>.
  2547. /// </returns>
  2548. /// <remarks>
  2549. /// This function sets the value of a string variable for the current case. The current case is
  2550. /// not written out to the data file until <see cref="spssCommitCaseRecordDelegate"/> is called.
  2551. /// </remarks>
  2552. protected delegate ReturnCode spssSetValueCharDelegate(int handle, double varHandle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string value);
  2553. protected static spssSetValueCharDelegate spssSetValueCharImpl;
  2554. /// <summary>
  2555. /// Sets the value of a numeric variable.
  2556. /// </summary>
  2557. /// <param name="handle">
  2558. /// Handle to the data file
  2559. /// </param>
  2560. /// <param name="varHandle">
  2561. /// Handle to the variable
  2562. /// </param>
  2563. /// <param name="value">
  2564. /// Value of the variable
  2565. /// </param>
  2566. /// <returns>
  2567. /// <see cref="ReturnCode.SPSS_OK"/>,
  2568. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2569. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2570. /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>, or
  2571. /// <see cref="ReturnCode.SPSS_NUME_EXP"/>.
  2572. /// </returns>
  2573. /// <remarks>
  2574. /// This function sets the value of a numeric variable for the current case. The current case
  2575. /// is not written out to the data file until <see cref="spssCommitCaseRecordDelegate"/> is called.
  2576. /// </remarks>
  2577. public delegate ReturnCode spssSetValueNumericDelegate(int handle, double varHandle, double value);
  2578. public static spssSetValueNumericDelegate spssSetValueNumeric;
  2579. /// <summary>
  2580. /// Sets the alignment of a variable.
  2581. /// </summary>
  2582. /// <param name="handle">
  2583. /// Handle to the data file
  2584. /// </param>
  2585. /// <param name="varName">
  2586. /// Variable name
  2587. /// </param>
  2588. /// <param name="alignment">
  2589. /// Alignment. Must be one of <see cref="AlignmentCode.SPSS_ALIGN_LEFT"/>,
  2590. /// <see cref="AlignmentCode.SPSS_ALIGN_RIGHT"/>, or
  2591. /// <see cref="AlignmentCode.SPSS_ALIGN_CENTER"/>. If not a legal
  2592. /// value, alignment is set to a type-appropriate default
  2593. /// </param>
  2594. /// <returns>
  2595. /// <see cref="ReturnCode.SPSS_OK"/>,
  2596. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2597. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2598. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2599. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
  2600. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  2601. /// </returns>
  2602. /// <remarks>
  2603. /// This function sets the value of the alignment attribute of a variable.
  2604. /// </remarks>
  2605. protected delegate ReturnCode spssSetVarAlignmentDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, AlignmentCode alignment);
  2606. protected static spssSetVarAlignmentDelegate spssSetVarAlignmentImpl;
  2607. /// <summary>
  2608. /// Sets missing values for a short string variable.
  2609. /// </summary>
  2610. /// <param name="handle">
  2611. /// Handle to the data file
  2612. /// </param>
  2613. /// <param name="varName">
  2614. /// Variable name
  2615. /// </param>
  2616. /// <param name="missingFormat">
  2617. /// The number of missing values (0-3) actually supplied.
  2618. /// </param>
  2619. /// <param name="missingVal1">
  2620. /// First missing value
  2621. /// </param>
  2622. /// <param name="missingVal2">
  2623. /// Second missing value
  2624. /// </param>
  2625. /// <param name="missingVal3">
  2626. /// Third missing value
  2627. /// </param>
  2628. /// <returns>
  2629. /// <see cref="ReturnCode.SPSS_OK"/>,
  2630. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2631. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2632. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2633. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  2634. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  2635. /// <see cref="ReturnCode.SPSS_STR_EXP"/>,
  2636. /// <see cref="ReturnCode.SPSS_SHORTSTR_EXP"/>,
  2637. /// <see cref="ReturnCode.SPSS_INVALID_MISSFOR"/>,
  2638. /// <see cref="ReturnCode.SPSS_EXC_STRVALUE"/>, or
  2639. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2640. /// </returns>
  2641. /// <remarks>
  2642. /// This function sets missing values for a short string variable. The argument
  2643. /// missingFormat must be set to a value in the range 0–3 to indicate the number of missing
  2644. /// values supplied. When fewer than three missing values are to be defined, the redundant
  2645. /// arguments must still be present, although their values are not inspected. For example,
  2646. /// if missingFormat is 2, missingVal3 is unused. The supplied missing values must be nullterminated
  2647. /// and not longer than the length of the variable unless the excess length is
  2648. /// made up of blanks, which are ignored. If the missing value is shorter than the length of
  2649. /// the variable, trailing blanks are assumed.
  2650. /// </remarks>
  2651. protected delegate ReturnCode spssSetVarCMissingValuesDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, MissingValueFormatCode missingFormat, [MarshalAs(UnmanagedType.VBByRefStr)] ref string missingVal1, [MarshalAs(UnmanagedType.VBByRefStr)] ref string missingVal2, [MarshalAs(UnmanagedType.VBByRefStr)] ref string missingVal3);
  2652. protected static spssSetVarCMissingValuesDelegate spssSetVarCMissingValuesImpl;
  2653. /// <summary>
  2654. /// Sets the column width of a variable.
  2655. /// </summary>
  2656. /// <param name="handle">
  2657. /// Handle to the data file
  2658. /// </param>
  2659. /// <param name="varName">
  2660. /// Variable name
  2661. /// </param>
  2662. /// <param name="columnWidth">
  2663. /// Column width. If negative, a value of zero is (quietly) used instead
  2664. /// </param>
  2665. /// <returns>
  2666. /// <see cref="ReturnCode.SPSS_OK"/>,
  2667. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2668. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2669. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2670. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
  2671. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
  2672. /// </returns>
  2673. /// <remarks>
  2674. /// This function sets the value of the column width attribute of a variable. A value of zero
  2675. /// is special and means that the SPSS Data Editor, which is the primary user of this
  2676. /// attribute, is to set an appropriate width using its own algorithm.
  2677. /// </remarks>
  2678. protected delegate ReturnCode spssSetVarColumnWidthDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, int columnWidth);
  2679. protected static spssSetVarColumnWidthDelegate spssSetVarColumnWidthImpl;
  2680. /// <summary>
  2681. /// Changes or adds a value label for a short string variable.
  2682. /// </summary>
  2683. /// <param name="handle">
  2684. /// Handle to the data file
  2685. /// </param>
  2686. /// <param name="varName">
  2687. /// Variable name
  2688. /// </param>
  2689. /// <param name="value">
  2690. /// Value to be labeled
  2691. /// </param>
  2692. /// <param name="label">
  2693. /// Label
  2694. /// </param>
  2695. /// <returns>
  2696. /// <see cref="ReturnCode.SPSS_OK"/>,
  2697. /// <see cref="ReturnCode.SPSS_EXC_LEN60"/>,
  2698. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2699. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2700. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2701. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  2702. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  2703. /// <see cref="ReturnCode.SPSS_STR_EXP"/>,
  2704. /// <see cref="ReturnCode.SPSS_SHORTSTR_EXP"/>,
  2705. /// <see cref="ReturnCode.SPSS_EXC_STRVALUE"/>,
  2706. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>, or
  2707. /// <see cref="ReturnCode.SPSS_INTERNAL_VLABS"/>.
  2708. /// </returns>
  2709. /// <remarks>
  2710. /// This function changes or adds a value label for the specified value of a short string
  2711. /// variable. The label should be a null-terminated string not exceeding 60 characters in
  2712. /// length.
  2713. /// </remarks>
  2714. protected delegate ReturnCode spssSetVarCValueLabelDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, [MarshalAs(UnmanagedType.VBByRefStr)] ref string value, [MarshalAs(UnmanagedType.VBByRefStr)] ref string label);
  2715. protected static spssSetVarCValueLabelDelegate spssSetVarCValueLabelImpl;
  2716. /// <summary>
  2717. /// Sets the variable sets information in a data file.
  2718. /// </summary>
  2719. /// <param name="handle">
  2720. /// Handle to the data file
  2721. /// </param>
  2722. /// <param name="varSets">
  2723. /// Variable sets information
  2724. /// </param>
  2725. /// <returns>
  2726. /// <see cref="ReturnCode.SPSS_OK"/>,
  2727. /// <see cref="ReturnCode.SPSS_EMPTY_VARSETS"/>,
  2728. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2729. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2730. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>, or
  2731. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2732. /// </returns>
  2733. /// <remarks>
  2734. /// This function sets the variable sets information in the data file. The information must
  2735. /// be provided in the form of a null-terminated string. No validity checks are performed
  2736. /// on the supplied string beyond ensuring that its length is not 0. Any existing variable
  2737. /// sets information is discarded.
  2738. /// </remarks>
  2739. protected delegate ReturnCode spssSetVariableSetsDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varSets);
  2740. protected static spssSetVariableSetsDelegate spssSetVariableSetsImpl;
  2741. /// <summary>
  2742. /// Sets the label of a variable.
  2743. /// </summary>
  2744. /// <param name="handle">
  2745. /// Handle to the data file
  2746. /// </param>
  2747. /// <param name="varName">
  2748. /// Variable name
  2749. /// </param>
  2750. /// <param name="varLabel">
  2751. /// Variable label. The length of the string should not exceed 120 characters.
  2752. /// If varLabel is the empty string, the existing label, if any, is
  2753. /// deleted.
  2754. /// </param>
  2755. /// <returns>
  2756. /// <see cref="ReturnCode.SPSS_OK"/>,
  2757. /// <see cref="ReturnCode.SPSS_EXC_LEN120"/>,
  2758. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2759. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2760. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2761. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  2762. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
  2763. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2764. /// </returns>
  2765. /// <remarks>
  2766. /// This function sets the label of a variable.
  2767. /// </remarks>
  2768. protected delegate ReturnCode spssSetVarLabelDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varLabel);
  2769. protected static spssSetVarLabelDelegate spssSetVarLabelImpl;
  2770. /// <summary>
  2771. /// Sets the measurement level of a variable.
  2772. /// </summary>
  2773. /// <param name="handle">
  2774. /// Handle to the data file
  2775. /// </param>
  2776. /// <param name="varName">
  2777. /// Variable name
  2778. /// </param>
  2779. /// <param name="measureLevel">
  2780. /// Measurement level. Must be one of <see cref="MeasurementLevelCode.SPSS_MLVL_NOM"/>,
  2781. /// <see cref="MeasurementLevelCode.SPSS_MLVL_ORD"/>,
  2782. /// <see cref="MeasurementLevelCode.SPSS_MLVL_RAT"/>, or
  2783. /// <see cref="MeasurementLevelCode.SPSS_MLVL_UNK"/> for
  2784. /// nominal, ordinal, scale (ratio), and unknown, respectively. If
  2785. /// <see cref="MeasurementLevelCode.SPSS_MLVL_UNK"/>,
  2786. /// measurement level is set to a type-appropriate default.
  2787. /// </param>
  2788. /// <returns>
  2789. /// <see cref="ReturnCode.SPSS_OK"/>,
  2790. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2791. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2792. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2793. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  2794. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
  2795. /// <see cref="ReturnCode.SPSS_INVALID_MEASURELEVEL"/>.
  2796. /// </returns>
  2797. /// <remarks>
  2798. /// This function sets the value of the measurement level attribute of a variable.
  2799. /// </remarks>
  2800. protected delegate ReturnCode spssSetVarMeasureLevelDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, int measureLevel);
  2801. protected static spssSetVarMeasureLevelDelegate spssSetVarMeasureLevelImpl;
  2802. /// <summary>
  2803. /// Creates a new variable with a given name.
  2804. /// </summary>
  2805. /// <param name="handle">
  2806. /// Handle to the data file
  2807. /// </param>
  2808. /// <param name="varName">
  2809. /// Variable name
  2810. /// </param>
  2811. /// <param name="varType">
  2812. /// Type and size of the variable
  2813. /// </param>
  2814. /// <returns>
  2815. /// <list type="table">
  2816. /// <listheader>
  2817. /// <term>Error code</term>
  2818. /// <description>Description</description>
  2819. /// </listheader>
  2820. /// <item>
  2821. /// <term><see cref="ReturnCode.SPSS_OK"/></term>
  2822. /// <description>No error</description>
  2823. /// </item>
  2824. /// <item>
  2825. /// <term><see cref="ReturnCode.SPSS_INVALID_HANDLE"/></term>
  2826. /// <description>The file handle is not valid</description>
  2827. /// </item>
  2828. /// <item>
  2829. /// <term><see cref="ReturnCode.SPSS_OPEN_RDMODE"/></term>
  2830. /// <description>File is open for reading, not writing</description>
  2831. /// </item>
  2832. /// <item>
  2833. /// <term><see cref="ReturnCode.SPSS_DICT_COMMIT"/></term>
  2834. /// <description>Dictionary has already been written with <see cref="spssCommitHeaderDelegate"/></description>
  2835. /// </item>
  2836. /// <item>
  2837. /// <term><see cref="ReturnCode.SPSS_INVALID_VARTYPE"/></term>
  2838. /// <description>Invalid length code ( varLength is negative or exceeds 255)</description>
  2839. /// </item>
  2840. /// <item>
  2841. /// <term><see cref="ReturnCode.SPSS_INVALID_VARNAME"/></term>
  2842. /// <description>Variable name is invalid</description>
  2843. /// </item>
  2844. /// <item>
  2845. /// <term><see cref="ReturnCode.SPSS_DUP_VAR"/></term>
  2846. /// <description>There is already a variable with the same name</description>
  2847. /// </item>
  2848. /// <item>
  2849. /// <term><see cref="ReturnCode.SPSS_NO_MEMORY"/></term>
  2850. /// <description>Insufficient memory</description>
  2851. /// </item>
  2852. /// </list>
  2853. /// </returns>
  2854. /// <remarks>
  2855. /// This function creates a new variable named varName, which will be either numeric or
  2856. /// string based on varLength. If the latter is zero, a numeric variable with a default format
  2857. /// of F8.2 will be created; if it is greater than 0 and less than or equal to 255, a string variable
  2858. /// with length varLength will be created; any other value will be rejected as invalid.
  2859. /// For better readability, macros SPSS_NUMERIC and SPSS_STRING( length) may be
  2860. /// used as values for varLength.
  2861. /// </remarks>
  2862. protected delegate ReturnCode spssSetVarNameDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, int varType);
  2863. protected static spssSetVarNameDelegate spssSetVarNameImpl;
  2864. /// <summary>
  2865. /// Sets the missing values for a numeric variable.
  2866. /// </summary>
  2867. /// <param name="handle">
  2868. /// Handle to the data file
  2869. /// </param>
  2870. /// <param name="varName">
  2871. /// Variable name
  2872. /// </param>
  2873. /// <param name="missingFormat">
  2874. /// Missing values format code
  2875. /// </param>
  2876. /// <param name="missingVal1">
  2877. /// First missing value
  2878. /// </param>
  2879. /// <param name="missingVal2">
  2880. /// Second missing value
  2881. /// </param>
  2882. /// <param name="missingVal3">
  2883. /// Third missing value
  2884. /// </param>
  2885. /// <returns>
  2886. /// <see cref="ReturnCode.SPSS_OK"/>,
  2887. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2888. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2889. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2890. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  2891. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  2892. /// <see cref="ReturnCode.SPSS_NUME_EXP"/>,
  2893. /// <see cref="ReturnCode.SPSS_INVALID_MISSFOR"/>,
  2894. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2895. /// </returns>
  2896. /// <remarks>
  2897. /// This function sets missing values for a numeric variable. The interpretation of the
  2898. /// arguments missingVal1, missingVal2, and missingVal3 depends on the value of
  2899. /// missingFormat. If missingFormat is set to SPSS_MISS_RANGE, missingVal1 and
  2900. /// missingVal2 are taken as the upper and lower limits, respectively, of the range, and
  2901. /// missingVal3 is ignored. If missingFormat is SPSS_MISS_RANGEANDVAL, missingval1
  2902. /// and missingVal2 are taken as limits of the range and missingVal3 is taken as the discrete
  2903. /// missing value. If missingFormat is neither of the above, it must be in the range 0–3,
  2904. /// indicating the number of discrete missing values present. For example, if
  2905. /// missingFormat is 2, missingVal1 and missingVal2 are taken as two discrete missing
  2906. /// values and missingVal3 is ignored. (The macros SPSS_NO_MISSVAL,
  2907. /// SPSS_ONE_MISSVAL, SPSS_TWO_MISSVAL, and SPSS_THREE_MISSVAL may be
  2908. /// used as synonyms for 0–3.)
  2909. /// </remarks>
  2910. protected delegate ReturnCode spssSetVarNMissingValuesDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, MissingValueFormatCode missingFormat, double missingVal1, double missingVal2, double missingVal3);
  2911. protected static spssSetVarNMissingValuesDelegate spssSetVarNMissingValuesImpl;
  2912. /// <summary>
  2913. /// Changes or adds a value label to a numeric variable.
  2914. /// </summary>
  2915. /// <param name="handle">
  2916. /// Handle to the data file
  2917. /// </param>
  2918. /// <param name="varName">
  2919. /// Variable name
  2920. /// </param>
  2921. /// <param name="value">
  2922. /// Value to be labeled
  2923. /// </param>
  2924. /// <param name="label">
  2925. /// Label
  2926. /// </param>
  2927. /// <returns>
  2928. /// <see cref="ReturnCode.SPSS_OK"/>,
  2929. /// <see cref="ReturnCode.SPSS_EXC_LEN60"/>,
  2930. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2931. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2932. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2933. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  2934. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  2935. /// <see cref="ReturnCode.SPSS_NUME_EXP"/>,
  2936. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>, or
  2937. /// <see cref="ReturnCode.SPSS_INTERNAL_VLABS"/>.
  2938. /// </returns>
  2939. /// <remarks>
  2940. /// This function changes or adds a value label for the specified value of a numeric
  2941. /// variable. The label should be a null-terminated string not exceeding 60 characters in
  2942. /// length.
  2943. /// </remarks>
  2944. protected delegate ReturnCode spssSetVarNValueLabelDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, double value, [MarshalAs(UnmanagedType.VBByRefStr)] ref string label);
  2945. protected static spssSetVarNValueLabelDelegate spssSetVarNValueLabelImpl;
  2946. /// <summary>
  2947. /// Sets the print format of a variable.
  2948. /// </summary>
  2949. /// <param name="handle">
  2950. /// Handle to the data file
  2951. /// </param>
  2952. /// <param name="varName">
  2953. /// Variable name
  2954. /// </param>
  2955. /// <param name="printType">
  2956. /// Print format type code (file spssdio.h defines macros of the form
  2957. /// <see cref="FormatTypeCode">SPSS_FMT_...</see> for all
  2958. /// valid format type codes)
  2959. /// </param>
  2960. /// <param name="printDec">
  2961. /// Number of digits after the decimal
  2962. /// </param>
  2963. /// <param name="printWidth">
  2964. /// Print format width
  2965. /// </param>
  2966. /// <returns>
  2967. /// <see cref="ReturnCode.SPSS_OK"/>,
  2968. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  2969. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  2970. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  2971. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  2972. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  2973. /// <see cref="ReturnCode.SPSS_INVALID_PRFOR"/>, or
  2974. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  2975. /// </returns>
  2976. /// <remarks>
  2977. /// This function sets the print format of a variable.
  2978. /// </remarks>
  2979. protected delegate ReturnCode spssSetVarPrintFormatDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, FormatTypeCode printType, int printDec, int printWidth);
  2980. protected static spssSetVarPrintFormatDelegate spssSetVarPrintFormatImpl;
  2981. /// <summary>
  2982. /// Sets the write format of a variable.
  2983. /// </summary>
  2984. /// <param name="handle">
  2985. /// Handle to the data file
  2986. /// </param>
  2987. /// <param name="varName">
  2988. /// Variable name
  2989. /// </param>
  2990. /// <param name="writeType">
  2991. /// Write format type code (file spssdio.h defines macros of the form
  2992. /// <see cref="FormatTypeCode">SPSS_FMT_...</see> for all valid format type codes)
  2993. /// </param>
  2994. /// <param name="writeDec">
  2995. /// Number of digits after the decimal
  2996. /// </param>
  2997. /// <param name="writeWidth">
  2998. /// Write format width
  2999. /// </param>
  3000. /// <returns>
  3001. /// <see cref="ReturnCode.SPSS_OK"/>,
  3002. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  3003. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  3004. /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
  3005. /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
  3006. /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
  3007. /// <see cref="ReturnCode.SPSS_INVALID_WRFOR"/>, or
  3008. /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
  3009. /// </returns>
  3010. /// <remarks>
  3011. /// This function sets the write format of a variable.
  3012. /// </remarks>
  3013. protected delegate ReturnCode spssSetVarWriteFormatDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string varName, FormatTypeCode writeType, int writeDec, int writeWidth);
  3014. protected static spssSetVarWriteFormatDelegate spssSetVarWriteFormatImpl;
  3015. /// <summary>
  3016. /// Gets the system missing value.
  3017. /// </summary>
  3018. /// <returns>
  3019. /// The SPSS system-missing value for the host system.
  3020. /// </returns>
  3021. /// <remarks>
  3022. /// This function returns the SPSS system-missing value for the host system. It may be
  3023. /// called at any time.
  3024. /// </remarks>
  3025. public delegate double spssSysmisValDelegate();
  3026. public static spssSysmisValDelegate spssSysmisValImpl;
  3027. /// <summary>
  3028. /// Reads in the raw data for an entire case.
  3029. /// </summary>
  3030. /// <param name="handle">
  3031. /// Handle to the data file
  3032. /// </param>
  3033. /// <param name="caseRec">
  3034. /// Buffer to contain the case
  3035. /// </param>
  3036. /// <returns>
  3037. /// <see cref="ReturnCode.SPSS_OK"/>,
  3038. /// <see cref="ReturnCode.SPSS_FILE_END"/>,
  3039. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  3040. /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>, or
  3041. /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>.
  3042. /// </returns>
  3043. /// <remarks>
  3044. /// This function reads a case from a data file into a case buffer provided by the user. The
  3045. /// required size of the buffer may be obtained by calling <see cref="spssGetCaseSizeDelegate"/>. This is a fairly
  3046. /// low-level function whose use should not be mixed with calls to <see cref="spssReadCaseRecordDelegate"/>
  3047. /// using the same file handle because both procedures read a new case from the data file.
  3048. /// </remarks>
  3049. protected delegate ReturnCode spssWholeCaseInDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string caseRec);
  3050. protected static spssWholeCaseInDelegate spssWholeCaseInImpl;
  3051. /// <summary>
  3052. /// Writes out raw data as a case.
  3053. /// </summary>
  3054. /// <param name="handle">
  3055. /// Handle to the data file
  3056. /// </param>
  3057. /// <param name="caseRec">
  3058. /// Case record to be written to the data file
  3059. /// </param>
  3060. /// <returns>
  3061. /// <see cref="ReturnCode.SPSS_OK"/>,
  3062. /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
  3063. /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
  3064. /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>, or
  3065. /// <see cref="ReturnCode.SPSS_FILE_WERROR"/>.
  3066. /// </returns>
  3067. /// <remarks>
  3068. /// This function writes a case assembled by the caller to a data file. The case is assumed
  3069. /// to have been constructed correctly in the buffer caseRec, and its validity is not
  3070. /// checked. This is a fairly low-level function whose use should not be mixed with calls
  3071. /// to <see cref="spssCommitCaseRecordDelegate"/> using the same file handle because both procedures write a
  3072. /// new case to the data file.
  3073. /// </remarks>
  3074. protected delegate ReturnCode spssWholeCaseOutDelegate(int handle, [MarshalAs(UnmanagedType.VBByRefStr)] ref string caseRec);
  3075. protected static spssWholeCaseOutDelegate spssWholeCaseOutImpl;
  3076. /// <summary>
  3077. /// Constructor for <see cref="SpssThinWrapper"/> class. Not to be used.
  3078. /// </summary>
  3079. /// <remarks>
  3080. /// This class is a static class, and should not be instantiated.
  3081. /// </remarks>
  3082. protected SpssThinWrapper()
  3083. {
  3084. } // no construction
  3085. static SpssThinWrapper()
  3086. {
  3087. LoadSpssDll();
  3088. }
  3089. /// <summary>
  3090. /// Allow only a single thread to enter.
  3091. ///
  3092. /// <seealso href="http://archive.msdn.microsoft.com/DynamicDllLoading/Wiki/Print.aspx?title=Home&amp;version=5&amp;action=Print"/>
  3093. /// </summary>
  3094. [MethodImpl(MethodImplOptions.Synchronized)]
  3095. internal static void LoadSpssDll()
  3096. {
  3097. String dllPath = String.Empty;
  3098. //SW: original change had a call to Environment.Is64BitOperatingSystem
  3099. // decided to exclude this to retain compatibility with .Net 3.5 for now
  3100. // similarly call to Environment.Is64BitProcess change to an IntPtr.Size
  3101. // check
  3102. switch (IntPtr.Size)
  3103. {
  3104. case 8:
  3105. Debug.WriteLine("Loading x64 spssio64.dll from '" + spssio64 + "'.");
  3106. dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, spssio64);
  3107. break;
  3108. case 4:
  3109. Debug.WriteLine("Loading x86 spssio32.dll from '" + spssio32 + "'.");
  3110. dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, spssio32);
  3111. break;
  3112. }
  3113. if (spssDllHandle != IntPtr.Zero)
  3114. {
  3115. Debug.WriteLine("Spssio dll is already loaded!");
  3116. return;
  3117. }
  3118. //Temporary add the x86 or x64 directory to the dll loading path so the corresponding icu*.dll files also load correctly.
  3119. SetDllDirectory(Path.GetDirectoryName(dllPath));
  3120. spssDllHandle = LoadLibrary(dllPath);
  3121. if (spssDllHandle == IntPtr.Zero)
  3122. {
  3123. throw new DllNotFoundException(string.Format("{0} not found.", dllPath));
  3124. }
  3125. //Revert the dll loading path to normal.
  3126. SetDllDirectory(null);
  3127. spssCloseAppendImpl = (spssCloseAppendDelegate)GetSpssDelegate("spssCloseAppend", typeof(spssCloseAppendDelegate));
  3128. spssCloseReadImpl = (spssCloseReadDelegate)GetSpssDelegate("spssCloseRead", typeof(spssCloseReadDelegate));
  3129. spssCloseWriteImpl = (spssCloseWriteDelegate)GetSpssDelegate("spssCloseWrite", typeof(spssCloseWriteDelegate));
  3130. spssCommitCaseRecordImpl = (spssCommitCaseRecordDelegate)GetSpssDelegate("spssCommitCaseRecord", typeof(spssCommitCaseRecordDelegate));
  3131. spssCommitHeaderImpl = (spssCommitHeaderDelegate)GetSpssDelegate("spssCommitHeader", typeof(spssCommitHeaderDelegate));
  3132. spssConvertDateImpl = (spssConvertDateDelegate)GetSpssDelegate("spssConvertDate", typeof(spssConvertDateDelegate));
  3133. spssConvertSPSSDateImpl = (spssConvertSPSSDateDelegate)GetSpssDelegate("spssConvertSPSSDate", typeof(spssConvertSPSSDateDelegate));
  3134. spssConvertSPSSTimeImpl = (spssConvertSPSSTimeDelegate)GetSpssDelegate("spssConvertSPSSTime", typeof(spssConvertSPSSTimeDelegate));
  3135. spssConvertTimeImpl = (spssConvertTimeDelegate)GetSpssDelegate("spssConvertTime", typeof(spssConvertTimeDelegate));
  3136. spssCopyDocumentsImpl = (spssCopyDocumentsDelegate)GetSpssDelegate("spssCopyDocuments", typeof(spssCopyDocumentsDelegate));
  3137. spssFreeDateVariablesImpl = (spssFreeDateVariablesDelegate)GetSpssDelegate("spssFreeDateVariables", typeof(spssFreeDateVariablesDelegate));
  3138. spssFreeMultRespDefsImpl = (spssFreeMultRespDefsDelegate)GetSpssDelegate("spssFreeMultRespDefs", typeof(spssFreeMultRespDefsDelegate));
  3139. spssFreeVarCValueLabelsImpl = (spssFreeVarCValueLabelsDelegate)GetSpssDelegate("spssFreeVarCValueLabels", typeof(spssFreeVarCValueLabelsDelegate));
  3140. spssFreeVariableSetsImpl = (spssFreeVariableSetsDelegate)GetSpssDelegate("spssFreeVariableSets", typeof(spssFreeVariableSetsDelegate));
  3141. spssFreeVarNamesImpl = (spssFreeVarNamesDelegate)GetSpssDelegate("spssFreeVarNames", typeof(spssFreeVarNamesDelegate));
  3142. spssFreeVarNValueLabels = (spssFreeVarNValueLabelsDelegate)GetSpssDelegate("spssFreeVarNValueLabels", typeof(spssFreeVarNValueLabelsDelegate));
  3143. spssGetCaseSizeImpl = (spssGetCaseSizeDelegate)GetSpssDelegate("spssGetCaseSize", typeof(spssGetCaseSizeDelegate));
  3144. spssGetCaseWeightVarImpl = (spssGetCaseWeightVarDelegate)GetSpssDelegate("spssGetCaseWeightVar", typeof(spssGetCaseWeightVarDelegate));
  3145. spssGetCompressionImpl = (spssGetCompressionDelegate)GetSpssDelegate("spssGetCompression", typeof(spssGetCompressionDelegate));
  3146. spssGetDateVariablesImpl = (spssGetDateVariablesDelegate)GetSpssDelegate("spssGetDateVariables", typeof(spssGetDateVariablesDelegate));
  3147. spssGetDEWFirstImpl = (spssGetDEWFirstDelegate)GetSpssDelegate("spssGetDEWFirst", typeof(spssGetDEWFirstDelegate));
  3148. spssGetDEWGUIDImpl = (spssGetDEWGUIDDelegate)GetSpssDelegate("spssGetDEWGUID", typeof(spssGetDEWGUIDDelegate));
  3149. spssGetDEWInfoImpl = (spssGetDEWInfoDelegate)GetSpssDelegate("spssGetDEWInfo", typeof(spssGetDEWInfoDelegate));
  3150. spssGetDEWNextImpl = (spssGetDEWNextDelegate)GetSpssDelegate("spssGetDEWNext", typeof(spssGetDEWNextDelegate));
  3151. spssGetEstimatedNofCasesImpl = (spssGetEstimatedNofCasesDelegate)GetSpssDelegate("spssGetEstimatedNofCases", typeof(spssGetEstimatedNofCasesDelegate));
  3152. spssGetNumberofCasesImpl = (spssGetNumberofCasesDelegate)GetSpssDelegate("spssGetNumberofCases", typeof(spssGetNumberofCasesDelegate));
  3153. spssGetIdStringImpl = (spssGetIdStringDelegate)GetSpssDelegate("spssGetIdString", typeof(spssGetIdStringDelegate));
  3154. spssGetMultRespDefsImpl = (spssGetMultRespDefsDelegate)GetSpssDelegate("spssGetMultRespDefs", typeof(spssGetMultRespDefsDelegate));
  3155. spssGetNumberofVariables = (spssGetNumberofVariablesDelegate)GetSpssDelegate("spssGetNumberofVariables", typeof(spssGetNumberofVariablesDelegate));
  3156. spssGetReleaseInfoImpl = (spssGetReleaseInfoDelegate)GetSpssDelegate("spssGetReleaseInfo", typeof(spssGetReleaseInfoDelegate));
  3157. spssGetSystemStringImpl = (spssGetSystemStringDelegate)GetSpssDelegate("spssGetSystemString", typeof(spssGetSystemStringDelegate));
  3158. spssGetTextInfoImpl = (spssGetTextInfoDelegate)GetSpssDelegate("spssGetTextInfo", typeof(spssGetTextInfoDelegate));
  3159. spssGetTimeStampImpl = (spssGetTimeStampDelegate)GetSpssDelegate("spssGetTimeStamp", typeof(spssGetTimeStampDelegate));
  3160. spssGetValueCharImpl = (spssGetValueCharDelegate)GetSpssDelegate("spssGetValueChar", typeof(spssGetValueCharDelegate));
  3161. spssGetValueNumericImpl = (spssGetValueNumericDelegate)GetSpssDelegate("spssGetValueNumeric", typeof(spssGetValueNumericDelegate));
  3162. spssGetVarAlignmentImpl = (spssGetVarAlignmentDelegate)GetSpssDelegate("spssGetVarAlignment", typeof(spssGetVarAlignmentDelegate));
  3163. spssGetVarCMissingValuesImpl = (spssGetVarCMissingValuesDelegate)GetSpssDelegate("spssGetVarCMissingValues", typeof(spssGetVarCMissingValuesDelegate));
  3164. spssGetVarColumnWidthImpl = (spssGetVarColumnWidthDelegate)GetSpssDelegate("spssGetVarColumnWidth", typeof(spssGetVarColumnWidthDelegate));
  3165. spssGetVarCValueLabelImpl = (spssGetVarCValueLabelDelegate)GetSpssDelegate("spssGetVarCValueLabel", typeof(spssGetVarCValueLabelDelegate));
  3166. spssGetVarCValueLabelLongImpl = (spssGetVarCValueLabelLongDelegate)GetSpssDelegate("spssGetVarCValueLabelLong", typeof(spssGetVarCValueLabelLongDelegate));
  3167. spssGetVarCValueLabelsImpl = (spssGetVarCValueLabelsDelegate)GetSpssDelegate("spssGetVarCValueLabels", typeof(spssGetVarCValueLabelsDelegate));
  3168. spssGetVarHandleImpl = (spssGetVarHandleDelegate)GetSpssDelegate("spssGetVarHandle", typeof(spssGetVarHandleDelegate));
  3169. spssGetVariableSetsImpl = (spssGetVariableSetsDelegate)GetSpssDelegate("spssGetVariableSets", typeof(spssGetVariableSetsDelegate));
  3170. spssGetVarInfoImpl = (spssGetVarInfoDelegate)GetSpssDelegate("spssGetVarInfo", typeof(spssGetVarInfoDelegate));
  3171. //! TODO Check if delegate is ok
  3172. spssGetVarLabelImplImpl = (spssGetVarLabelDelegate)GetSpssDelegate("spssGetVarLabel", typeof(spssGetVarLabelDelegate));
  3173. spssGetVarLabelLongImpl = (spssGetVarLabelLongDelegate)GetSpssDelegate("spssGetVarLabelLong", typeof(spssGetVarLabelLongDelegate));
  3174. spssGetVarMeasureLevelImpl = (spssGetVarMeasureLevelDelegate)GetSpssDelegate("spssGetVarMeasureLevel", typeof(spssGetVarMeasureLevelDelegate));
  3175. spssGetVarNMissingValuesImpl = (spssGetVarNMissingValuesDelegate)GetSpssDelegate("spssGetVarNMissingValues", typeof(spssGetVarNMissingValuesDelegate));
  3176. spssGetVarNValueLabelImpl = (spssGetVarNValueLabelDelegate)GetSpssDelegate("spssGetVarNValueLabel", typeof(spssGetVarNValueLabelDelegate));
  3177. spssGetVarNValueLabelLong = (spssGetVarNValueLabelLongDelegate)GetSpssDelegate("spssGetVarNValueLabelLong", typeof(spssGetVarNValueLabelLongDelegate));
  3178. spssGetVarNValueLabelsImpl = (spssGetVarNValueLabelsDelegate)GetSpssDelegate("spssGetVarNValueLabels", typeof(spssGetVarNValueLabelsDelegate));
  3179. spssGetVarPrintFormatImpl = (spssGetVarPrintFormatDelegate)GetSpssDelegate("spssGetVarPrintFormat", typeof(spssGetVarPrintFormatDelegate));
  3180. spssGetVarNamesImpl = (spssGetVarNamesDelegate)GetSpssDelegate("spssGetVarNames", typeof(spssGetVarNamesDelegate));
  3181. spssGetVarWriteFormatImpl = (spssGetVarWriteFormatDelegate)GetSpssDelegate("spssGetVarWriteFormat", typeof(spssGetVarWriteFormatDelegate));
  3182. spssHostSysmisValImpl = (spssHostSysmisValDelegate)GetSpssDelegate("spssHostSysmisVal", typeof(spssHostSysmisValDelegate));
  3183. spssLowHighValImpl = (spssLowHighValDelegate)GetSpssDelegate("spssLowHighVal", typeof(spssLowHighValDelegate));
  3184. spssOpenAppendImpl = (spssOpenAppendDelegate)GetSpssDelegate("spssOpenAppend", typeof(spssOpenAppendDelegate));
  3185. spssOpenReadImpl = (spssOpenReadDelegate)GetSpssDelegate("spssOpenRead", typeof(spssOpenReadDelegate));
  3186. spssOpenWriteImpl = (spssOpenWriteDelegate)GetSpssDelegate("spssOpenWrite", typeof(spssOpenWriteDelegate));
  3187. spssOpenWriteCopyImpl = (spssOpenWriteCopyDelegate)GetSpssDelegate("spssOpenWriteCopy", typeof(spssOpenWriteCopyDelegate));
  3188. spssQueryType7Impl = (spssQueryType7Delegate)GetSpssDelegate("spssQueryType7", typeof(spssQueryType7Delegate));
  3189. spssReadCaseRecord = (spssReadCaseRecordDelegate)GetSpssDelegate("spssReadCaseRecord", typeof(spssReadCaseRecordDelegate));
  3190. spssSeekNextCase = (spssSeekNextCaseDelegate)GetSpssDelegate("spssSeekNextCase", typeof(spssSeekNextCaseDelegate));
  3191. spssSetCaseWeightVarImpl = (spssSetCaseWeightVarDelegate)GetSpssDelegate("spssSetCaseWeightVar", typeof(spssSetCaseWeightVarDelegate));
  3192. spssSetCompression = (spssSetCompressionDelegate)GetSpssDelegate("spssSetCompression", typeof(spssSetCompressionDelegate));
  3193. spssSetDateVariablesImpl = (spssSetDateVariablesDelegate)GetSpssDelegate("spssSetDateVariables", typeof(spssSetDateVariablesDelegate));
  3194. spssSetDEWFirstImpl = (spssSetDEWFirstDelegate)GetSpssDelegate("spssSetDEWFirst", typeof(spssSetDEWFirstDelegate));
  3195. spssSetDEWGUIDImpl = (spssSetDEWGUIDDelegate)GetSpssDelegate("spssSetDEWGUID", typeof(spssSetDEWGUIDDelegate));
  3196. spssSetDEWNextImpl = (spssSetDEWNextDelegate)GetSpssDelegate("spssSetDEWNext", typeof(spssSetDEWNextDelegate));
  3197. spssSetIdStringImpl = (spssSetIdStringDelegate)GetSpssDelegate("spssSetIdString", typeof(spssSetIdStringDelegate));
  3198. spssSetMultRespDefsImpl = (spssSetMultRespDefsDelegate)GetSpssDelegate("spssSetMultRespDefs", typeof(spssSetMultRespDefsDelegate));
  3199. spssSetTextInfoImpl = (spssSetTextInfoDelegate)GetSpssDelegate("spssSetTextInfo", typeof(spssSetTextInfoDelegate));
  3200. spssSetValueCharImpl = (spssSetValueCharDelegate)GetSpssDelegate("spssSetValueChar", typeof(spssSetValueCharDelegate));
  3201. spssSetValueNumeric = (spssSetValueNumericDelegate)GetSpssDelegate("spssSetValueNumeric", typeof(spssSetValueNumericDelegate));
  3202. spssSetVarAlignmentImpl = (spssSetVarAlignmentDelegate)GetSpssDelegate("spssSetVarAlignment", typeof(spssSetVarAlignmentDelegate));
  3203. spssSetVarCMissingValuesImpl = (spssSetVarCMissingValuesDelegate)GetSpssDelegate("spssSetVarCMissingValues", typeof(spssSetVarCMissingValuesDelegate));
  3204. spssSetVarColumnWidthImpl = (spssSetVarColumnWidthDelegate)GetSpssDelegate("spssSetVarColumnWidth", typeof(spssSetVarColumnWidthDelegate));
  3205. spssSetVarCValueLabelImpl = (spssSetVarCValueLabelDelegate)GetSpssDelegate("spssSetVarCValueLabel", typeof(spssSetVarCValueLabelDelegate));
  3206. spssSetVariableSetsImpl = (spssSetVariableSetsDelegate)GetSpssDelegate("spssSetVariableSets", typeof(spssSetVariableSetsDelegate));
  3207. spssSetVarLabelImpl = (spssSetVarLabelDelegate)GetSpssDelegate("spssSetVarLabel", typeof(spssSetVarLabelDelegate));
  3208. spssSetVarMeasureLevelImpl = (spssSetVarMeasureLevelDelegate)GetSpssDelegate("spssSetVarMeasureLevel", typeof(spssSetVarMeasureLevelDelegate));
  3209. spssSetVarNameImpl = (spssSetVarNameDelegate)GetSpssDelegate("spssSetVarName", typeof(spssSetVarNameDelegate));
  3210. spssSetVarNMissingValuesImpl = (spssSetVarNMissingValuesDelegate)GetSpssDelegate("spssSetVarNMissingValues", typeof(spssSetVarNMissingValuesDelegate));
  3211. spssSetVarNValueLabelImpl = (spssSetVarNValueLabelDelegate)GetSpssDelegate("spssSetVarNValueLabel", typeof(spssSetVarNValueLabelDelegate));
  3212. spssSetVarPrintFormatImpl = (spssSetVarPrintFormatDelegate)GetSpssDelegate("spssSetVarPrintFormat", typeof(spssSetVarPrintFormatDelegate));
  3213. spssSetVarWriteFormatImpl = (spssSetVarWriteFormatDelegate)GetSpssDelegate("spssSetVarWriteFormat", typeof(spssSetVarWriteFormatDelegate));
  3214. spssSysmisValImpl = (spssSysmisValDelegate)GetSpssDelegate("spssSysmisVal", typeof(spssSysmisValDelegate));
  3215. spssWholeCaseInImpl = (spssWholeCaseInDelegate)GetSpssDelegate("spssWholeCaseIn", typeof(spssWholeCaseInDelegate));
  3216. spssWholeCaseOutImpl = (spssWholeCaseOutDelegate)GetSpssDelegate("spssWholeCaseOut", typeof(spssWholeCaseOutDelegate));
  3217. }
  3218. static IntPtr spssDllHandle = IntPtr.Zero;
  3219. private static readonly object _lock = new object();
  3220. internal static Delegate GetSpssDelegate(string procName, Type delegateType)
  3221. {
  3222. Debug.WriteLine("Loading: " + procName);
  3223. IntPtr procAdress = GetProcAddress(spssDllHandle, procName);
  3224. if (procAdress == IntPtr.Zero)
  3225. {
  3226. throw new EntryPointNotFoundException("Spss function: " + procName);
  3227. }
  3228. try
  3229. {
  3230. return Marshal.GetDelegateForFunctionPointer(procAdress, delegateType);
  3231. }
  3232. catch (ArgumentNullException e)
  3233. {
  3234. Debug.WriteLine(e.Message);
  3235. }
  3236. catch (ArgumentException e)
  3237. {
  3238. Debug.WriteLine(e.Message);
  3239. }
  3240. return null;
  3241. }
  3242. [DllImport("kernel32.dll", CharSet = CharSet.Ansi)]
  3243. internal static extern IntPtr LoadLibrary(string fileName);
  3244. [DllImport("kernel32.dll", SetLastError = true)]
  3245. static extern bool FreeLibrary(IntPtr hModule);
  3246. [DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  3247. internal static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
  3248. [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true /*, CallingConvention = CallingConvention.Cdecl*/)]
  3249. internal static extern bool SetDllDirectory(string pathName);
  3250. }
  3251. }