MapInfo Pro Developers User Group

 View Only
  • 1.  Input("Pen", "Choose Pen","","pen") in 2019.3

    Posted 11-30-2020 21:40
    Hi, I'm using the new Input() function in a MapBasic app for MapInfo 2019.3

    According to the MapInfo 2019.3 release notes, I can use something like:

        dim p as pen
        p = Input("Pen", "Choose Pen","","pen")
        print p

    The issue I have is if the user clicks Cancel, then MapInfo displays the message "Could not covert data".


    Is this as expected?  Shouldn't MapInfo just close the Input dialog without any error message?  How do I determine if the user clicked Cancel so I can Exit Sub?

    You can test this in the MapBasic window.

    Thanks


    ------------------------------
    Kalu Ribush
    Dept. Jobs, Precincts & Regions (VIC)
    Melbourne VIC
    ------------------------------


  • 2.  RE: Input("Pen", "Choose Pen","","pen") in 2019.3

    Employee
    Posted 12-01-2020 02:15
    Hi Kalu

    Have you tried saving the return value into a String variable, and then check if it's empty before assigning it to a Pen variable?
    The dialog probably returns an empty string if the user cancels the dialog, similar to FileSaveAsDlg() and FileOpenDlg().

    dim p As Pen,
         rv As String

    rv = Input("Pen", "Choose Pen","","pen")
    If rv = "" Then
       Exit Sub
    End If
    p = rv

    print p

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



  • 3.  RE: Input("Pen", "Choose Pen","","pen") in 2019.3

    Employee
    Posted 12-01-2020 02:32
    I should have tried this before writing the answer above.

    The dialog returns a Pen when you specify the type to be Pen. You can however set a CancelledValue that will be returned when the user cancels the dialog. You'd then need to compare the return value to your CancelledValue to see if they match

    dim p As Pen
    p = Input("Pen", "Choose Pen", CurrentPen(), "pen", "CancelledValue=pen(1,1,34567)")
    print "pen: " + p

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



  • 4.  RE: Input("Pen", "Choose Pen","","pen") in 2019.3

    Posted 12-01-2020 04:11
    Thanks for your help Peter.
    I understand how this works now.  It's not entirely clear from the release notes.  I would have expected that cancelling the dialog should simply not update the pen variable.
    Cheers Kalu

    ------------------------------
    Kalu Ribush
    Dept. Jobs, Precincts & Regions (VIC)
    Melbourne VIC
    ------------------------------



  • 5.  RE: Input("Pen", "Choose Pen","","pen") in 2019.3

    Employee
    Posted 12-01-2020 08:59
    Hi Kalu,

    As it is a mapbasic function it has to return a value. For most types we return empty string or 0, but that is often a valid value. That is why we have the CancelledValue.

    Perhaps we should have returned a valid Pen to avoid the error.

    -Bob

    ------------------------------
    Bob Fortin
    Software Architect and Distinguished Engineer
    MapInfo Pro Development Team
    ------------------------------



  • 6.  RE: Input("Pen", "Choose Pen","","pen") in 2019.3

    Employee
    Posted 12-01-2020 09:54
    Hi Bob

    Can the CommandInfo(CMD_INFO_DLG_OK) function be used to tell if the user didn't click the OK button to close the dialog?
    Maybe that would be a better way than trying to compare two pen styles as I suggested above.

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



  • 7.  RE: Input("Pen", "Choose Pen","","pen") in 2019.3

    Employee
    Posted 12-01-2020 14:25
    Edited by Bob Fortin 12-01-2020 14:43
    That is a good idea Peter. I will add that. The cancelled value is still useful though.

    ------------------------------
    Bob Fortin
    Software Architect and Distinguished Engineer
    MapInfo Pro Development Team
    ------------------------------