Package com.stata.sfi
Class Scalar
java.lang.Object
com.stata.sfi.Scalar
This class provides access to Stata scalars.
Examples:
Loading and saving scalars...
public static int getStringScalar(String[] args) {
String name = args[0];
String contents = Scalar.getString(name);
SFIToolkit.displayln(name + " = " + contents);
return 0;
}
public static int setStringScalar(String[] args) {
String name = args[0];
String contents = args[1];
int rc = Scalar.setString(name, contents);
return rc;
}
public static int getScalar(String[] args) {
String name = args[0];
Double contents = Scalar.getValue(name);
SFIToolkit.displayln(name + " = " + contents);
return 0;
}
public static int setScalar(String[] args) {
String name = args[0];
Double value = Double.parseDouble(args[1]);
int rc = Scalar.setValue(name, value);
return rc;
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGet the contents of a Stata string scalar.static StringGet the contents of a Stata string scalar.static DoubleGet the contents of a Stata scalar.static DoubleGet the contents of a Stata scalar.static intSet the contents of a Stata string scalar.static intSet the contents of a Stata string scalar.static intSet the value of a Stata scalar.static intSet the value of a Stata scalar.static intSet the value of a Stata scalar.static intSet the value of a Stata scalar.
-
Field Details
-
TYPE_AUTOMATIC
public static final int TYPE_AUTOMATIC- See Also:
-
TYPE_CRETURN
public static final int TYPE_CRETURN- See Also:
-
TYPE_ERETURN
public static final int TYPE_ERETURN- See Also:
-
TYPE_GLOBAL
public static final int TYPE_GLOBAL- See Also:
-
TYPE_RETURN
public static final int TYPE_RETURN- See Also:
-
TYPE_RRETURN
public static final int TYPE_RRETURN- See Also:
-
TYPE_SRETURN
public static final int TYPE_SRETURN- See Also:
-
VTYPE_HIDDEN
public static final int VTYPE_HIDDEN- See Also:
-
VTYPE_HISTORICAL
public static final int VTYPE_HISTORICAL- See Also:
-
VTYPE_VISIBLE
public static final int VTYPE_VISIBLE- See Also:
-
-
Method Details
-
getString
Get the contents of a Stata string scalar.- Parameters:
name- Name of the scalar.- Returns:
- Value of the scalar. Returns null if the scalar is not found or if the scalar is marked as binary.
-
getString
Get the contents of a Stata string scalar.- Parameters:
name- Name of the scalar.type- Type of the scalar; may beTYPE_AUTOMATIC,TYPE_GLOBAL, orTYPE_CRETURN.- Returns:
- Value of the scalar. Returns null if the scalar is not found or if the scalar is marked as binary.
-
getValue
Get the contents of a Stata scalar.- Parameters:
name- Name of the scalar.- Returns:
- Value of the scalar. Returns null if the scalar is not found.
-
getValue
Get the contents of a Stata scalar.- Parameters:
name- Name of the scalar.type- Type of the scalar; may beTYPE_AUTOMATIC,TYPE_GLOBAL,TYPE_RETURN,TYPE_RRETURN,TYPE_ERETURN, orTYPE_CRETURN.- Returns:
- Value of the scalar. Returns null if the scalar is not found.
-
setString
Set the contents of a Stata string scalar.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.- Returns:
- Return code from Stata; 0 if successful.
-
setString
Set the contents of a Stata string scalar.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.type- Type of the scalar; may beTYPE_AUTOMATICorTYPE_GLOBAL.- Returns:
- Return code from Stata; 0 if successful.
-
setValue
Set the value of a Stata scalar. If necessary, the scalar will be created.- Parameters:
name- Name of the scalar.val- Value to store in the scalar.- Returns:
- Return code from Stata; 0 if successful.
-
setValue
Set the value of a Stata scalar. If necessary, the scalar will be created.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.type- Type of the scalar; may beTYPE_AUTOMATIC,TYPE_GLOBAL,TYPE_RETURN,TYPE_RRETURN, orTYPE_ERETURN.- Returns:
- Return code from Stata; 0 if successful.
-
setValue
Set the value of a Stata scalar. If necessary, the scalar will be created.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.type- Type of the scalar; may beTYPE_AUTOMATIC,TYPE_GLOBAL,TYPE_RETURN,TYPE_RRETURN, orTYPE_ERETURN.vtype- If the scalar is a type of return value, sets whether the return value isVTYPE_VISIBLE,VTYPE_HIDDEN, orVTYPE_HISTORICAL. This parameter is ignored withTYPE_GLOBAL.- Returns:
- Return code from Stata; 0 if successful.
-
setValue
Set the value of a Stata scalar. If necessary, the scalar will be created.- Parameters:
name- Name of the scalar.value- Value to store in the scalar.type- Type of the scalar; may beTYPE_GLOBAL,TYPE_RETURN,TYPE_RRETURN, orTYPE_ERETURN.version- If the scalar is a type of return value, sets the release number in the form #[#][.[#[#]]] for a return result. This parameter is ignored withTYPE_GLOBAL.- Returns:
- Return code from Stata; 0 if successful.
-