Formatting Text, Numeric Values, and Time Values in Text

DIAdem 2018 Help


Edition Date: June 2018
Part Number: 370858P-01
View Product Info

DOWNLOAD (Windows Only)


DIAdem 2017 Help
DIAdem 2018 Help
DIAdem 2019 Help
DIAdem 2020 Help
DIAdem 2020 SP1 Help

Use control characters to format text in DIAdem, and to insert variables, formulas, and script results into text. Use identifiers to format symbols in curves.

Displaying and Formatting Variable Contents in Text

Use the @@ character combination to display variable contents in text. You can use the Calculator operands and operations to display text. You can use all the expressions that have a single expression as the result. You must enclose the name of the variable or the Calculator expression in @@ characters. DIAdem evaluates the expression and displays the evaluated expression in the text. You can also connect normal text with expressions. Use the normal VBS syntax for linking text within the @@ expression, for example: @@"CurrDate:"& CurrDate &" CurrTime: "& CurrTime@@

NoteUse three @ characters to display a single @ character in text. For example, if you want to display the e-mail address Info@ni.com in a text, enter the expression Info@@@ni.com.

Use the Str function or the PU function to format time and date values in text. Enclose the entire expression in @@ characters. Refer to Using Variables in Text for more information about formatting variable contents in text. If you do not enter a format, DIAdem automatically selects a format.

Formatting Numeric Values in Text

Use numeric format instructions to display a specific number of decimal places, or, for example, to display data as exponents. Use the following format instructions in the Str function and in all dialog boxes where you want to format numeric values.

Use the following numeric formats:

 If you do not specify a format, DIAdem displays all the numeric values.
AutoAdjAutomatic numeric format. This format displays the number as compactly as possible, as a decimal or as an exponential. At least 3 numbers and not more than 9 characters display. DIAdem tries to manage without an exponential display. If a display without exponent returns more than 7 characters, DIAdem selects the exponential display.
The AutoAdj format displays the number 123.45678 as 123.45, and displays the number 12345.678 as 123E+04.
d or D Displays numbers as decimals or exponents. If you want to display numbers in decimal format, specify each digit to be displayed with d or D. For example, the format specification dd.ddd displays a number with two places before and three places after the decimal point. In numbers that have more places before the decimal point than you specified, DIAdem automatically expands the display. You cannot delete leading blanks with Trim or LTrim if you format the values with D, for example:
Call MsgBoxDisp(Trim(Str(1234,"DDDDDDDDD"))) ' => "     1234"
e Displays numbers as exponents. For example, d.dde displays the format 1.23E+01.
h Displays numbers with powers of ten. For example, d.ddh displays numbers in the format 1.23*10².
. or, Separates the places before and after the decimal point. For example, d.dd displays numbers in the format 1.23.
b Displays numbers in binary format. For example, DIAdem displays the number 43 as 101011.
$ Displays numbers in hexadecimal format.
If more characters follow after the first $ character, DIAdem uses this character as the prefix for the result, for example:
Call MsgBoxDisp(Str(1234,"$0x")) ' => 0x04D2
If further $ characters follow after the prefix, these characters indicate the number of places. DIAdem interprets all characters behind the last $ character as postfix, for example:
Call MsgBoxDisp(Str(1234,"$ $$$$$$$$hex")) ' => 000004D2hex
If no further character follows after the first $ character, DIAdem shows the number to be formatted as a hexadecimal value and uses the $ character before the numbers as ID for the hexadecimal display.
Call MsgBoxDisp(Str(1234,"$")) ' => $04D2
! Suppresses NoValues.
abs Suppressing the sign. You can combine this identifier with the characters listed above, for example, abs d.dd.
ENG Displays numbers in Engineering format. The Engineering format is an exponential format that has a multiple of 3 as the exponent. You specify the number of places after the decimal point with .d. For example, the format ENG.ddd specifies three places after the decimal point. If you specify a d before the decimal point, the point is always the fifth character. For example, the format ENGd.ddd specifies the display " 1.234E+03" or "-123.123E-06". With a non-proportional font, the points can be aligned to each other, for example, in tables in DIAdem VIEW or in DIAdem REPORT.
ENGSI Corresponds to the display of numbers in Engineering format. This format specification adds the decimal prefixes of the International System of Units (SI) to the exponential format.
Call MsgBoxDisp(Str(1234,"ENGSI.d")) ' => 1.2k
Call MsgBoxDisp(Str(12,"ENGSI.dd"))  ' => 1.20da
ENGM Corresponds to the display of numbers in Engineering format. This format specification adds the decimal prefixes of the International System of Units (SI) to the exponential format. The format specification uses these decimal prefixes only for numbers in the thousands range.
Call MsgBoxDisp(Str(1234,"ENGM.dd")) ' => 1.23k
Call MsgBoxDisp(Str(12,"ENGM.dd"))   ' => 12.00

