I've hit an issue with using the Dialog Preserve command. I get the error message "Invalid Dialog preserve command. There is no active dialog". As far as I can tell I've followed the guidance provided in the MapBasic reference guide. Here is a subset of my code which reproduces the error in MapInfo 11.5 and 12
' * Include mapbasic.def - required for various MapBasic commands including "CMD_INFO_XXX" Include "mapbasic.def" ' * OK button handler for Dialog Declare Sub gmeu_goToGridReference ( gmeu_userEnteredGridRef As String ) Sub gmeu_goToGridReference ( gmeu_userEnteredGridRef As String ) Dialog Preserve Print "You entered: " + gmeu_userEnteredGridRef End Sub Declare Sub Main Sub Main ' * Create a custom dialog box to obtain the grid reference from the user Dim gmeu_userEnteredGridRef As String Dialog Title "Go to Grid Reference" Control StaticText Title "Enter a grid reference:" Control EditText Into gmeu_userEnteredGridRef Control OKButton Control CancelButton If CommandInfo( CMD_INFO_DLG_OK ) Then Call gmeu_goToGridReference( gmeu_userEnteredGridRef ) End If End Sub
I've tried moving the position of the declare statements from the top to just before the Subs are coded but this has not changed the result - I didn't think it would but wanted to be thorough.