CHerb Posted February 28 Share Posted February 28 I have a WS with a database row that has a RunScript call in one of the columns. When I run a different script that sends a vs.RecalculateWS command to the WS with the runscript all the variables set befroe the vs.RecalculateWS command are cleared and I get an error saying the variable is not defined. Is there a way around this? The runscript is running a small script to convert the string value stored in a record back to the document dimensions since it seems you cant write a real value to a record from a script. Currently working in VW2024. Quote Link to comment
Pat Stanford Posted February 28 Share Posted February 28 Can you post the file or a sample that we can look at. This does not sound like something that is working properly? What happens when you manually recaculate the worksheet?. Quote Link to comment
CHerb Posted March 1 Author Share Posted March 1 (edited) @Pat Stanford Recalculation works fine, both in the WS Editor and in the script. Its just any lines after the Recalculate command that needs variables from before the recaculate command that need dont work. I cant post the file but I was able to recreate the issue in a another file so I have attaced that. WS Recalc.vwx Edited March 1 by CHerb Quote Link to comment
Pat Stanford Posted March 1 Share Posted March 1 I have played with this and see what you are seeing. It appears to be a Python problem because I can simulate your script in Vectorscript and it seem to run fine. A workaround if your script does not use too many variables would be to store them into the Saved Setting and then recall them after the Recalc. I am filing a bug on this for you. X1 = '5' vs.SetSavedSetting('CHerb', 'X1', X1) ws = vs.GetObject('Worksheet1') vs.RecalculateWS(ws) B1, X1 = vs.GetSavedSetting('CHerb', 'X1') vs.Message(B1, ' -- ',X1) Quote Link to comment
Pat Stanford Posted March 1 Share Posted March 1 Bug submitted VB-210191 Python vs.RecalculateWS deletes variables and does not work on WS Images I found an additional problem in that a Python Recalculate works on a Worksheet open for editing, but does not update the WS Image if the WS is not open for editing. Vectorscript properly handles both issues. 1 Quote Link to comment
Pat Stanford Posted March 7 Share Posted March 7 Just heard back on my bug report. This is a limitation of Python. When the script switches contexts to be able to do the recalculate the variables are lost. Best solution in Python is to save the variables and restore them after the recalculate. Better solution is to do this kind of script in VS. 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.