Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.6k

Application v 6.6a

  

 

Chapter ElevenSGML Functions (continued)

SGMLValueToTWIPS Function

Overview

The SGMLValueToTWIPS function converts a pvalue to TWIPS including ranging for percentages or em values.

Syntax/Parameters

Syntax

int = SGMLValueToTWIPS ( PVALUE value, [int box], [int em] );

string = SGMLValueToTWIPS ( string value, [int box], [int em] );

Parameters

value

A dword or string specifying a structured parameter value (can also be defined as a PVALUE). If the provided data type determines the returned data type.

box

An optional int value specifying the size of the containing box. This value is only used if the incoming unit type is PT_PERCENT. If omitted, the default is 8640 or 6 inches.

em

An optional int value specifying the size of reference em (the widest character in a font). This value is only used if the incoming unit type is PT_EM. If omitted, the default is 240 or 12 points.

Return Value

If the value parameter is a dword, an int is returned containing the number of TWIPS.

If the value parameter is a string, an string is returned containing the number of TWIPS as a decimal string or an empty string on failure..

Use the GetLastError to retrieve a formatted error code. If the units of the value is not supported, it is assumed to be ‘px’ (pixel) and the last error will be set to ERROR_EOD. The conversion will be performed as if the value was pixels.

When the value parameter is a string, a syntax error ERROR_SYNTAX or an ERROR_SOFT can occur if the string is poorly formatted or has unsupported units. The lower portion can have PT_ERROR_ type detail (such as PT_ERROR_UNITS).

Remarks

A TWIP, or twentieth of a point, is 1/20 of a printer's point, or equivalently 1/1440 of an inch. It is the standard unit of measure for positional and spacing values in SGML/XML-based document layout for applications such as Microsoft Word or Open Office (.docx).

This function will also process the arbitrary unit keywords such as ‘%’ or ‘em’ based on the default or provided parameters box and em.

The value parameter unit can also be expressed in border keywords using the PT_KEYWORD:

PT_KEYWORD | PK_BORDER_THIN       Thin

PT_KEYWORD | PK_BORDER_MEDIUM     Medium

PT_KEYWORD | PK_BORDER_THICK      Thick

The function assumes the keyword ordinal values are for border-width group of CSS properties. Since the context is not checked, other property ordinal values will return unpredictable results.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic

Page revised 2026-09-14