string_format, used in conjunction with modules like plume_shell, plume_volume, loop and others provides a very simple way to create complex titles that change as the parameters in your module change. It also provides a simple means to perform mathematical operations on numbers coming from up to 4 numeric input ports. By using multiple string_format modules, a title (string) of any complexity may be created.
The panel for string_format is shown above. The expression shown
s1 + " Plume Level" + s2 + Text(f1,2) + " mg/kg"
1) with a value of 5.0 (actually 4.99999995) input to the leftmost numeric input port and
2) the iso_component input to s1 (string 1) and
3) the above/below string input to s2, results in the following string output:
TOTHC Plume Level above 5.00 mg/kg
The most wonderful thing about this result is that changing any of the parameters in the plume_volume module that which is connected to 3 inputs on string_format automatically update the result. Even in an animation, changes that affect plume_volume are automatically reflected in the output of string_format. This behavior can be changed by unchecking the checkbox next to the desired field. When this box is unchecked the output will not change when that value changes until it is checked again. However if the value changes in any other field that is checked the module will run will all of the current values.
In addition to the functions, variables, and operations available in the other math operations, the string_format module can also use the following functions on string variables and values:
String(number,[decimals],[format]) or Text(number,[decimals],[format]):
This function takes one to three arguments.
The first is a number. This number is converted into a string for display purposes.
An optional second argument can be used, which is the number of decimal points to use during the conversion.
If this number is negative, the function attempts to automatically determine the optimal number of decimal points to use based on the value. By changing this negative value, you can control the number of decimal points used in the automatic conversion.
The default setting if unspecified is a value of -2.
A third optional argument is a formatting specifier. Note that the format specifier must be in single or double quotes 'r;e' or "e". The following values can be used:
'n' (default): Number format: The value is converted to a string of the form "-d,ddd,ddd.ddd..." The symbols used for thousands and decimal separators are determined in the Regional Settings of the Windows Control Panel.
'f': Fixed format: The value is converted to a string of the form "-ddddddd.ddd"
'e': Scientific Notation: The value is converted to a string of the form "-d.ddd...E+ddd". The resulting string starts with a minus sign if the number is negative. One digit always precedes the decimal point.
'g': General format: The value is converted to the shortest possible decimal string using fixed or scientific format.
'm': Money format: The value is converted to a string that represents a currency amount. The format is controlled by the Regional Settings in the Windows Control Panel, and will include the currency symbol, thousands separator, and decimal separator as specified in the Regional Settings.
Examples: (quotes " " are shown, but are not a part of the output)
String(5.5) = "5.5"
String(5.5,3) = "5.500"
String(1000000,1) = "1,000,000.0"
Text(5423.1,2,'f') = "5423.10"
Text(5423.1,2,'m') = "$5,423.10"
String Operators: Many functions (operators) are available to parse and assess the characteristics of strings. These are discussed here:
Pop-up available String Operatorshere or Jump to availableString Operatorshere.
Complex Example: If you connect a filename port to s1 after browsing for a file (browsing always gives you \ slashes, doubled in the saved app), the following works:
Mid(s1,1+RPos(s1,"\"))
This will strip off just the filename portion. (ie: If you do c:\ctech\data\analyte\initial_soil_investigation_subsite.apdv, the above returns initial_soil_investigation_subsite.apdv)
The 1+ is because we want the character after the "\".
Date(date_number, format)
The date function allows you to format a wide variety of date and time strings (labels). Note that the format specifier must be in single or double quotes 'r;c' or "c".
Pop-up available Date Formats here or Jump to available date formats here.
To create the current date/time use the following:
date(now()) = 10/16/2009 8:59:14 AM
date(now(),"MMMM dd, YYYY") = October 16, 2009
Season(date_number)
Season is a special date operator that outputs either Winter, Spring, Summer or Fall, based on the date_number input. To display Summer, 2002 you would use Season in conjunction with Date (displaying only the year).
Now()
Returns the date_number referring to the current date and time.
String_format can also have complex math operations in the expression.
Any of these operators may be used.
An example of an application using this module is shown above.
The parameters in plume_volume are shown below.
The output from this application is shown below.
© 1994-2018 ctech.com