1

I have created a menu item in MapBasic. I need to call a procedure to open a dialog box as the result of one of the menu items being selected. I believe I am having trouble declaring the sub procedure that will be called. I have not included the sub procedure, because it is not right. Here is my code:

Declare Sub Main
Sub Main
    Create Menu "Test" ID "12" As
        "Preferences",
        "Leads",
        "LeadsRemain",
        "Accts",
        "AcctsRemain"
    Alter Menu Bar Add "Test"
End Sub

1 Answer 1

2

You just need to have a Calling statemet after each menu item, like this.

Sub Main
    Create Menu "Test" ID "12" As
        "Preferences" Calling Prefs,
        "Leads" Calling Leads,
        "LeadsRemain" Calling LeadsRemain,
        "Accts" Calling Accts,
        "AcctsRemain Calling AcctsRemain "
    Alter Menu Bar Add "Test"
End Sub

And a Sub Routine hooked up to each of those, like this

Sub Prefs
Dialog
    Title "Hello!"
    Control StaticText 
        Position 5,10
        Width 100
        Height 20
        Title "Hello again"

End Sub

Repeat the above for the others.

The MapBasic help docs have some really good info on these, just look for 'Create Menu' and 'Dialog' and you should find the help docs. There are loads more options for the menu items and dialogs than I provided, for example you can add Help text, IDs so you can alter them as the result of other actions and more. Like I said, the MapBasic help docs are invaluable once you know what you're looking for.

Good luck, and if you have any further problems just let us know!

2
  • Awesome. If all is well please consider marking the answer as accepted! And if you come across any other issues then just ask a new question. Commented May 21, 2013 at 15:38
  • There should be a little tick underneath the vote up buttons. If you hover over it it should say something along the lines of 'Mark this answer as accepted'. This will also earn you a bit of reputation! Commented May 22, 2013 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.