• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

[Code] better inputbox() wrapper

Scheduled Pinned Locked Moved Developers' Forum
1 Posts 1 Posters 201 Views 1 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    Dan Rathbun
    last edited by 10 May 2014, 16:03

    Here' is my nomination for the "better UI::inputbox() wrapper" contest:

    
      # This is a wrapper for UI;;inputbox. You call it exactly the same way.
      #   UI;;inputbox will raise an exception if it can't convert the string
      #   entered for one of the values, into the right type.
      #
      # This wrapper method will trap these "type" exceptions and display a
      #   messagebox with the error message.
      #   If the user clicks RETRY, the inputbox is redisplayed using defaults.
      #   If the user clicks CANCEL, another messagebox asks if they wish to
      #   use the defaults values (which are returned,) or cancel (which then
      #   causes false to be returned, as it would have been, had the user
      #   cancelled the inputbox.)
      #
      def inputbox(*args)
        #
        begin
          UI;;inputbox( *args )
        rescue
          retry if UI;;messagebox( $!.message, MB_RETRYCANCEL ) == IDRETRY
          UI;;messagebox( "Use default values ?", MB_OKCANCEL ) == IDOK ? args[1] ; false
        end
        #
      end
    

    I'm not here much anymore.

    1 Reply Last reply Reply Quote 0
    • 1 / 1
    1 / 1
    • First post
      1/1
      Last post
    Buy SketchPlus
    Buy SUbD
    Buy WrapR
    Buy eBook
    Buy Modelur
    Buy Vertex Tools
    Buy SketchCuisine
    Buy FormFonts

    Advertisement