Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter FiveGeneral Functions (continued)

TrailStringBefore Function

Overview

The TrailStringBefore function will truncate the target string if it exceeds the specified size and adds an ellipse style trail (‘...’) at the beginning of the string.

Syntax/Parameters

Syntax

string = TrailStringBefore ( string source, int size );

Parameters

source

A string with a maximum size of 1MB.

size

An int specifying the size of the string before the trail. If the string exceeds the size less than 3, the source will be trailed off. The value must be > 4 and less than 1,048,575.

Return Value

Returns a string as the source string or a trailed off version of the source string.

Remarks

The TrailStringABefore function is useful for displaying a string in a limited space without roughly truncating but rather adding a “trail before” indicator. If the function does not alter the string, the value retrieved from the GetLastError function will be ERROR_SOFT. The last error can also be ERROR_RANGE if the size parameter does not conform to the above specification.

There are multiple methods of “trailing off” strings. The following illustrates examples:

        string             s1, s2;

        s1 = "This is the story of my cats, purry, furry and cute";
        AddMessage("Original String         :%s:", s1);

        s2 = TrailStringAfter(s1, 20);
        AddMessage("TrailStringAfter        :%s:", s2);

        s2 = TrailStringAfterAlways(s1, 20);
        AddMessage("TrailStringAfterAlways  :%s:", s2);

        s2 = TrailStringAfterAlways(s1, 1000);
        AddMessage("TrailStringAfterAlways  :%s:", s2);

        s2 = TrailStringBefore(s1, 25);
        AddMessage("TrailStringBefore       :%s:", s2);

Results in the following placed in the log:

        Original String         :This is the story of my cats, purry, furry and cute:
        TrailStringAfter        :This is the stor...:
        TrailStringAfterAlways  :This is the stor...:
        TrailStringAfterAlways  :This is the story of my cats, purry, furry and c...:
        TrailStringBefore       :...purry, furry and cute:
        

Related Functions

Platform Support

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

Legato IDE, Legato Basic