FormatLogString Procedure

Version 2024/v13

Changes the format of Test results of a given Test type printed by ATEasy at the end of a Test to the Log window or returned by the GetLogString function.

Syntax

[ lReturnFormat = ] FormatLogString ( enTestType, sHeader, sFormatSpec [, enFlags] )

The FormatLogString procedure syntax has the following parts:

 

Name

Type

Description

lReturnFormat

enumAFormatLogStringFlag

Returned format

enTestType

Val enumATestType

The type of test

sHeader

Val BString

Test header

sFormatSpec

Val BString

Test format specification

enFlags

Val enumAFormatLogStringFlag

Test format flag

Where

enumATestType can be one of the following values:

 

Name

Value

Description

atestTypeMinMax

1

MinMax

atestTypeOther

2

Other

atestTypeRef2

3

Ref2

atestTypeRefx

4

RefX

atestTypeTolerance

5

Tolerance

atestTypePrecise

6

Precise

atestTypeString

7

String

enumAFormatLogStringFlag can be one or a combination of the following values:

 

Name

Value

Description

aFormatLogDefault

0x00

Default

aFormatLogNextIncludeHeader

0x01

Next Include Header

aFormatLogNextNotIncludeHeader

0x02

Next Not Include Header

aFormatLogNextCalculateTestStatus

0x04

Next Calculate TestStatus

aFormatLogIgnoresHeaderParameter

0x10

Ignores Header Parameter

aFormatLogIgnoresFormatSpecParameter

0x20

Ignores FormatSpec Parameter

aFormatLogAddDuration

0x10000

Display Duration column for each test in the test log, use this flag without other flags. ATEasy 2024/v13. See comments below.

aFormatLogRemoveDuration

0x2000

Do not display Duration column for each test in the test log (default), use this flag without other flags. ATEasy 2024/v13. See comments below.

Comments

The sHeader parameter is used to set the specified Test type enTestType header. For example, the default MIN-MAX header is the following string if the current Log format is the Text format:

 

"#

Test-Name

Pin

Unit

Min

Result

Max

Status\r\n"+

"---

------------------

------

------

----------

----------

----------

------"

In Log Text format, this header can be changed by setting the sHeader parameter. If the sHeader parameter contains one or more lines separated by \r\n ATEasy will use the sHeader as is when printing the test header. If the sHeader does not contain \r\n then the second line will automatically be generated by ATEasy according to the sFormatSpec parameter. In Text format, if sHeader is a null string then ATEasy will generate the header automatically.

For example:

sHeader=

 

"|

  #

|

Test Name

|

Result

|

Status

|

\r\n"+

|

"|

~~~~~

|

~~~~~~~~~~~~~~~~~~

|

~~~~~~~~~~~

|

~~~~~~~~~~~

|

"

|

The sFormatSpec string parameter contains fields characters preceded with % and an optional parameter following the field character. The field syntax is : %F[P] where F is the field character and P is the optional parameter. The field can be separated by any character (s) which are used as is. The following table describes the field codes and their parameters:

 

Field

Name

Parameter

Default Parameter

#

TestNum

[length]

3

N

TestName

[length]

20

P

TestPin

[length]

6

U

TestUnit

[length]

6

L

TestMin

[length [:decimal[:exponent]]]

10:4

H

TestMax

[length [:decimal[:exponent]]]

10:4

R

TestResult

[length [:decimal[:exponent|overflow character]]]

10:4

V

TestValue

[length [:decimal[:exponent]]]

10:4

+

TestValueMinus

[length [:decimal[:exponent]]]

7:3

-

TestValuePlus

[length [:decimal[:exponent]]]

7:3

2

GetTestMask

GetTestRef

TestRefResult

[length]

32

X

TestRefResult

[length]

8

M

GetTestMask

[length]

8

F

GetTestRef

[length]

8

D

Test.EndTime-Test.StartTime

[length]

8

S

TestStatus

[length]

6

The maximum length size parameters is 255 characters (v9 build 152d) and 80 characters for earlier versions.

Example:

sFormatSpec="| %# | %N16 | %R10:3:3 | %S |"

will generate the following Test result:

"| 001 | This is an examp | 10.245E+02 | pass |"

The user can specify an overflow character with the field R to accommodate the overflow condition where the number is bigger than the field length.  For example, with "%R6:2:*",  the test result,12345.6 will be displayed "******".  But when the length is greater then 6 and such overflow occurred, ATEasy will display the number either as a floating number or in E format.

The enFlags parameter specifies whether to include or not to include the sHeader in the next call to the GetLogString function or in the next time ATEasy outputs Test results to the Log window.

The enFlags can be used to force ATEasy to calculate the TestStatus if its value is not NONE in the next call to GetLogString.

Other flags 0x10, and 0x20 can be used to keep the Format or Header as is.

The return value indicates the previous flags state. This value can be used in order to find out whether ATEasy will include the Test header in the next call to GetLogString or in the next time ATEasy outputs Test results to the Log window.

For the HTML Log Format, as in the example below, the header which is required, can contain each field's width in percentage and the format specification uses the same width for each field. Note that since '%'  is a special field character, the user has to use '%%' to take effect the real percent sign as in a HTML format example below.

ATEasy 2024 (v13). Duration column when added is displayed normally before the Status column. The duration uses the field code D. The duration is displays in Second (suffix s), Minutes (suffix m), Hours, (suffix h), or Days (suffix d). The duration numbers are always displayed xx.xxx format followed with the suffix 's'. Millseconds are displayed only if the elapsed time < 1 minute. For example: 43.221s is 43 seconds and 221 milliseconds, 34m 55s is 34 minutes and 55 seconds, 11h 22m - 11 hours and 22 minutes, 12d 10h is 12 days and 10 hours.

To display duration calls this functions as follows:

FormatLogString(0, "", "", aFormatLogAddDuration)

To remove the duration column:

FormatLogString(0, "", "", aFormatLogRemoveDuration)

When using the Test Executive use the "Show Log Duration" to set it during OnInitProgram event or call the following command:

 

TestExec Customize Options Set (ateOptionsLogShowDuration, True)

With Duration on, The Test Log will show as follows:

 

 Example

The LANGUAGE.PRG Program contains several examples of Log formatting using the FormatLogString function. The following example demonstrates how to change the format of MIN-MAX Test results in Text Log format and HTML Log format:

Procedure OnInitProgram(): Void Public ! Occurs when a program is started.

{  

! Text Format

s=  "|Num|    Test Name   |   Result   |Status|\r\n"

s=s+"|~~~|~~~~~~~~~~~~~~~~|~~~~~~~~~~~~|~~~~~~|"

FormatLogString(1, s, "|%#|%N16|%R12:5|%S6|", 4)

}

Procedure OnInitProgram(): Void Public ! Occurs when a program is started.

{

! HTML Format

s="<TABLE BGCOLOR=INFOBACKGROUND BORDER=1 FRAME=BELOW RULES=NONE WIDTH=52%%><TR><TH ALIGN=LEFT WIDTH=6%%>#<TH ALIGN=LEFT WIDTH=20%%>Name<TH WIDTH=16%%>Result<TH ALIGN=LEFT WIDTH=10%%>Status</TABLE>"

FormatLogString(1, s, "<TABLE WIDTH=52%%><TR><TD WIDTH=6%%>%#<TD WIDTH=20%%>%N16<TD WIDTH=16%% ALIGN=CENTER>%R12:5<TD WIDTH=10%%>%S6</TABLE>", 4)

}

 

See Also

GetLogString, Print, SetLogOff, SetLogOn, SetLogString