Jump to content
Developer Wiki and Function Reference Links ×

If a parameter value of a PIO is invalid how would you alert the user?


MaxStudio

Recommended Posts

I have a script that creates a plugin object that accepts a parameter, call it "ParamA". ParamA is an integer. The script creates a rectangle, duplicates it and offsets it a specified distance.

I use a repeat/until to repeat the procedure "ParamA" number of times.

My problem is this. If the user sets ParamA to 0 the plugin crashes.

I know I can test the parameter early on in the script using:

If ParamA>=0 Then BEGIN

{my script}

END

ELSE BEGIN

END;

But I'm curious to know what the best practice is when it comes to a situation like this? I don't want my scripts to crash, but I also don't want the user to sit there and wonder why nothing is happening. Should I use a dialog to explain to the user what went wrong? Or is there a way to highlight the parameter in the Object Info Pallatte? How do you handle this situation?

Link to comment

There are various ways of correcting this.

One would be checking paramA as you did, and correcting it as it has to be "1" as minimum.

if paramA <= 0 THEN
SetRField(); => change paramA to 1 in the object

Instead of correcting it without asking the user, you could also create a popup that it has to be atleast 1, and having that popup in a loop until the user gives a correct number.

Or you could ignore the "until loop" if paramA <= 0, but if that means nothing gets drawn, you can't select the object once you deselect it....

Link to comment

I would use a AlertInformDontShowAgain(); or a AlertInform();. If you set the boolean "minorAlert" to True, the message will appear in the lower right bottom of VW (although i thought there was a preference somewhere to not show this or only give a sound alert, but i can't seem to find it...).

Link to comment
  • Vectorworks, Inc Employee

The best thing to do is trap the bad value in your script that creates the object. You can present a dialog in the script and make the user correct the problem there before you create the object.

If you need to deal with the problem in the object it's common to just set the parameter to the minimum value in your case.

The problem with presenting a dialog happens when you have multiple objects selected and they all need to present the dialog and the user needs to dismiss each dialog.

If you set them to be a "minorAlert" it may still show as a standard Alert Dialog if the minor alert is issued multiple times.

The DontShowAgain may work but in general, objects are not supposed to generate dialogs without a specific user action.

FYI: The preference for minor alerts is to show then in the mode bar. If you disable the preference it will show a minor alert in the middle of the screen as the standard alert.

Link to comment

The problem with presenting a dialog happens when you have multiple objects selected and they all need to present the dialog and the user needs to dismiss each dialog.

If you set them to be a "minorAlert" it may still show as a standard Alert Dialog if the minor alert is issued multiple times.

Since objects are executed in sequence, this should not be a problem if the value on the other selected objects is corrected before they execute.

Link to comment

I created a separate file the is referenced as a test for all values. I test the value.. if it it's below 0 i use and AlertInform(); then set the parameter to the minimum value. It draws the object using the minimum value but alerts the user that they input an invalid number. If the parameter is a dimension I tried using an ABS to convert the negative value to an absolute instead of inserting a minimum value.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...