ph_extractval PowerHome formula function
Description
Extracts a value from a string containing a
structured list of
name/value pairs
Syntax
ph_extractval ( as_data, as_id, as_sep )
Argument | Description |
as_data | String. A string containing a list of
name/value pairs. See Usage below. |
as_id | String. The ID within the list to extract the value |
as_sep | String. The separator character(s) that
separate the ID and VALUE data |
Return value
String. Returns the VALUE associated
with the specified ID (as_id). Returns "*ERROR* - Unable to locate ID" if the ID
cant be located. Returns "*ERROR* - Unable to locate value" if the value
cant be returned.
Usage
Use this function to quickly search
and return values from a structured list contained within as_data. This
function expects 1 name/value pair per line with lines separated by carriage
return line feed characters (~r~n). The name/value pair is separated from each
other by one or more "separator" characters (as_sep). A sample
as_data string containing 5 name/value pairs with a "," as the separator character could
look like:
Temp,75.0
Humd,55.3
Forecast,Cloudy
Graphic,clouds.jpg
Level,32
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_extractval(ph_readfile("c:\powerhome\data.txt"),"Forecast",",")
- Returns the string "Cloudy" if the list above is contained within a file
located at c:\powerhome\data.txt