Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter TwoLanguage Overview (continued)

ConsoleGetHandle Function

Overview

The ConsoleGetHandle function retrieves the handle associated with a specific console window.

Syntax/Parameters

Syntax

handle = ConsoleGetHandle ( [int id] );

Parameters

id

An optional int specifying a console ID from 0 to 7. If omitted, the default console window ID of 0 is returned.

Return Value

Returns a handle value or NULL_HANDLE on error. Use the GetLastError function to retrieve a formatted error code.

Remarks

The handle value returned is a window handle when operating as a Windows application or a pseudo handle for the command line console window. The pseudo handle is not the handle to the actual shell that executed the script but rather an internal semaphore for standard input and output.

Example

In the following example, the console handle is retrieved to use the AddMessage function to write to the console.

        string  list[];
        int     ix;
        handle  hCon;
        
        AddMessage("This is the default log");
        ConsoleOpen();
        hCon = ConsoleGetHandle();
        
        AddMessage(hCon, "File dump to console:");
        list = EnumerateFiles(GetScriptFolder() + "*.*");
        while (list[ix] != "") {
          AddMessage(hCon, "  %2d : %s", ix, list[ix]);
          ix++;
          }
          
        AddMessage("This is the END of the default log");

In this example, the ConsoleOpen function is inert when running as a console application; however, it is needed when running in the IDE since, unlike the ConsolePrint function, the AddMessage function will not automatically open a console in the IDE. As a console application, the messages (file list) are dumped to the console and then the default log. Under the IDE, the default log appears in the Information View and a console window will contain the files.

Related Functions

Platform Support

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

Legato IDE, Legato Basic