/Spss/SpssSafeWrapper.cs
C# | 1990 lines | 483 code | 35 blank | 1472 comment | 49 complexity | 64713a1d4b30e9c4fc1db0fe322ff097 MD5 | raw file
Possible License(s): LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- using System;
- using System.Runtime.InteropServices;
-
- namespace Spss
- {
-
- /// <summary>
- /// Very thin SpssSafeWrapper class for functions exposed by spssio32.dll.
- /// </summary>
- [CLSCompliant(false)]
- public class SpssSafeWrapper : SpssThinWrapper
- {
- /// <summary>
- /// Creates an instance of the <see cref="SpssSafeWrapper"/> class.
- /// </summary>
- protected SpssSafeWrapper()
- {
- }
-
- // These lengths were extracted from the SPSS documentation
- // rather than any header file.
- public const int SPSS_GUID_LENGTH = 256;
- public const int SPSS_SYSTEM_STRING_LENGTH = 41;
- public const int SPSS_MAX_TEXTINFO = 255;
- public const int SPSS_DATESTAMP_LENGTH = 9;
- public const int SPSS_TIMESTAMP_LENGTH = 8;
-
- #region veg
-
- public static Int32 SPSS_STRING(Int32 size)
- {
- return size;
- }
-
- public const Int32 SPSS_NUMERIC = 0;
-
- #endregion veg
-
- /// <summary>
- /// Opens an SPSS file for reading.
- /// </summary>
- /// <param name="fileName">
- /// Name of the file.
- /// </param>
- /// <param name="handle">
- /// The handle to the opened file.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_FITAB_FULL"/>,
- /// <see cref="ReturnCode.SPSS_FILE_OERROR"/>,
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>,
- /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>,
- /// <see cref="ReturnCode.SPSS_NO_TYPE2"/>, or
- /// <see cref="ReturnCode.SPSS_NO_TYPE999"/>.
- /// </returns>
- /// <remarks>
- /// This function opens an SPSS data file for reading and returns a handle that should be
- /// used for subsequent operations on the file.
- /// Files opened with spssOpenRead should be closed with <see cref="SpssThinWrapper.spssCloseReadDelegate"/>.
- /// </remarks>
- public static ReturnCode spssOpenRead(string fileName, out int handle)
- {
- return SpssThinWrapper.spssOpenReadImpl(ref fileName, out handle);
- }
- /// <summary>
- /// Creates an empty SPSS file.
- /// </summary>
- /// <param name="fileName">
- /// Name of the file.
- /// </param>
- /// <param name="handle">
- /// The handle to the new file.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_FITAB_FULL"/>,
- /// <see cref="ReturnCode.SPSS_FILE_OERROR"/>,
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>,
- /// </returns>
- /// <remarks>
- /// This function opens a file in preparation for creating a new SPSS data file and returns a
- /// handle that should be used for subsequent operations on the file.
- /// Files opened with spssOpenWrite should be closed with <see cref="SpssThinWrapper.spssCloseWriteDelegate"/>.
- /// </remarks>
- public static ReturnCode spssOpenWrite(string fileName, out int handle)
- {
- return SpssThinWrapper.spssOpenWriteImpl(ref fileName, out handle);
- }
- /// <summary>
- /// Reports the name of the case weight variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// The name of the case weight variable.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_NO_CASEWGT"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
- /// <see cref="ReturnCode.SPSS_INVALID_CASEWGT"/>.
- /// </returns>
- /// <remarks>
- /// This function reports the name of the case weight variable.
- /// </remarks>
- public static ReturnCode spssGetCaseWeightVar(int handle, out string varName)
- {
- varName = new string(' ', SPSS_MAX_VARNAME + 1);
- ReturnCode result = SpssThinWrapper.spssGetCaseWeightVarImpl(handle, ref varName);
- varName = (result == ReturnCode.SPSS_OK) ? varName.Substring(0, varName.IndexOf('\0')) : null;
- return result;
- }
- /// <summary>
- /// Retrieves the first block of SPSS Data Entry information from a data file.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="data">
- /// Data from the file.
- /// </param>
- /// <param name="maxData">
- /// Maximum bytes to return.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_NO_DEW"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
- /// <see cref="ReturnCode.SPSS_FILE_BADTEMP"/>.
- /// </returns>
- /// <remarks>
- /// The client can retrieve DEW information (file information that is private to the SPSS
- /// Data Entry product) from a file in whatever increments are convenient. The first such
- /// increment is retrieved by calling spssGetDEWFirst, and subsequent segments are
- /// retrieved by calling spssGetDEWNext as many times as necessary. As with
- /// spssGetDEWInfo, spssGetDEWFirst will return SPSS_NO_DEW if the file was written
- /// with a byte order that is the reverse of that of the host.
- /// </remarks>
- public static ReturnCode spssGetDEWFirst(int handle, out string data, int maxData)
- {
- data = new string(' ', maxData);
- int len;
- ReturnCode result = SpssThinWrapper.spssGetDEWFirstImpl(handle, ref data, data.Length, out len);
- data = (result == ReturnCode.SPSS_OK) ? data.Substring(0, len) : null;
- return result;
- }
- /// <summary>
- /// Gets the Data Entry GUID from a data file.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="asciiGUID">
- /// The file's GUID in character form or a null string if the
- /// file contains no GUID.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/> or
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
- /// </returns>
- /// <remarks>
- /// Data Entry for Windows maintains a GUID in character form as a uniqueness indicator.
- /// Two files have identical dictionaries and DEW information if they have the same
- /// GUID. Note that the spssOpenWriteCopy function will not copy the source files
- /// GUID. spssGetDEWGUID allows the client to read a files GUID, if any.
- /// </remarks>
- public static ReturnCode spssGetDEWGUID(int handle, out string asciiGUID)
- {
- asciiGUID = new string(' ', SPSS_GUID_LENGTH + 1);
- ReturnCode result = SpssThinWrapper.spssGetDEWGUIDImpl(handle, ref asciiGUID);
- // Although we search for a null terminator, the documentation
- // tells us that the GUID is always SPSS_GUID_LENGTH, so we COULD
- // just terminate the string there to trim off the null terminator that is
- // artificially put there.
- asciiGUID = (result == ReturnCode.SPSS_OK) ? asciiGUID.Substring(0, asciiGUID.IndexOf('\0')) : null;
- return result;
- }
- /// <summary>
- /// Retrieves the next block of SPSS Data Entry information from a data file.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="data">
- /// Data from the file.
- /// </param>
- /// <param name="maxData">
- /// Maximum bytes to return.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_DEW_NOFIRST"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
- /// <see cref="ReturnCode.SPSS_FILE_BADTEMP"/>.
- /// </returns>
- /// <remarks>
- /// The client can retrieve DEW information (file information that is private to the SPSS
- /// Data Entry product) from a file in whatever increments are convenient. The first such
- /// increment is retrieved by calling <see cref="spssGetDEWFirst"/>, and subsequent segments are
- /// retrieved by calling spssGetDEWNext as many times as necessary. As with
- /// <see cref="SpssThinWrapper.spssGetDEWInfoDelegate"/>, <see cref="spssGetDEWFirst"/> will return SPSS_NO_DEW if the file was written
- /// with a byte order that is the reverse of that of the host.
- /// </remarks>
- public static ReturnCode spssGetDEWNext(int handle, out string data, int maxData)
- {
- data = new string(' ', maxData);
- int len;
- ReturnCode result = SpssThinWrapper.spssGetDEWNextImpl(handle, ref data, data.Length, out len);
- data = (result == ReturnCode.SPSS_OK) ? data.Substring(0, len) : null;
- return result;
- }
- /// <summary>
- /// Gets the file label of a data file.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="id">
- /// File label.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/> or
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
- /// </returns>
- /// <remarks>
- /// This function retrieves the file label of the SPSS data file associated with
- /// <paramref>handle</paramref> into the <paramref>id</paramref> parameter.
- /// </remarks>
- public static ReturnCode spssGetIdString(int handle, out string id)
- {
- id = new string(' ', SPSS_MAX_IDSTRING + 1); // leave room for null terminator
- ReturnCode result = SpssThinWrapper.spssGetIdStringImpl(handle, ref id);
- id = (result == ReturnCode.SPSS_OK) ? id.Substring(0, id.IndexOf('\0')) : null;
- return result;
- }
- /// <summary>
- /// Gets information on the running version of SPSS, and the hosting computer.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="relInfo">
- /// Array of <see cref="int"/> in which release- and machine-specific data will be
- /// stored.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>, or
- /// <see cref="ReturnCode.SPSS_NO_TYPE73"/>.
- /// </returns>
- /// <remarks>
- /// This function reports release- and machine-specific information about the file
- /// associated with handle. The information consists of an array of eight int values copied
- /// from record type 7, subtype 3 of the file, and is useful primarily for debugging. The
- /// array elements are, in order, release number (index 0), release subnumber (1), special
- /// release identifier number (2), machine code (3), floating-point representation code (4),
- /// compression scheme code (5), big/little-endian code (6), and character representation
- /// code (7).
- /// </remarks>
- public static ReturnCode spssGetReleaseInfo(int handle, out int[] relInfo)
- {
- relInfo = new int[8];
- ReturnCode result = SpssThinWrapper.spssGetReleaseInfoImpl(handle, relInfo);
- return result;
- }
- /// <summary>
- /// Gets the name of the system that created a data file.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="sysName">
- /// The originating system name.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/> or
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
- /// </returns>
- /// <remarks>
- /// This function returns the name of the system under which the file was created.
- /// </remarks>
- public static ReturnCode spssGetSystemString(int handle, out string sysName)
- {
- sysName = new string(' ', SPSS_SYSTEM_STRING_LENGTH + 1); // leave room for null terminator
- ReturnCode result = SpssThinWrapper.spssGetSystemStringImpl(handle, ref sysName);
- sysName = (result == ReturnCode.SPSS_OK) ? sysName.Substring(0, sysName.IndexOf('\0')) : null;
- return result;
- }
- /// <summary>
- /// Gets the data created by TextSmart.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="textInfo">
- /// Text data.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/> or
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
- /// </returns>
- /// <remarks>
- /// This function retrieves the text data created by TextSmart.
- /// </remarks>
- public static ReturnCode spssGetTextInfo(int handle, out string textInfo)
- {
- textInfo = new string(' ', SPSS_MAX_TEXTINFO + 1);
- ReturnCode result = SpssThinWrapper.spssGetTextInfoImpl(handle, ref textInfo);
- textInfo = (result == ReturnCode.SPSS_OK) ? textInfo.Substring(0, textInfo.IndexOf('\0')) : null;
- return result;
- }
- /// <summary>
- /// Gets the creation date of a data file, as recorded in the file itself.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="fileDate">
- /// File creation date.
- /// </param>
- /// <param name="fileTime">
- /// File creation time.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/> or
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>.
- /// </returns>
- /// <remarks>
- /// This function returns the creation date of the file as recorded in the file itself. The creation
- /// date is a 9-byte string in dd mmm yy format (27 Feb 96). The creation time is a
- /// 8-byte oypcbi in hh:mm:ss format (13:12:15).
- /// </remarks>
- public static ReturnCode spssGetTimeStamp(int handle, out string fileDate, out string fileTime)
- {
- fileDate = new string(' ', SPSS_DATESTAMP_LENGTH + 1);
- fileTime = new string(' ', SPSS_TIMESTAMP_LENGTH + 1);
- ReturnCode result = SpssThinWrapper.spssGetTimeStampImpl(handle, ref fileDate, ref fileTime);
- fileDate = (result == ReturnCode.SPSS_OK) ? fileDate.Substring(0, fileDate.IndexOf('\0')) : null;
- fileTime = (result == ReturnCode.SPSS_OK) ? fileTime.Substring(0, fileTime.IndexOf('\0')) : null;
- return result;
- }
- /// <summary>
- /// Gets the string value of a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varHandle">
- /// Handle of the variable.
- /// </param>
- /// <param name="value">
- /// Value of the string variable.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_WRMODE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_CASE"/>,
- /// <see cref="ReturnCode.SPSS_STR_EXP"/>, or
- /// <see cref="ReturnCode.SPSS_BUFFER_SHORT"/>.
- /// </returns>
- /// <remarks>
- /// This function gets the value of a string variable for the current case, which is the case
- /// read by the most recent call to <see cref="SpssThinWrapper.spssReadCaseRecordDelegate"/>.
- /// </remarks>
- public static ReturnCode spssGetValueChar(int handle, double varHandle, out string value)
- {
- value = new string(' ', SPSS_MAX_LONGSTRING + 1); // leave room for null terminator
- ReturnCode result = SpssThinWrapper.spssGetValueCharImpl(handle, varHandle, ref value, value.Length);
- if (result == ReturnCode.SPSS_BUFFER_SHORT)
- {
- value = new string(' ', SPSS_MAX_VERYLONGSTRING + 1);
- result = SpssThinWrapper.spssGetValueCharImpl(handle, varHandle, ref value, value.Length);
- }
-
- value = (result == ReturnCode.SPSS_OK) ? value.Substring(0, value.IndexOf('\0')) : null;
- return result;
- }
-
- /// <summary>
- /// Gets the alignment of a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="alignment">
- /// Alignment of the variable.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
- /// </returns>
- /// <remarks>
- /// This function reports the value of the alignment attribute of a variable.
- /// </remarks>
- public static ReturnCode spssGetVarAlignment(int handle, string varName, out AlignmentCode alignment)
- {
- return SpssThinWrapper.spssGetVarAlignmentImpl(handle, ref varName, out alignment);
- }
- /// <summary>
- /// Gets the missing values of a short string variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="missingFormat">
- /// Missing value format code.
- /// </param>
- /// <param name="missingVal1">
- /// First missing value.
- /// </param>
- /// <param name="missingVal2">
- /// Second missing value.
- /// </param>
- /// <param name="missingVal3">
- /// Third missing value.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
- /// <see cref="ReturnCode.SPSS_STR_EXP"/>, or
- /// <see cref="ReturnCode.SPSS_SHORTSTR_EXP"/>.
- /// </returns>
- /// <remarks>
- /// This function reports the missing values of a short string variable. The value of
- /// <paramref>missingFormat</paramref> will indicate
- /// the number of missing values. The
- /// appropriate number of missing values is copied to the <paramref>missingVal1</paramref>,
- /// <paramref>missingVal2</paramref>, and <paramref>missingVal3</paramref> parameters.
- /// </remarks>
- public static ReturnCode spssGetVarCMissingValues(int handle, string varName, out MissingValueFormatCode missingFormat, out string missingVal1, out string missingVal2, out string missingVal3)
- {
- missingVal1 = new string(' ', SPSS_MAX_SHORTSTRING + 1);
- missingVal2 = new string(' ', SPSS_MAX_SHORTSTRING + 1);
- missingVal3 = new string(' ', SPSS_MAX_SHORTSTRING + 1);
- ReturnCode result = SpssThinWrapper.spssGetVarCMissingValuesImpl(handle, ref varName, out missingFormat,
- ref missingVal1, ref missingVal2, ref missingVal3);
- if (missingFormat < MissingValueFormatCode.SPSS_THREE_MISSVAL)
- missingVal3 = null;
- else
- missingVal3 = (result == ReturnCode.SPSS_OK) ? missingVal3.Substring(0, missingVal3.IndexOf('\0')) : null;
- if (missingFormat < MissingValueFormatCode.SPSS_TWO_MISSVAL)
- missingVal2 = null;
- else
- missingVal2 = (result == ReturnCode.SPSS_OK) ? missingVal2.Substring(0, missingVal2.IndexOf('\0')) : null;
- if (missingFormat < MissingValueFormatCode.SPSS_ONE_MISSVAL)
- missingVal1 = null;
- else
- missingVal1 = (result == ReturnCode.SPSS_OK) ? missingVal1.Substring(0, missingVal1.IndexOf('\0')) : null;
- return result;
- }
- /// <summary>
- /// Gets the width of a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="columnWidth">
- /// Column width.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
- /// </returns>
- /// <remarks>
- /// This function reports the value of the column width attribute of a variable. A value of
- /// zero is special and means that the SPSS Data Editor, which is the primary user of this
- /// attribute, will set an appropriate width using its own algorithm.
- /// </remarks>
- public static ReturnCode spssGetVarColumnWidth(int handle, string varName, out int columnWidth)
- {
- return SpssThinWrapper.spssGetVarColumnWidthImpl(handle, ref varName, out columnWidth);
- }
- /// <summary>
- /// Gets the name and type of a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="iVar">
- /// Zero origin variable number.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="varType">
- /// Variable type.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>,
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>, or
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
- /// </returns>
- /// <remarks>
- /// This function gets the name and type of one of the variables present in a data file. It
- /// serves the same purpose as <see cref="spssGetVarNames"/> but returns the information one variable
- /// at a time and, therefore, can be passed to a Visual Basic program.
- /// The type code is an integer in the range 0255, 0 indicating a numeric
- /// variable and a positive value indicating a string variable of that size.
- /// </remarks>
- public static ReturnCode spssGetVarInfo(int handle, int iVar, out string varName, out int varType)
- {
- varName = new string(' ', SpssSafeWrapper.SPSS_MAX_VARNAME + 1);
- ReturnCode result = SpssThinWrapper.spssGetVarInfoImpl(handle, iVar, ref varName, out varType);
- varName = (result == ReturnCode.SPSS_OK) ? varName.Substring(0, varName.IndexOf('\0')) : null;
- return result;
- }
- /// <summary>
- /// Gets the handle for a named variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="varHandle">
- /// Handle for the variable.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
- /// </returns>
- /// <remarks>
- /// This function returns a handle for a variable, which can then be used to read or write
- /// (depending on how the file was opened) values of the variable. If handle is associated
- /// with an output file, the dictionary must be written with <see cref="SpssThinWrapper.spssCommitHeaderDelegate"/>
- /// before variable handles can be obtained via spssGetVarHandle.
- /// </remarks>
- public static ReturnCode spssGetVarHandle(int handle, string varName, out double varHandle)
- {
- return SpssThinWrapper.spssGetVarHandleImpl(handle, ref varName, out varHandle);
- }
- /// <summary>
- /// Gets the variable label for some named variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="varLabel">
- /// Variable label.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_NO_LABEL"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
- /// </returns>
- /// <remarks>
- /// This function copies the label of variable <paramref>varName</paramref> into
- /// <paramref>varLabel</paramref>. To get labels more than 120 characters long, use
- /// the spssGetVarLabelLong function.
- /// </remarks>
- public static ReturnCode spssGetVarLabel(int handle, string varName, out string varLabel)
- {
- int len;
- varLabel = new string(' ', SPSS_MAX_LONGSTRING + 1); // leave room for null terminator
- ReturnCode result = spssGetVarLabelLongImpl(handle, ref varName, ref varLabel, varLabel.Length, out len);
- varLabel = (result == ReturnCode.SPSS_OK) ? varLabel.Substring(0, len) : varLabel = null;
- return result;
- }
-
- /// <summary>
- /// Gets the measurement level of a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="measureLevel">
- /// Measurement level.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
- /// </returns>
- /// <remarks>
- /// This function reports the value of the measurement level attribute of a variable.
- /// </remarks>
- public static ReturnCode spssGetVarMeasureLevel(int handle, string varName, out MeasurementLevelCode measureLevel)
- {
- int measureLevelInt;
- ReturnCode status = SpssThinWrapper.spssGetVarMeasureLevelImpl(handle, ref varName, out measureLevelInt);
- measureLevel = (MeasurementLevelCode)measureLevelInt;
- return status;
- }
- /// <summary>
- /// Gets the missing values of a numeric variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="missingFormat">
- /// Missing value format code.
- /// </param>
- /// <param name="missingVal1">
- /// First missing value.
- /// </param>
- /// <param name="missingVal2">
- /// Second missing value.
- /// </param>
- /// <param name="missingVal3">
- /// Third missing value.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
- /// <see cref="ReturnCode.SPSS_NUME_EXP"/>.
- /// </returns>
- /// <remarks>
- /// This function reports the missing values of a numeric variable. The value of
- /// <paramref>missingFormat</paramref> determines the interpretation of
- /// <paramref>missingVal1</paramref>, <paramref>missingVal2</paramref>, and
- /// <paramref>missingVal3</paramref>. If missingFormat is SPSS_MISS_RANGE,
- /// <paramref>missingVal1</paramref> and <paramref>missingVal2</paramref>
- /// represent the upper and lower limits, respectively, of the range, and
- /// <paramref>missingVal3</paramref> is not used. If missingFormat is
- /// SPSS_MISS_RANGEANDVAL, <paramref>missingVal1</paramref> and
- /// <paramref>missingVal2</paramref> represent the range and
- /// <paramref>missingVal3</paramref> is the discrete missing value.
- /// If missingFormat is neither of the above, it will be in the range
- /// 03, indicating the number of discrete missing
- /// values present. (The macros SPSS_NO_MISSVAL, SPSS_ONE_MISSVAL,
- /// SPSS_TWO_MISSVAL, and SPSS_THREE_MISSVAL may be used as synonyms for 03.)
- /// </remarks>
- public static ReturnCode spssGetVarNMissingValues(int handle, string varName, out MissingValueFormatCode missingFormat, out double missingVal1, out double missingVal2, out double missingVal3)
- {
- return SpssThinWrapper.spssGetVarNMissingValuesImpl(handle, ref varName, out missingFormat, out missingVal1, out missingVal2, out missingVal3);
- }
- /// <summary>
- /// Gets the value label for a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="value">
- /// Short string value for which the label is wanted.
- /// </param>
- /// <param name="label">
- /// Label for the value.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_NO_LABELS"/>,
- /// <see cref="ReturnCode.SPSS_NO_LABEL"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
- /// <see cref="ReturnCode.SPSS_STR_EXP"/>,
- /// <see cref="ReturnCode.SPSS_SHORTSTR_EXP"/>, or
- /// <see cref="ReturnCode.SPSS_EXC_STRVALUE"/>.
- /// </returns>
- /// <remarks>
- /// This function gets the value label for a given value of a short string variable.
- /// </remarks>
- public static ReturnCode spssGetVarCValueLabel(int handle, string varName, string value, out string label)
- {
- int len;
- label = new string(' ', SPSS_MAX_VALLABEL + 1);
- ReturnCode result = spssGetVarCValueLabelLongImpl(handle, ref varName, ref value, ref label, label.Length, out len);
- label = (result == ReturnCode.SPSS_OK) ? label.Substring(0, len) : null;
- return result;
- }
- /// <summary>
- /// Gets the value label for a given value of a numeric variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="value">
- /// Numeric value for which the label is wanted.
- /// </param>
- /// <param name="label">
- /// Label for the value.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_NO_LABELS"/>,
- /// <see cref="ReturnCode.SPSS_NO_LABEL"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
- /// <see cref="ReturnCode.SPSS_NUME_EXP"/>.
- /// </returns>
- /// <remarks>
- /// This function gets the value label for a given value of a numeric variable.
- /// </remarks>
- public static ReturnCode spssGetVarNValueLabel(int handle, string varName, double value, out string label)
- {
- int len;
- label = new string(' ', SPSS_MAX_VALLABEL + 1); // leave room for null terminator
- ReturnCode result = spssGetVarNValueLabelLong(handle, ref varName, value, ref label, label.Length, out len);
- if (result == ReturnCode.SPSS_OK)
- label = label.Substring(0, len);
- else
- label = null;
-
- return result;
- }
-
- /// <summary>
- /// Gets print formatting information for a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="printType">
- /// Print format type code (file spssdio.h defines macros of
- /// the form <see cref="FormatTypeCode">SPSS_FMT_...</see> for all valid format type codes)
- /// </param>
- /// <param name="printDec">
- /// Number of digits after the decimal.
- /// </param>
- /// <param name="printWidth">
- /// Print format width.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
- /// </returns>
- /// <remarks>
- /// This function reports the print format of a variable. Format type, number of decimal
- /// places, and field width are returned as <paramref>printType</paramref>,
- /// <paramref>printDec</paramref>, and <paramref>printWid</paramref>, respectively.
- /// </remarks>
- public static ReturnCode spssGetVarPrintFormat(int handle, string varName, out FormatTypeCode printType, out int printDec, out int printWidth)
- {
- return SpssThinWrapper.spssGetVarPrintFormatImpl(handle, ref varName, out printType, out printDec, out printWidth);
- }
- /// <summary>
- /// Gets the write format of a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file
- /// </param>
- /// <param name="varName">
- /// Variable name
- /// </param>
- /// <param name="writeType">
- /// Pointer to write format type code (file spssdio.h defines macros of
- /// the form <see cref="FormatTypeCode">SPSS_FMT_...</see> for all valid format type codes)
- /// </param>
- /// <param name="writeDec">
- /// Pointer to number of digits after the decimal
- /// </param>
- /// <param name="writeWidth">
- /// Pointer to write format width
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
- /// </returns>
- /// <remarks>
- /// This function reports the write format of a variable. Format type, number of decimal
- /// places, and field width are returned as writeType, writeDec, and writeWid,
- /// respectively.
- /// </remarks>
- public static ReturnCode spssGetVarWriteFormat(int handle, string varName, out FormatTypeCode writeType, out int writeDec, out int writeWidth)
- {
- return SpssThinWrapper.spssGetVarWriteFormatImpl(handle, ref varName, out writeType, out writeDec, out writeWidth);
- }
- /// <summary>
- /// Opens an SPSS file for appending cases.
- /// </summary>
- /// <param name="fileName">
- /// Name of the file.
- /// </param>
- /// <param name="handle">
- /// Handle to the opened file.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_FITAB_FULL"/>,
- /// <see cref="ReturnCode.SPSS_FILE_OERROR"/>,
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>,
- /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>,
- /// <see cref="ReturnCode.SPSS_NO_TYPE2"/>,
- /// <see cref="ReturnCode.SPSS_NO_TYPE999"/>, or
- /// <see cref="ReturnCode.SPSS_INCOMPAT_APPEND"/>.
- /// </returns>
- /// <remarks>
- /// This function opens an SPSS data file for appending cases and returns a handle that
- /// should be used for subsequent operations on the file.
- /// </remarks>
- public static ReturnCode spssOpenAppend(string fileName, out int handle)
- {
- return SpssThinWrapper.spssOpenAppendImpl(ref fileName, out handle);
- }
- /// <summary>
- /// Creates a new SPSS data file, with a dictionary copied from an existing file.
- /// </summary>
- /// <param name="fileName">
- /// Name of the new file.
- /// </param>
- /// <param name="dictFileName">
- /// Name of existing file.
- /// </param>
- /// <param name="handle">
- /// Handle of the new file.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_FITAB_FULL"/>,
- /// <see cref="ReturnCode.SPSS_FILE_OERROR"/>,
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>,
- /// <see cref="ReturnCode.SPSS_FILE_RERROR"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_FILE"/>,
- /// <see cref="ReturnCode.SPSS_NO_TYPE2"/>, or
- /// <see cref="ReturnCode.SPSS_NO_TYPE999"/>.
- /// </returns>
- /// <remarks>
- /// This function opens a file in preparation for creating a new SPSS data file and initializes
- /// its dictionary from that of an existing SPSS data file. It is useful when you want to modify
- /// the dictionary or data of an existing file or replace all of its data. The typical sequence
- /// of operations is to call <see cref="spssOpenWriteCopy"/> (newFileName, oldFileName, ...) to open a
- /// new file initialized with a copy of the old files dictionary, then <see cref="spssOpenRead"/> (oldFile-
- /// Name, ...) to open the old file to access its data.
- /// </remarks>
- public static ReturnCode spssOpenWriteCopy(string fileName, string dictFileName, out int handle)
- {
- return SpssThinWrapper.spssOpenWriteCopyImpl(ref fileName, ref dictFileName, out handle);
- }
- /// <summary>
- /// Sets the case weight variable in a data file.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// The name of the case weight variable.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
- /// <see cref="ReturnCode.SPSS_NUME_EXP"/>, or
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
- /// </returns>
- /// <remarks>
- /// This function defines variable varName as the case weight variable for the data file
- /// specified by the handle.
- /// </remarks>
- public static ReturnCode spssSetCaseWeightVar(int handle, string varName)
- {
- return SpssThinWrapper.spssSetCaseWeightVarImpl(handle, ref varName);
- }
- /// <summary>
- /// Sets the Trends date variable information.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="dateInfo">
- /// Array containing date variables information.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_DATEINFO"/>, or
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
- /// </returns>
- /// <remarks>
- /// This function sets the Trends date variable information. The array at dateInfo is
- /// assumed to have numofElements elements that correspond to the data array portion of
- /// record 7, subtype 3. Its first six elements comprise the fixed information, followed
- /// by a sequence of one or more three-element groups. Since very little validity checking
- /// is done on the input array, this function should be used with caution and is
- /// recommended only for copying Trends information from one file to another.
- /// </remarks>
- unsafe public static ReturnCode spssSetDateVariables(int handle, int[] dateInfo)
- {
- return SpssThinWrapper.spssSetDateVariablesImpl(handle, dateInfo.Length, (int*)Marshal.UnsafeAddrOfPinnedArrayElement(dateInfo, 0));
- }
- /// <summary>
- /// Sets the first block of Data Entry information.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="data">
- /// Data to be written.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_EMPTY_DEW"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>, or
- /// <see cref="ReturnCode.SPSS_FILE_BADTEMP"/>.
- /// </returns>
- /// <remarks>
- /// DEW information (file information which is private to the SPSS Data Entry product)
- /// can be delivered to the I/O DLL in whatever segments are convenient for the client.
- /// The spssSetDEWFirst function is called to deliver the first such segment, and
- /// subsequent segments are delivered by calling spssSetDEWNext as many times as
- /// necessary.
- /// </remarks>
- public static ReturnCode spssSetDEWFirst(int handle, string data)
- {
- return SpssThinWrapper.spssSetDEWFirstImpl(handle, ref data, data.Length);
- }
- /// <summary>
- /// Sets the unique Data Entry uniqueness GUID.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="asciiGUID">
- /// The GUID to be stored on the file.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>, or
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
- /// </returns>
- /// <remarks>
- /// This function stores the Data Entry for Windows uniqueness indicator on the data file.
- /// It should only be used by the DEW product.
- /// </remarks>
- public static ReturnCode spssSetDEWGUID(int handle, string asciiGUID)
- {
- return SpssThinWrapper.spssSetDEWGUIDImpl(handle, ref asciiGUID);
- }
- /// <summary>
- /// Sets the next block of information for Data Entry.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="data">
- /// Data to be written.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_DEW_NOFIRST"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>, or
- /// <see cref="ReturnCode.SPSS_FILE_BADTEMP"/>.
- /// </returns>
- /// <remarks>
- /// The DEW information (file information that is private to the SPSS Data Entry product)
- /// can be delivered to the I/O DLL in whatever segments are convenient for the client.
- /// The spssSetDEWFirst function is called to deliver the first such segment, and
- /// subsequent segments are delivered by calling spssSetDEWNext as many times as
- /// necessary.
- /// </remarks>
- public static ReturnCode spssSetDEWNext(int handle, string data)
- {
- return SpssThinWrapper.spssSetDEWNextImpl(handle, ref data, data.Length);
- }
- /// <summary>
- /// Sets the file label of a data file.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="id">
- /// File label. The length of the string should not exceed
- /// <see cref="SpssThinWrapper.SPSS_MAX_IDSTRING"/> characters.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_EXC_LEN64"/>
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>, or
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>.
- /// </returns>
- /// <remarks>
- /// This function sets the file label of the output SPSS data file associated with handle to
- /// the given string id.
- /// </remarks>
- public static ReturnCode spssSetIdString(int handle, string id)
- {
- return SpssThinWrapper.spssSetIdStringImpl(handle, ref id);
- }
-
- /// <summary>
- /// Sets multiple response definitions to a data file.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="mrespDefs">
- /// ASCII string containing definitions.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_EMPTY_MULTRESP"/>
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>, or
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
- /// </returns>
- /// <remarks>
- /// This function is used to write multiple response definitions to the file. The definitions
- /// consist of a single null-terminated ASCII string which is similar to that containing the
- /// variable set definitions.
- /// </remarks>
- public static ReturnCode spssSetMultRespDefs(int handle, string mrespDefs)
- {
- return SpssThinWrapper.spssSetMultRespDefsImpl(handle, ref mrespDefs);
- }
-
- /// <summary>
- /// Sets the text data from the string in textInfo.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file
- /// </param>
- /// <param name="textInfo">
- /// Text data
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>, or
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
- /// </returns>
- /// <remarks>
- /// This function sets the text data from the null-terminated string in textInfo. If the string is
- /// longer than 255 characters, only the first 255 are (quietly) used. If textInfo contains the
- /// empty string, existing text data, if any, is deleted.
- /// </remarks>
- public static ReturnCode spssSetTextInfo(int handle, string textInfo)
- {
- return SpssThinWrapper.spssSetTextInfoImpl(handle, ref textInfo);
- }
-
- /// <summary>
- /// Sets the value of a string variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varHandle">
- /// Handle to the variable.
- /// </param>
- /// <param name="value">
- /// Value of the variable. The length of the
- /// string (ignoring trailing blanks, if any) should be less than or equal
- /// to the length of the variable.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_NOTCOMMIT"/>,
- /// <see cref="ReturnCode.SPSS_STR_EXP"/>, or
- /// <see cref="ReturnCode.SPSS_EXC_STRVALUE"/>.
- /// </returns>
- /// <remarks>
- /// This function sets the value of a string variable for the current case. The current case is
- /// not written out to the data file until <see cref="SpssThinWrapper.spssCommitCaseRecordDelegate"/> is called.
- /// </remarks>
- public static ReturnCode spssSetValueChar(int handle, double varHandle, string value)
- {
- return SpssThinWrapper.spssSetValueCharImpl(handle, varHandle, ref value);
- }
- /// <summary>
- /// Sets the alignment of a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="alignment">
- /// Alignment. If not a legal
- /// value, alignment is set to a type-appropriate default.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
- /// </returns>
- /// <remarks>
- /// This function sets the value of the alignment attribute of a variable.
- /// </remarks>
- public static ReturnCode spssSetVarAlignment(int handle, string varName, AlignmentCode alignment)
- {
- return SpssThinWrapper.spssSetVarAlignmentImpl(handle, ref varName, alignment);
- }
- /// <summary>
- /// Sets missing values for a short string variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="missingFormat">
- /// The number of missing values (0-3) actually supplied.
- /// </param>
- /// <param name="missingVal1">
- /// First missing value.
- /// </param>
- /// <param name="missingVal2">
- /// Second missing value.
- /// </param>
- /// <param name="missingVal3">
- /// Third missing value.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>,
- /// <see cref="ReturnCode.SPSS_STR_EXP"/>,
- /// <see cref="ReturnCode.SPSS_SHORTSTR_EXP"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_MISSFOR"/>,
- /// <see cref="ReturnCode.SPSS_EXC_STRVALUE"/>, or
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
- /// </returns>
- /// <remarks>
- /// This function sets missing values for a short string variable. The argument
- /// missingFormat must be set to a value in the range 03 to indicate the number of missing
- /// values supplied. When fewer than three missing values are to be defined, the redundant
- /// arguments must still be present, although their values are not inspected. For example,
- /// if missingFormat is 2, missingVal3 is unused. The supplied missing values must be nullterminated
- /// and not longer than the length of the variable unless the excess length is
- /// made up of blanks, which are ignored. If the missing value is shorter than the length of
- /// the variable, trailing blanks are assumed.
- /// </remarks>
- public static ReturnCode spssSetVarCMissingValues(int handle, string varName, MissingValueFormatCode missingFormat, string missingVal1, string missingVal2, string missingVal3)
- {
- return SpssThinWrapper.spssSetVarCMissingValuesImpl(handle, ref varName, missingFormat,
- ref missingVal1, ref missingVal2, ref missingVal3);
- }
- /// <summary>
- /// Sets the column width of a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="columnWidth">
- /// Column width. If negative, a value of zero is (quietly) used instead.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>, or
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>.
- /// </returns>
- /// <remarks>
- /// This function sets the value of the column width attribute of a variable. A value of zero
- /// is special and means that the SPSS Data Editor, which is the primary user of this
- /// attribute, is to set an appropriate width using its own algorithm.
- /// </remarks>
- public static ReturnCode spssSetVarColumnWidth(int handle, string varName, int columnWidth)
- {
- return SpssThinWrapper.spssSetVarColumnWidthImpl(handle, ref varName, columnWidth);
- }
- /// <summary>
- /// Sets the label of a variable.
- /// </summary>
- /// <param name="handle">
- /// Handle to the data file.
- /// </param>
- /// <param name="varName">
- /// Variable name.
- /// </param>
- /// <param name="varLabel">
- /// Variable label. The length of the string should not exceed
- /// <see cref="SpssThinWrapper.SPSS_MAX_VARLABEL"/> characters.
- /// If varLabel is the empty string, the existing label, if any, is deleted.
- /// </param>
- /// <returns>
- /// <see cref="ReturnCode.SPSS_OK"/>,
- /// <see cref="ReturnCode.SPSS_EXC_LEN120"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_HANDLE"/>,
- /// <see cref="ReturnCode.SPSS_OPEN_RDMODE"/>,
- /// <see cref="ReturnCode.SPSS_DICT_COMMIT"/>,
- /// <see cref="ReturnCode.SPSS_INVALID_VARNAME"/>,
- /// <see cref="ReturnCode.SPSS_VAR_NOTFOUND"/>, or
- /// <see cref="ReturnCode.SPSS_NO_MEMORY"/>.
- /// </returns>
- /// <remarks>
- /// This function sets the l…
Large files files are truncated, but you can click here to view the full file