2.2.4.33.9 Page::Layers

Description

A Collection of all Layers in a page.


Get a Layer object by index from the Layers Collection.


Get a layer object by name from the Layers Collection.

Syntax

Collection<Layer> Layers


Layer Layers(int iIndex = -1)


Layer Layers(LPCSTR lpcszName)

Parameters

index
[input] The index of the requested Layer. If < 0 (default) then the active layer is returned.


lpcszName
[input] The name of the requested Layer.

Return

Returns a valid Layer object if iIndex is less than the number of layers in the Page otherwise returns an invalid Layer object.


Returns the named Layer object on successful exit and an invalid layer object on failure.

Examples

EX1

int Page_Layers_ex1()
{
    GraphPage gp;
    gp.Create("origin");
    if( gp.IsValid() )
    {
        gp.AddLayer();
        gp.AddLayer();
        gp.AddLayer();
        int iLayers;
        foreach(GraphLayer gl in gp.Layers)
            iLayers++;
        printf("%s has %d layer(s)\n", gp.GetName(), iLayers);
    }
    return 0;
}

EX2

// For this example to run a Graph window must be the active window in the project.
int Page_Layers_ex2()
{
	GraphPage gp = Project.Pages();
	if( gp )
	{
		GraphLayer gl = gp.Layers(); // Get active layer
		printf("%s has %d layer(s) with active layer %d\n", gp.GetName(), gp.Layers.Count(), gl.GetIndex() + 1); // Show LabTalk index
	}
	return 0;
}

EX3

int Page_Layers_ex3()
{
	WorksheetPage wp;
	wp.Create("origin");
	if( wp )
	{
		wp.AddLayer();
		wp.AddLayer();
		Worksheet wks1 = wp.Layers(1); // Get second Worksheet by index
		if( wks1 )
		{
			Worksheet wks2 = wp.Layers(wks1.GetName()); // Get same (second) sheet by name
			if( wks2 )
				printf("%s has %d layers with second sheet(layer) named %s\n", wp.GetName(), wp.Layers.Count(), wks2.GetName());
		}
	}
	return 0;
}

Remark

Header to Include

origin.h

See Also

Reference