Jump to content
Developer Wiki and Function Reference Links ×

Script has bad interaction with user file.


Recommended Posts

OK.  I'm hoping someone can help me with this.

 

I'm having a problem where some scripts start misbehaving after a while.  @PatStanfordhelped me track it down a few months ago.  He showed my how to fix it, but it's a bit of a draconian fix.

 

I have many scripts like the one below:

 

Procedure FontSizePlus1;
{Badly scripted by Michael Klaers}

VAR
	
	WSHand		: Handle; 				{Handle to Worksheet}

	topRow,leftColumn,bottomRow,rightColumn,fontIndex,fontSize,fontStyle  :INTEGER;

	currentCellRow,currentCellColumn,topRangeRow,leftRangeColumn,topRangeSubrow,bottomRangeRow,rightRangeColumn,bottomRangeSubrow   :INTEGER;

	newFontSize	:INTEGER;

	LoopColumn,LoopRow	:INTEGER;

BEGIN
	WSHand:=GetTopVisibleWS;
	
	GetWSSelection(WSHand,currentCellRow,currentCellColumn,topRangeRow,leftRangeColumn,topRangeSubrow,bottomRangeRow,rightRangeColumn,bottomRangeSubrow);
	
	For    LoopColumn := leftRangeColumn TO rightRangeColumn
	DO	BEGIN
		
			FOR LoopRow :=	topRangeRow TO bottomRangeRow
			DO	BEGIN
				
				GetWSCellTextFormat(WSHand,LoopRow,LoopColumn,fontIndex,fontSize,fontStyle);
	
				newFontSize := fontSize+1;
	
				SetWSCellTextFormat(WSHand,LoopRow,LoopColumn,LoopRow,LoopColumn,fontIndex,newFontSize,fontStyle);

				Message('Font Size ', newFontSize);

				END;
		END;
END;

RUN(FontSizePlus1);

It's super simple (the only kind I write :-).  It has served me well from 2011 to 2016.  After a while in 2016 or 2017 it will start throwing this error every time I run it:

5934de0e3d1bb_ScreenShot2017-06-04at11_14_44PM.png.94b192de7cbdae404bbc6927982e77bb.png

Here's the weird thing.  The script still works.  If I dismiss the error message, it just goes on and does its job.  Other users don't get this error message.

It seems like it's getting a zero value for a row or column?

 

This solution - thanks Pat -  is to delete my user file.  /Users/MK/Library/Application Support/Vectorworks/2017.  That works for a while until it doesn't.

 

Obviously, this is no fun.

 

Any ideas?  What can this script be doing to the user file?  Or, what is stored in the user file that changes over time that could interact with this script?

 

 

Thanks in advance.

 

mk

 

Link to comment

Michael,

 

Does your worksheet have any extra rows or columns or are they hard up against the edges?

 

I had to modify my PIOFields script for 2017 to add some extra rows/columns to get it to run right. I was getting the same errors/warnings.

 

When I paste your script into the ScriptEditor, Row 19 is the GetWSSelection line. I think there may be a bug.

 

Try adding some space around your margins and see what happens.

Link to comment

I don't know why it goes away.

 

For me on VW2017 it errors immediately in a spreadsheet row. Runs properly on a  database row. That tells me it has something to do with the SubRow returns an invalid value in the GetWSSelection call.

 

Actually, I think I do know. It is a warning not an error. Therefore when you are running in Vectorscript Developer Mode (VW Preferenced, Session tab), it stops and displays the dialog. When you nuke the user folder, it turns off developer mode.

 

You can either turn off developer mode when you are not actually developing, or you can be patient for a few months and see what happens. ;-)

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