Jump to content

SyntaxError EOL while scanning literal


twk

Recommended Posts

Yeah,

The single quote that you have in the name is going to cause you all sorts of trouble. VW uses single quotes to define string literals. Therefore it does not understand how to handle your line with three single quote marks in it.

The best option would be to change the name of the Custom Title so it does not contain quote marks.

The second and are worse option would be to somehow "escape" the single quote inside the string so it can be recognized.

My Python is not good enough to do that from memory and I don't have time to work it out right now. Hopefully this will put you on the right track.

  • Like 1
Link to comment

Thanks Josh and Pat,

So Josh, you mentioned it has been "acknowledged" as a bug and "not an easy fix"

 does this mean that :

  • the-powers-that-be at the Vectorworks Dev section know that this is a fix and it will take a long time to fix it? or
  • the Vectorworks Dev people know of this and are actively finding a fix? or
  • this is a bug that can't be fixed?

I'm wondering whether i need to tag JimW and ask him to forward this to the relevant parties. By the way, where do we submit bugs for stuff like this? or when functions don't behave the way they should? are the forums the best place? @JimW

Link to comment

A bug or not, it's never a good idea to have a parameter contain a special character.

Since you can localise a parameter, have you tried that instead ? This makes the original name of the param "PARAM" and then you localise it in anything you'd like "PARAM's"
When working (codewise) with the value you need the first one, the second one is only used when displaying to the end user in the OIP.

Link to comment

Maybe the screenshot is a bit misleading..

The actual parameter name doesn't have an apostrophe in it. Its the value of the parameter.

eg

If I want the value of this Parameter ('title_cust') to have a value of : Floor Plan 01, it works, once I include an apostrophe it breaks. And the only way to use the plugin again, is to restart vectorworks.

eg, I cant type Floor Plan 'Existing'.. it will have to be typed into the object info pallette as Floor Plan \'Existing\'

The whole plugin works well until you enter a value into this parameters field (title_cust), and that value has an apostrophe. What Josh suggested, is at the moment, the only way we can have it work. (By adding escape characters \' to include the apostrophe into the fields value)

Hope this clears things up..

 

 

Link to comment

I think maybe some confusion here.

If you have a line of python code that you have written in the script for you plugin that looks like this

vs.Ptitle_cust = 'Ground Floor Plan ''

Then to fix the problem you need to change the code to

vs.Ptitle_cust = 'Ground Floor Plan \''

This is because your original python code finishes a string then starts a new string but doesn't finish it which is why you are getting a 'syntax error EOL while scanning string literal' because you opened a new string with your third quote mark and python has read all the way to the end of the line (EOL) looking for a forth quote mark to terminate the string and not found it. The correction adds a backslash character to escape the quote so python ignores it when looking for the end of the string. 

If the error occurs when you type the text into the object info pallet then that would definitely be a bug in vectorworks. But from looking at your error message I'm pretty sure that is code you have written that it causing the problem?

Edited by Will
Link to comment

Hi @Will, thanks for your feedback.

That snippet in the debug window :

vs.Ptitle_cust = 'Ground Floor Plan ''

Was NOT written by me. When setting up parameters for a plugin in the VW Plugin Editor, whatever parameter name you specify, in the background, VW will store it as variable with an extra 'P' in front of it. 

example:

- I set a parameter name in the Plugin Editor as 'title_cust' with a default value of 'hello'.

- In the background VW stores whatever value that's assigned to this parameter in a variable called vs.Ptitle_cust = 'hello'

This is further discussed by others here :

https://forum.vectorworks.net/index.php?/topic/42954-python-newbie-retrieving-parameters-from-oip/

 

 

 

Link to comment
  • 4 weeks later...

So.. further to this threads discussion, I had an idea for this problem from another thread (

https://forum.vectorworks.net/index.php?/topic/45875-evaluating-if-a-variable-has-changed/

 

The idea was to add a custom widget to the plugin using :

 

result = vs.vsoAddWidget(widgetID, widgetType, locName)

WidgetTypes:

	kFieldLongInt     = ;
	kFieldBoolean     = ;
	kFieldReal        = ;
	kFieldText        = ;
	kFieldCalculation = ;
	kFieldHandle      = ;
	kFieldCoordDisp   = ; 
	kFieldPopUp       = ;
	kFieldRadio       = ;
	kFieldCoordLocX   = ;	
	kFieldCoordLocY   = ;

	kWidgetButton     = ;
	kWidgetStaticText = ;
	kWidgetDisclosure = ; 

 

..and using the widgetType = 4 (Text)

 

The problem is, as @JBenghiathas mentioned, is that there is no way to get values from these added/inserted widgets. Does anyone know then, what these Widgets are used for then?

( @Pat Stanford, @orso b. schmid, @Dieter @ DWorks, @Hippocode, @GioPet, @MarissaF), sorry just tagging people who've helped me in the past :):) . Tagging you Marrisa because this happens in Marionette as well, with Text Parameters for Marionette Objects.

 

Cheers

 

Link to comment

Buttons, dividers, and static text are the only useful standalone widgets in VS. Any other widgets must be linked to a parameter. 

 

There's really no workaround for your issue from a coding standpoint, as Vectorworks isn't escaping the parameter field values. Your only option is to have the user escape special characters with a backslash. 

 

 

You can submit bugs bugs directly with this online form:

 

http://www.vectorworks.net/support/bugsubmit

  • Like 1
Link to comment
14 minutes ago, Will said:

As a workaround could you add a button which opens a custom dialog and have fields there which allow you to enter the information. I Just tried this and it works fine.

 

Yes will, that is the current (undersired) work-around.

 

Cheers

Link to comment
  • 11 months later...
  • 2 years later...

An EOL ( End of Line ) error indicates that the Python interpreter expected a particular character or set of characters to have occurred in a specific line of code, but that those characters were not found before the end of the line . This results in Python stopping the program execution and throwing a syntax error .

 

The SyntaxError: EOL while scanning string literal error in python occurs when while scanning a string of a program the python hit the end of the line due to the following reasons:

  •     Missing quotes
  •     Strings spanning multiple lines

Strings can't normally span multiple lines. If you don't want the string to appear on multiple lines but you want to initialize it on multiple lines (so you can read it more easily), you can "escape" the newline by putting a backslash before the newline. If you want it to appear on multiple lines, you can use triple quotes around the string.

 

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