JavaScript Global Classes
    • 30 Jan 2026
    • 6 Minutes to read
    • Contributors
    • PDF

    JavaScript Global Classes

    • PDF

    Article summary

    Applies to: Lasernet 11

    Color

    Description

    The Color class is used for representing colors.

    Methods

    setRgb

    Description

    Sets the color code of the color.

    The value is a bitmask on the form 0xRRGGBB, where RR=red, GG=green, and BB=blue, all as hexadecimal digits.

    Parameters

    Colorcode : Number

    Returns

    None

    Example

    var mycolor = new Color();

    mycolor.setRgb(0x00ff00); // one way to set color to green

    setRgb

    Description

    Sets the red, green and blue color values of the color to red, green and blue, respectively.

    Parameters

    red : Number

    green : Number

    blue : Number

    Returns

    None

    Example

    var mycolor = new Color();

    mycolor.setRgb(0, 255, 0); // another way to set color to green

    Dir

    Description

    The Dir class is used for searching and manipulating directories.

    Constructors

    Dir

    Description

    Creates a new Dir instance which points to the given filePath.

    Parameters

    filePath : String

    Returns

    Dir

    Example

    var d = new Dir(‘c:\\myfolder’);

    Enums

    FilterSpec

    These filtering options are used in the entryList method.

    Dirs

    List directories only

    Files

    List files only

    Drives

    List drives only

    NoSymLinks

    Do not list symbolic links

    All

    Lists everything

    TypeMask

    Dirs | Files | Drives | NoSymLinks

    Readable

    List files that the application has read access to

    Writable

    List files that the application has write access to

    Executable

    List files for which the application has execute access

    RWEMask

    Readable | Writable | Executable

    Modified

    List files that have been modified

    System

    Lists system files

    AccessMask

    Readable | Writable Executable | Modified | Hidden | System

    SortSpec

    These sorting options are used in the entryList method.

    Name

    Sort by name

    Time

    Sort by modification time

    Size

    Sort by file size

    Unsorted

    Do not sort

    SortByMask

    Name | Time | Size

    DirsFirst

    List directories before files

    Reversed

    Reverse the sort order

    IgnoreCase

    Sort case-insensitively

    Static Properties

    current

    Description

    Returns the current directory for the application.

    Access

    Read

    Returns

    String

    Example

    var myDir = Dir.current;   //  C:/Program Files/Formpipe Software/Lasernet 10

    home

    Description

    Returns the home directory for the user under which the application runs.

    Access

    Read

    Returns

    String

    Example

    var myDir = Dir.home;   //  C:/Users/LasernetUser

    root

    Description

    Returns the root directory.

    Access

    Read

    Returns

    String

    Example

    var myDir = Dir.root;   //  C:/

    drives

    Description

    Returns an array of the drives on the system.

    Access

    Read

    Returns

    String[]

    Example

    var myDir = Dir.drives;   //  C:,D:

    Static Methods

    cleanDirPath

    Description

    Removes duplicate directory separators /  and removes any relative references .. and . found in filePath.

    Parameters

    filePath : String

    Returns

    String

    Example

    var myDir = Dir.cleanDirPath("c:\\program files\\..\\lasernet");

    //  c:/lasernet

    convertSeparators

    Description

    Returns a converted version of filePath where all directory separators are converted to backslash.

    Parameters

    filePath : String

    Returns

    String

    Example

    var myDir = Dir.convertSeparators(Dir.cleanDirPath("c:\\files\\..\\lasernet"));

    //  c:\lasernet

    Properties

    name

    Description

    Returns the name of the directory. This is not the full path, but simply the last part.

    Access

    Read

    Returns

    String

    Example

    var myDir = new Dir('d:\\lasernet');

    var lastFolderName = myDir.name;   //  lasernet

    path

    Description

    The full path of the directory.

    Access

    Read, Write

    Returns

    String

    Example

    var myDir = new Dir('d:\\lasernet');

    var lastFolderName = myDir.path;   //  d:/lasernet

    absPath

    Description

    Returns the full absolute path – usually starting with a drive specification.

    Access

    Read

    Returns

    String

    Example

    var myDir = new Dir('d:\\file\\..\\lasernet\\');

    var MyPath = myDir.absPath;   //  d:/lasernet

    canonicalPath

    Description

    Returns the full path, but without any symbolic links or . or .. relative references.

    Access

    Read

    Returns

    String

    Example

    var myDir = new Dir('d:\\file\\..\\lasernet\\');

    var MyPath = myDir.canonicalPath;   //  D:/lasernet

    readable

    Description

    Returns true if the directory is readable otherwise false is returned.

    Access

    Read

    Returns

    Boolean

    Example

    var myDir = new Dir('d:\\file\\..\\lasernet\\');

    var MyPath = myDir.readable;   //  false

    exists

    Description

    Returns true if the directory exists otherwise false is returned.

    Access

    Read

    Returns

    Boolean

    Example

    var myDir = new Dir('d:\\file\\..\\lasernet\\');

    var MyPath = myDir.exists;   //  false

    Methods

    filePath

    Description

    Returns the filepath of the filename file in the directory.

    Parameter

    Filename: String

    Returns

    String

    Example

    var myDir = new Dir('d:\\lasernet\\');

    var MyPath = myDir.filePath('test.spl');  // d:/lasernet/test.spl

    absFilePath

    Description

    Returns the absolute filepath of the filename file in the directory.

    Parameter

    Filename: String

    Returns

    String

    Example

    var myDir = new Dir('d:\\lasernet\\..\\file');

    var MyPath = myDir.filePath('test.spl');   // d:/file/test.spl

    cd

    Description

    Changes directory to the given dirname if possible. Otherwise an exception is thrown.

    Parameter

    Dirname : String

    Returns

    Boolean

    Example

    var myDir = new Dir('d:\\lasernet\\..\\file');

    myDir.cd('c:\\lasernet');

    cdUp

    Description

    If possible, changes the directory to the parent directory of the current one. If not possible, an exception is thrown.

    Parameter

    None

    Returns

    Boolean

    Example

    var myDir = new Dir('d:\\lasernet\\..\\file');

    myDir.cdUp();   // changes to d:/

    entryList

    Description

    Returns an array with the list of all files and directories in the directory that matches the given filterSpec and sortSpec.

    Parameter

    filter : String

    [filterSpec : Number = All]

    [sortSpec : Number = Name]

    Returns

    String[]

    Example

    var dir = new Dir('c:\\temp\\');

    var filelist = new Array(dir.entryList('*', Dir.All));

    fileExists

    Description

    Checks if the file filename exists in the directory. Returns true if it does, otherwise false is returned.

    Parameter

    Filename : String

    Returns

    Boolean

    Example

    var dir = new Dir('c:\\temp\\lasernet');

    if (dir.fileExists('file.temp'))

    {

       // do something now we know the file exists in the directory

    }

    mkdir

    Description

    Creates the directory dirname in the directory. If for some reason it cannot create the directory (e.g. invalid name) it throws an exception.

    Parameter

    dirname : String

    Returns

    Boolean

    Example

    var dir = new Dir('c:\\temp\\');

    dir.mkdir('test');

    mkdirs

    Description

    Creates the directory tree dirname if possible. Otherwise an exception is thrown.

    Parameter

    Dirname : String

    Returns

    Boolean

    Example

    var dir = new Dir('c:\\temp\\');

    dir.mkdirs('c:\\temp\\lasernet');  // creates the Lasernet folder in c:\temp

    rmdir

    Description

    Deletes the directory dirname if possible (directory must not contain any files). Returns false if the directory cannot be deleted and true on success.

    Parameter

    Dirname : String

    Returns

    None

    Example

    var dir = new Dir('c:\\temp\\');

    dir.rmdir('lasernet');  // removes the lasernet folder in c:\temp

    rmdirs

    Description

    Deletes the specified dirname directory and any parent directories provided they are empty. Returns false if the directory cannot be deleted and true on success.

    Parameter

    Dirname : String

    Returns

    None

    Example

    var dir = new Dir('c:\\temp\\');

    dir.rmdirs('lasernet');   // removes the lasernet folder and parent folder in c:\temp\lasernet

    rmRecursive

    Description

    Removes the directory, including all its contents.

    Returns true if successful, otherwise false.

    If a file or directory cannot be removed, rmRecursive() keeps going and attempts to delete as many files and subdirectories as possible, then returns false.

    If the directory was already removed, the method returns true (expected result already reached).

    Note: This function is meant for removing a small application-internal directory (such as a temporary directory), but not user-visible directories. For user-visible operations, it is recommended to report errors more precisely to the user, to offer solutions in case of errors, to show progress during the deletion since it could take several minutes.

    Parameter

    None

    Returns

    Boolean

    Example

    var dir = new Dir('C:\\Temp\\FolderToRemove');

    var result = dir.rmRecursive();

    logger.logEvent(Debug, result ? 'Removal Succeeded' : 'Removal Failed');

    FontStyle

    Description

    The FontStyle class is used for manipulating font style properties.

    Properties

    bold

    Description

    Gets and sets the bold property of the font used for style.

    Access

    Read, Write

    Returns

    Boolean

    Example

    var globalFont = sheet.fontStyle("Global");

    globalFont.bold = true;

    color

    Description

    Gets and sets the color property of the font style.

    Access

    Read, Write

    Returns

    Color

    Example

    var globalFont = form.fontStyle("Global");

    globalFont.color = green;

    family

    Description

    Gets and sets the font name of the font style.

    Access

    Read, Write

    Returns

    String

    Example

    var globalFont = form.fontStyle("Global");

    globalFont.family = "Courier New";

    italic

    Description

    Gets and sets the italic property of the font style.

    Access

    Read, Write

    Returns

    Boolean

    Example

    var globalFont = form.fontStyle("Global");

    globalFont.italic = true;

    name

    Description

    Returns the style name.

    Access

    Read

    Returns

    String

    Example

    var globalFont = form.fontStyle("Global");

    logger.logEvent(0,’Name of Current Style = ‘+ globalFont.name);

    pointSize

    Description

    Gets and sets the pointSize property of the font style

    Access

    Read, Write

    Returns

    Number

    Example

    var globalFont = form.fontStyle("Global");

    globalFont.pointSize = 12;

    strikeOut

    Description

    Gets and sets the strike out property of the font style.

    Access

    Read, Write

    Returns

    Boolean

    Example

    var globalFont = form.fontStyle("Global");

    globalFont.strikeOut = false;

    underline

    Description

    Gets and sets the underline property of the font style.

    Access

    Read, Write

    Returns

    Boolean

    Example

    var globalFont = form.fontStyle("Global");

    globalFont.underline = true;

    ShapeStyle

    Description

    The ShapeStyle class is used for manipulating shape style properties.

    Properties

    fillColor

    Description

    Gets and sets the fill color property of the shape style.

    Access

    Read, Write

    Returns

    Color

    Example

    var globalShape = form.shapeStyle("Global");

    globalShape.fillColor = blue;

    lineColor

    Description

    Gets and sets the line color property of the shape style.

    Access

    Read, Write

    Returns

    Color

    Example

    var globalShape = form.shapeStyle("Global");

    globalShape.lineColor = green;

    lineDashes

    Description

    Gets and sets the line dashes type property of the shape style.

    Access

    Read, Write

    Returns

    Number

    Example

    var globalShape = form.shapeStyle("Global");

    globalShape.lineDashes = 2;

    var localShape = sheet.shapeStyle("Local");

    localShape.lineDashes = localShape.DotLine;

    Values

    1; SolidLine

    2; DashLine

    3; DotLine

    4; DashDotLine

    5; DashDotDotLine

    lineWeightPts

    Description

    Gets and sets the line weight property of the shape style.

    Access

    Read, Write

    Returns

    Number

    Example

    var globalShape = form.shapeStyle("Global");

    globalShape.lineWeightPts = 10;

    name

    Description

    Returns the style name.

    Access

    Read

    Returns

    String

    Example

    var globalShape = form.shapeStyle("Global");

    logger.logEvent(0,’Name of Current Style = ‘+ globalShape.name);

    Connection

    Description

    Holds the properties for a connection.

    Properties

    name

    Description

    Name of the Connection in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, connection.name);

    description

    Description

    Description of the Connection in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, connection.description);

    type

    Description

    Type of the Connection in the Configuration. Database, SharePoint, SharePoint365, AzureStorage, AzureStorageSAS.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, connection.type);

    guid

    Description

    Unique id of the Connection in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, connection.guid);

    Module

    Description

    Holds the properties for a module.

    Properties

    name

    Description

    Name of the Module in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, module.name);

    description

    Description

    Description of the Module in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, module.description);

    type

    Description

    Type of the Module in the Configuration. For example; File Input, Printer Service.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, module.type);

    guid

    Description

    Unique id of the module in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, module.guid);

    printer

    Description

    For Modules of type ‘Printer Service’, the printer can be read via this property.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, module.printer);

    printserver

    Description

    For Modules of type ‘Printer Service’, the Print Server can be read via this property.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, module.printserver);

    Printer

    Description

    Holds the properties for a printer.

    Properties

    name

    Description

    Name of the Printer module in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, printer.name);

    description

    Description

    Description of the Printer module in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, printer.description);

    printername

    Description

    Name of the printer in the Printer module in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, printer.printername);

    profiles

    Description

    A list of the printer profiles for a printer.

    Access

    Read

    Returns

    Array of PrinterProfiles (4.6.8).

    Example

    See getPrinterProfiles for example.

    PrinterProfile

    Description

    Holds the properties for a printer profile.

    Properties

    name

    Description

    Name of the PrinterProfile of a Printer in the Configuration.

    Access

    Read

    Returns

    String

    Example

    See getPrinterProfiles for example.

    Server

    Description

    Holds the properties for a Lasernet environment (previously known as a server).

    Properties

    name

    Description

    Name of the environment in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, server.name);

    description

    Description

    Description of the environment in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, server.description);

    hostname

    Description

    Hostname of the environment in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, server.hostname);

    port

    Description

    Port of the environment in the Configuration.

    Access

    Read

    Returns

    String

    Example

    Logger.logEvent(Debug, server.port);