Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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!

share|improve this answer
    
Worked perfectly! Thank you Rob –  user15642 May 21 '13 at 15:36
    
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. –  Rob Quincey May 21 '13 at 15:38
    
Silly question, but I am new to this: How do I mark the answer as accepted? –  user15642 May 21 '13 at 16:00
    
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! –  Rob Quincey May 22 '13 at 8:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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