Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter FiveGeneral Functions (continued)

CreateSortImage Function

Overview

The CreateSortImage function parses the incoming data and expands numeric values to the precision size. This normalizes a string for sort comparing.

Syntax/Parameters

Syntax

string = CreateSortImage ( string data, [int precision] );

Parameters

data

A string containing source data.

precision

An optional int that specifies the size of the numeric expansion. This value should be larger than the widest expected number.

Return Value

Returns a string with a normalized word, if the function fails an empty string is returned. Use the GetLastError function to retrieve a formatted error code.

Remarks

When sorting strings, numbers are counted as simple characters. Therefore, a sort will result is:

“1, 10, 11, 12, 2, 20, etc.” or “a1, a10, a11, a12, a2, a20”.

The desired result would typically be:

“a1, a2, a10, a11, a12, a20”.

CreateSortImage expands each discrete number in the string by adding leading zero padding. So the returned values would be:

“a0001, a0002, a0010, a0011, a0012, a0020”.

Thus, when sorted, the values are in the desired order. Obviously, this would be destructive to the source data. Therefore, a separate companion image string is created for each original and added to a table column. The table can then be sorted using the SortTable function. 

The source data can be of any size but the result after expansion cannot be larger than 4096 bytes.

Related Functions

Platform Support

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

Legato IDE, Legato Basic