Jump to content
Developer Wiki and Function Reference Links ×

Recalculating Worksheets


WhoCanDo

Recommended Posts

Can anyone suggest why this has stopped working for me. The script just looks until I press ESC but it use to work for years.

 

h := FInGroup (GetParent (GetObject ('Banding Cutting List')));
while h <> NIL do
  if (GetTypeN (h) = 18) then
    RecalculateWS (h);

The worksheet "Banding Cutting List" exists in the sub-folder Worksheets in the Resource Browser. There are only 15 worksheets in this folder and yet the integer loop counter I tested just kept going past it's positive limits.

 

I must be missing something here.

 

 

Link to comment

Well, if the code you pasted is exactly as you have it, you have a while loop that doesn't change h. As long as the first statement returns a valid handle, this loop will run indefinitely. 

 

Possibly the the last time you ran this script successfully, h was nil at the outset. 

 

-Josh 

Link to comment

It's been like this for years and only recently stopped working.

 

I can see your point, so that means that VW has ignored the RecalculateWS (h) for years rather than running indefinitely and chosen to run indefinitely.

 

This maybe the fix but it counts 106 instead of the expected 15 worksheets. I'd like to know why if anyone can help.

 

h := FInGroup (GetParent (GetObject ('Banding Cutting List')));
p := 0;
while (h <> NIL) do
  begin
  p := p + 1;
  if (GetTypeN (h) = 18) then
    RecalculateWS (h);
  h := NextObj (h);
  end;
Message (p);

 

Link to comment
38 minutes ago, WhoCanDo said:

This maybe the fix but it counts 106 instead of the expected 15 worksheets. I'd like to know why if anyone can help.

 

The count is higher because there are a lot more objects in that list than Worksheets. If you put another counter inside your IF statement you should get 15 for the Worksheet count.

 

  if (GetTypeN (h) = 18) then begin
    q := q + 1;
    RecalculateWS (h);
  end;

...

  Message('Total Cnt= ', p, '  Worksheet Cnt= ', q);

 

Raymond

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...