Include "MapBasic.Def" DECLARE SUB Main SUB Main Dim num_windows,nLayer as integer num_windows = NumWindows() print (num_windows) Dim i,map_windowid,legend_windowid,map_layer_count as integer Dim info_name, info_type, info_windowid as string For i = 1 to num_windows print ("............") print (i) info_name = (WindowInfo(i, WIN_INFO_NAME)) info_type = (WindowInfo(i, WIN_INFO_TYPE)) info_windowid = (WindowInfo(i, WIN_INFO_WINDOWID)) ' print (info_name) ' print (info_type) ' print (info_windowid) if info_type="35" then print ("legend window") legend_windowid=int(info_windowid) elseif info_type="1" then print ("map window") map_windowid=int(info_windowid) map_layer_count=MapperInfo(info_windowid, MAPPER_INFO_LAYERS) ' print (map_layer_count) 'LayerListInfo(map_window_id, numeric_counter, attribute ) '**This is where we build the legend in the layout '**I'm just adding a static 2 inces to the position for each layer '**- that needs to depend on the size of the previous frame For nLayer = 1 to map_layer_count Create Designer Legend Custom 'Position (2.0,2.0) Units "in" 'Width 2.8 Units "in" Height 5 Units "in" Frame From Layer i Position (2.0 + ((i-1) * 2), 2.0) Units "in" Next 'nLayer end if next print ("Collected layer/map info") End Sub?