Jump to content

Recalculate WS clearing variables


Recommended Posts

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.

Link to comment
Posted (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 by CHerb
Link to comment

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)

 

Link to comment

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.

  • Like 1
Link to comment

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.

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