Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
π¨ Skimp | 25% Off until March 30 Buy Now
[Code] better inputbox() wrapper
-
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement