Contents Developing Windows Clients  

OptionService Object

A service that sets and gets option values for a SAS Workspace.

OptionService Full Description

Attributes

Parent Property

Methods

SetOptions Method
GetOptions Method

Enumerations

SetError Enumeration
GetError Enumeration
DataType Enumeration

Description

The object provides an interface for reading and setting option values on the SAS Workspace.



Readonly Property Parent

The parent of this object.

Type: Utilities

Description

The Utilities object that is the parent of this object.

Example

Usage


Method SetOptions

Sets multiple SAS system options to new values.

Description

Call SetOptions to set one or more SAS system options to new values. This method accepts input array parameters that supply the option name and new value for each option. These two arrays must be of equal size.

Errors and warnings are returned using three arrays, all of which have a size equal to the total number of errors and warnings encountered (often zero). The first of these identifies which options had problems by listing indices from the option name input array. The second returns an error type indicator for each. The third returns a message describing each error or warning.

Usage

Parameters

Name Direction Type Description
optionNames  in  String(index)  A one-dimensional array of strings that names the SAS system options to be set. If you want to set only one option, then the array should contain only one element.

For Boolean options, it is also possible to supply the negative form of the option name. See the description of the following parameter (SetOptions::values) for details.  

values  in  String(index)  An array of strings containing the values for the options. This array must be the same size as the one that specifies option names. A string is used regardless of the data type of the option. For options whose values are not already strings, the string is converted to the value of the appropriate type for the option. For numeric values, this is easy.

Special rules apply for Boolean options. They may be set via the option name alone (in positive or negative form) or via the positive option name with the value specified as the name in positive or negative form. Here are the possible alternatives (using the FMTERR option as an example):

 || Name      || Value      || Setting
 || FMTERR    ||            || On
 || NOFMTERR  ||            || Off
 || FMTERR    || FMTERR     || On
 || FMTERR    || NOFMTERR   || Off
 
errorIndices  out  Long(index)  An array which identifies individual errors or warnings by listing their indices from the input arrays. If the returned array is zero-length, then no errors or warnings occurred while setting the options.  
errorCodes  out  SetError(index)  For each error or warning identified in the previous parameter (SetOptions::errorIndices), the corresponding element in this array distinguishes error from warning and identifies the type of error by returning a value from the SetError enumeration.  
errorMsgs  out  String(index)  Provides an error (or warning) message for each item listed in the SetOptions::errorIndices output parameter.  

Example

Public Sub optsvcex()
Dim obWSMgr As New SASWorkspaceManager.WorkspaceManager
Dim obWS As SAS.Workspace
Dim errString As String
Dim obOptSvc As SAS.OptionService
Dim names(5) as string
Dim values(5) as string
Dim failIndices() as long
Dim failCodes() as long
Dim failMsgs() as string
' Create a local workspace
Set obWS = obWSMgr.Workspaces.CreateWorkspaceByServer("My workspace", VisibilityNone, Nothing, "", "", errString)
Set obOptSvc = obWS.Utilities.OptionService
' One way to enable boolean option ON (set it to True).
names(0) = "MPRINT"
values(0) = ""
'Another way to enable a boolean option on.
names(1) = "NOTES"
values(1) = "NOTES"
' One way to disable a boolean option (set it to False).
names(2) = "NOMLOGIC"
values(2) = ""
' Another way to disable a boolean option.
names(3) = "MAUTOSOURCE"
values(3) = "NOMAUTOSOURCE"
' Set an integer option.
names(4) = "LINESIZE"
values(4) = "100"
' Set a character string option.
names(5) = "MISSING"
values(5) = "?"
obOptSvc.SetOptions names, values, failIndices, failCodes, failMsgs
dim i as integer
for i = 0 to UBound(failIndices)
   debug.print "Error: Could not set " & names(failIndices(i))
   debug.print "     : " & failMsgs(i)
next i
debug.print str(6-i) & " options set successfully."
obWS.Close
End Sub

See Also

GetOptions


Method GetOptions

Get the values of multiple SAS system options.

Description

Get the values of multiple SAS system options for the Workspace. Information about the option is also returned.

Usage

Parameters

Name Direction Type Description
optionNames  in  String(index)  A one-dimensional array of strings that name the SAS system options to be retrieved. If you want to retrieve only one option, then the array should contain only one element.

For Boolean options, the name must be the base option name. The "NO" form cannot be used in this parameter.  

types  out  DataType(index)  The data type of each option as indicated by the DataType enumeration.  
isPortable  out  Boolean(index)  Distinguishes portable and host options.  
isStartupOnly  out  Boolean(index)  Indicates if an option is restricted to being set only when starting SAS.  
values  out  String(index)  An array of strings that returns the value of each of the requested options.

This array is the same size as the input array of option names. A string is used regardless of the data type of the option. For options whose values are not strings, you can convert the string to the appropriate type.

Boolean options are treated differently. The positive or negative form of the option name will be returned. The following table shows an example of this with the FMTERR option:

 || Name      || Setting    || Returned value
 || FMTERR    || On         || FMTERR
 || FMTERR    || Off        || NOFMTERR
 
errorIndices  out  Long(index)  An array which identifies individual errors or warnings by listing their indices from the input array. The GetOptions::types, GetOptions::isPortable, GetOptions::isStartupOnly and GetOptions::values output parameters will have an element for each option request regardless of whether or not it had an error. The elements, however, contain meaningful values only when an error does not occur.

If the returned array is zero-length, then there were no errors or warnings in retrieving the options.  

errorCodes  out  GetError(index)  For each error or warning identified in the previous parameter (GetOptions::errorIndices), the corresponding element in this array distinguishes error from warning and identifies the type of error by returning a value from the GetError enumeration.  
errorMsgs  out  String(index)  Provides an error (or warning) message for each item listed in the GetOptions::errorIndices output parameter.  

Example

See Also


Enum SetError

Error and warning classification for setting an option.

Description

The OptionService object provides a SetOptions method that sets multiple options at once. It classifies option setting problems according to the set of values described here.

Usage

Member Description
SetErrorNone  Option set successfully, but a warning message was generated.  
SetErrorUnknown  The option was not set due to an error of unknown type. See the accompanying message for details.  
SetErrorInvalidName  The specified option name is not known.  
SetErrorInvalidValue  The specified option value is not correct. See the accompanying message for details.  
SetErrorNotSettable  The specified option cannot be set after SAS invocation.  


Enum GetError

Error and warning classification for getting an option value.

Description

The OptionService object provides a GetOptions method that gets multiple options at once. It classifies option query problems according to the set of values described here.

Usage

Member Description
GetErrorNone  Option information was obtained successfully, but a warning message was generated.  
GetErrorUnknown  The option value was not retrieved due to an error of unknown type. See the accompanying message for details.  
GetErrorInvalidName  The specified option name is not known.  


Enum DataType

The data type of an option value.

Description

This enumeration identifies the possible data types for option values.

Usage

Member Description
DataTypeString  The option value is a string.  
DataTypeBoolean  The option value is Boolean (true/false).  
DataTypeInteger  The option value is an integer.  
DataTypeDouble  The option value is a real number (SAS numeric value) that can be represened in double-precision floating-point format.  

Contents Developing Windows Clients