Formatting Time Values in Text

To interpret data as numeric values, use # as the first character.

Use the following format instructions for the time formats:

m or M Month
d or D Day
y or Y Year
k Calendar week
h or H Hour
n or N Minute
s or S Second
f Fraction of a second

Example: Call MsgBoxDisp(Str(CurrDateTimeReal,"#MM/DD/YYYY hh:nn")) is 7/27/2005 06:00.

Note  If you use the uppercase in the format instructions above, DIAdem deletes leading zeros with leading nulls. The format specification hh:nn:ss displays, for example, 01:01:00, the format specification HH:NN:SS displays 1: 1: 0, and the format specification HH:nn:ss displays 1:01:00.
hhh or HHH Display of the consecutive hours. More than 24 hours are possible.
Example: Call MsgBox(Str(TTR("0000/01/02 03:04:05","#yyyy/mm/dd hh:nn:ss"),"#hhh:nn:ss")) is 27:04:05.
ampm Display in a 12-hour format with a.m. or p.m.
Example: Call MsgBoxDisp(Str(CurrDateTimeReal,"#hh:nn ampm")) is 06:00 p.m.
AMPM Display in 12-hour format with AM or PM
Example: Call MsgBoxDisp(Str(CurrDateTimeReal,"#hh:nn AMPM")) is 06:00 PM.
ap Display in 12-hour format with a or p
Example: Call MsgBoxDisp(Str(CurrDateTimeReal,"#hh:nn ap")) is 06:00 p.
AP Display in 12-hour format with A or P
Example: Call MsgBoxDisp(Str(CurrDateTimeReal,"#hh:nn AP")) is 06:00 P.
CRLF Adds a linefeed.
Example: Call MsgBoxDisp(Str(CurrDateTimeReal,"#MM/DDCRLFYYYY")) equals:

12/31
2018

Use the following format instructions to display months and days of the week as text:

#t, #tt, #ttt, ... Months with 1, 2, 3, ... characters, for example, Nov
#w, #ww, #www, ... Days of the week with 1, 2, 3, ... characters, for example, Sun
#T Months written
#W Weekdays written
Note  You can use the format specifications for months and weekdays only for formatted reading out of date/time specifications.
Note  Use the TimeFormat variable to specify the time format that DIAdem uses when no other time format is specified.
Note  Some variables, for example CurrTime, CurrDate, and CurrDateTime, return dates or time values as text. You must use the TTR function to convert the text into numeric values before you can format the text.
Note  Use NRF to label a 2D axis with two lines in the time format. DIAdem repeats the first line at every scale value. DIAdem positions the bottom line in the center of the time unit. For example, if you enter the format # tttNRF yy, DIAdem displays the first three characters of the particular month at each scaled value. DIAdem displays the last two numbers of the particular year in the second line, at the position that shows the middle of the particular year.
The CRLF character adds a linefeed in every row.
Note  Databases often use #yyyy-mm-dd hh:nn:ss as the time format.

Subscript and Superscript

Use the following control characters for subscript and superscript:

^h Changes text to superscript.
^t Changes text to subscript.
^n Undoes one level of the subscript or superscript.

You can cascade subscript and superscript. DIAdem reduces the size of each level of the subscript or superscript. For example, the Level 2 subscript is smaller than the Level 1 subscript.

Formatting Text with User Commands

Use user commands to execute complex formatting. For example, use a script request to label axes with text such as In the border range. You define user commands in a script. If you use user commands for format settings, you must enclose the user commands in two @@ characters, for example, @@MyFunc@@. You must register scripts before you can use them.

To transfer the value currently to be formatted, use transfer parameters in functions. Use the CurrFormatValue variable to get the number to be formatted, for example, the current table value or the current value on the axis scaling. Use the CurrChnNo variable to use the number of the current data channel.

Note  The Format Numbers dialog box assists you in formatting time values and numeric values.

Procedures

Displaying Differently Formatted Text | Inserting Text | Rotating Text | Subscript and Superscript | Using Variables in Text

WAS THIS ARTICLE HELPFUL?

Not Helpful