getProfileString
Description
Retrieves a string value from the users profile.
Profile values are identified by their section (sections begin with [section name]) and by the entry (or key) name.
Section groupings allow values to be organized in logical groups. They also allow values with the same name to be differentiated between different groups.
Specifying -file
allows the values to be read from a file of the users choice. The file does not have to have an "ini" extension.
Note that some users use the profile (or other file) as a "global variable" mechanism. While this is still supported, it is not recommended and has been superseded by actual global variables which allow you to have variables that persist between script executions. See setGlobalVar (and related commands) for more information.
Functional area
System
Command syntax
Syntax
getProfileString "sectionHeader" "entry" "defaultValue"[-file string] |
Arguments
Name | Type | Required | Comments |
---|---|---|---|
sectionHeader | string | yes | Logical grouping of the value. This will find the line in the profile which looks like [sectionHeader] |
entry | string | yes | The entry name. This will be the first value on the line followed by an = sign. |
defaultValue | string | yes | Value to return if a value with the given section and name could not be found, or if there was an error accessing the profile. |
Flags
Name | Flag arguments | Argument type | Exclusive to | Comments |
---|---|---|---|---|
file | 1 | string | — | Inputs from another text file. The default is to input from the user's profile (ini file). |
Return value
string
Examples
// Store some information in the profile and read it back in string $value; // Write "Hello World" to the ini file writeProfileString "My Section" "KeyValue" "Hello World"; // Now retrieve it. Return "ERROR" if the value couldn't be found. $value = `getProfileString "My Section" "KeyValue" "ERROR"`; print $value;