MapInfo Pro Developers User Group

 View Only
  • 1.  Create Frame Name clause-How can I use a variable in it in MapBasic?

    Posted 08-21-2020 14:28
    In MapBasic 2019, I am trying to do a number of Create Frame commands in a Layout through a Loop. I need to be able to refer to these Frames later with LayoutItemID commands, so I need to use the Frames' Names.

    It appears that you can only have a static quoted name, such as "Myframe", in the Name clause, but I need to be able to have different Names as the Loop creates the frames. I have tried adding a counting variable z in the Name clause such as Name "Myframe"+z, but this doesn't seem to work. When I do the LayoutItemID, I get a -1 result meaning it didn't work. Anyone know how I can do this?
    Here is my code portion:
         For z=1 to PagesNeeded
            y=y+1

            Add Designer Page Window LayoutNum
            Set Layout Window LayoutNum Page y

            Create Frame
                Into Window LayoutNum
                (0.3,0.701) (10.751,8.009)
                Name "Myframe"+z
                FillFrame On

            Set Designer Frame
                Window LayoutNum
                ID 2
                From Window FiftyPBrowseNum

            iMapFrameID=LayoutItemID(LayoutNum, "Myframe"+z, LAYOUT_ITEM_TYPE_MAPPER)
            Print "iMapFrameID Browser = "+iMapFrameID

            iMapFrameWinID=LayoutItemInfo(LayoutNum, iMapFrameID, LAYOUT_ITEM_INFO_WIN)
            Print "iMapFrameWinID Browser = " + iMapFrameWinID

            Set Browse Window iMapFrameWinID Column Resize

        Next

    Thanks,
    Sam


    ------------------------------
    S W
    Knowledge Community Shared Account
    ------------------------------


  • 2.  RE: Create Frame Name clause-How can I use a variable in it in MapBasic?

    Employee
    Posted 08-24-2020 08:28

    Hi Sam

    You can capture the ID of the frame when you create it.

    The last created frame on the layout has the same ID as the number of elements on the layout:

      Create Frame
          Into Window LayoutNum
          (0.3,0.701) (10.751,8.009)

          FillFrame On

       iMapFrameID = LayoutInfo(LayoutNum, LAYOUT_INFO_NUM_ITEMS)

    I hope that helps



    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------