Error 1710: Array is Empty

Started by Mykal, June 04, 2025, 05:28:12 PM

Previous topic - Next topic

Mykal

If the user clicks the Pushbutton to begin processing but has forgotten, or ommitted, to highlight an element shown in the Array, the system exits with the message 'Error 1710:  Array is Empty'.  Is there a way this can be trapped prior to the exit ???

td

There are many ways to handle errors in WinBatch scripts. Check the help file or here:

https://docs.winbatch.com/mergedProjects/WindowsInterfaceLanguage/html/HTMLWIL_EH_001.htm

However, a better approach is to prevent the error in the first place by not allowing the user to exit until they make a selection. Another alternative is to provide the user with a cancel exit.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

You may find ArrInfo() relevant and useful.

Jim

chrislegarth

I would disable the button until the array element is selected.

Mykal

Hi Guys,

Thank you for your replies and suggestions.  I don't know whether it makes any difference, but am displaying the elements of an array by means of the ReportView Control.

As TD suggested, I am trying to find a way to not allow the error in the first place.   I have tried turning ErrorMode to @OFF but all rows of code then seem to be skipped until it strikes an ErrorMode(@Cancel) thereby missing the test(s) to see if an element has been selected.

I liked chrislegarth's suggestion of temporarily disabling the button, so I put @csDisabled into the control but that doesn't seem to make any difference to the button and consequently to the process.

However, JTaylor suggested using ArrInfo(0) to show how many elements in the user's selection and this has done the trick.   Thank you Jim.

Thank you all.

Cheers,
Myk.

kdmoyers

20 years of winbatch coding experience talking here:
"turning ErrorMode to @OFF" is a fast route to agony.

It's like, if you get turned around in a maze, deciding to put on a blind fold. The effect will be profound -- you will immediately become badly lost.

A strategy I have used sometimes is to shrink my view down to the very small. Starting from the top, tiny step by tiny step, I insert Message statements to verify what I think is true.  Crude but sometimes effective.

The mind is everything; What you think, you become.

spl

Quote from: Mykal on June 06, 2025, 05:08:57 PMHowever, JTaylor suggested using ArrInfo(0) to show how many elements in the user's selection and this has done the trick.   Thank you Jim.

Thank you all.

Cheers,
Myk.

Jim is quite good at suggesting an appropriate course of action. However, given that, I am a bit curious in terms of overall design. You are using a ReportView so that implies a dialog with a Callback. My question would be: is the ReportView populated based on an array user creates from a source, or is the array based on selections by the user from existing displayed ReportView data? If the first part of the question, then no need for a dialog or ReportView if user array is empty Arrinfo(). If the second part, there are ways to disable/hide/show pushbuttons to process the user selection.
Stan - formerly stanl [ex-Pundit]

Mykal

Thank you KDMOYERS.   We are on something of the same footing, except that I use Pause statements which give you the option of canceiiling out of the process.   My scripts are littered with Pause statements which have been commented out.   Thanks again.

Mykal

Hi spl.   Each element of the array contains the user's several comments about an object he/she/they are looking at with a view to purchse.  Each element has preset items available for comment and each item can also be given a weighting.   The purpose is to compile a list of objects which have been viewed and the total score of all their items.   My problem was to do with editing the items and scores previously entered.   I wished to present the list, showing each object and its total score as well as location & score, price & score, age & score, etc, etc.    So I guess the above would suggest the array is a result of the first part of your question.

spl

Quote from: Mykal on June 08, 2025, 09:39:47 PMSo I guess the above would suggest the array is a result of the first part of your question.

Thank you, but I would think you would not have to 'guess' unless the question was not clear, and for that I apologize. But I am again curious: is this app something you developed or inherited? Probably not worth further discussion.
Stan - formerly stanl [ex-Pundit]

kdmoyers

Quote from: Mykal on June 08, 2025, 09:20:52 PMI use Pause statements which give you the option of canceiiling out.
Oh, I like that!  I may switch to Pause.
The mind is everything; What you think, you become.

SMF spam blocked by CleanTalk