Page 1 of 1

Why do empty spaces cause syntax error?

Posted: Mon Jul 03, 2017 4:07 pm
by misohoza
Whenever I try to copy and paste a script from the forum or from the Steinberg's developer site, the script module gives me a syntax error. This script is copied from the developer site:

Code: Select all

-- find all effects and print their names
effects = this.program:findEffects(true)
 
if effects[1] then
    for i, effect in ipairs(effects) do
        print(effect.name)
    end
else
    print("Could not find any effects!")
end
The script is perfectly ok when typed in manually.

But when I copy and paste it I get this: Syntax Error: 3: unexpected symbol near char(194):
 
After deleting the empty line 3 the first error is fixed but then I get this:
Syntax Error: 4: unexpected symbol near char(194):     for i, effect in ipairs(effects) do

Does anyone know why is this happening and how to fix this?

Re: Why do empty spaces cause syntax error?

Posted: Tue Jul 04, 2017 2:25 pm
by AposMus
I've had the same issue.

I suspect when you copy scripts from the developer site you use double click to select all, as their tool tip suggests.

For some reason this ads a few blank or "space" ascii characters to the copied script. I've found if you select all text by the normal click and drag way (bottom to top is easiest), you avoid this issue.

Re: Why do empty spaces cause syntax error?

Posted: Wed Jul 05, 2017 2:45 pm
by misohoza
Thanks AposMus.

At least I know I'm not the only one having this issue.
Unfortunately doing it the way you suggested doesn't work for me either. I can copy it line by line which is not really efficient.

Thanks for confirming.

Re: Why do empty spaces cause syntax error?

Posted: Tue Aug 01, 2017 3:25 am
by abject39
You guys are a life saver! I was ready to throw my computer in frustration lol.

Re: Why do empty spaces cause syntax error?

Posted: Fri Aug 11, 2017 5:04 pm
by Tekknovator
I always use an external editor such as Atom or VSCode with lua extensions. They show pretty quickly if there is something fishy about your code and you can clean up whitespace stuff. The only annoying thing is that you need to save your script in a lua file before the external editor can open it.
You can configure the external editor in options. Now when you click the edit button it will open the external editor instead of the annoying built in. I guess the build in is really just for glimpsing at a script or making a quick change.