WhoCanDo Posted November 2, 2016 Share Posted November 2, 2016 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. Quote Link to comment
michaelk Posted November 2, 2016 Share Posted November 2, 2016 Are you using 2017? Is the worksheet in a RB folder? If so, see this thread: mk Quote Link to comment
WhoCanDo Posted November 2, 2016 Author Share Posted November 2, 2016 No, I'm still on 2016. No updates between working last week and not working this week. Other suggestions appreciated. Quote Link to comment
JBenghiat Posted November 2, 2016 Share Posted November 2, 2016 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 Quote Link to comment
WhoCanDo Posted November 3, 2016 Author Share Posted November 3, 2016 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); Quote Link to comment
MullinRJ Posted November 3, 2016 Share Posted November 3, 2016 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 Quote Link to comment
WhoCanDo Posted November 3, 2016 Author Share Posted November 3, 2016 Thankyou, I'll keep that in mind. So h := NextObj (h); was the answer to my problem. Thanks to all. Quote Link to comment
Recommended Posts
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.