unexpected token errors

21 views
Skip to first unread message

Brandon RAGS Smith

unread,
Nov 14, 2020, 11:55:43 AM11/14/20
to Google Apps Script Community
The unexpected token is something that the browser is burping on.  Sometimes is is simply a typo, a } instead of ).  But you will encounter situation in which your code is squeaky clean and you know there's nothing extra.  You even log the raw html to the console log so you can eyeball the actual stream of characters being sent to the browser.

After a great many trails and errors and false paths, the only thing that has fixed this error in my environment -- Google Apps Script webapp on Chrome on the latest Windows platform -- is to break up my script into a whole bunch of little ones. Probably will also work if I follow the best practices and move most the the script into other html files and include them between separate script pairs..

html...
<script>
  code function 
</script>
<script>
  code  some lines;  declarations, assignments
</script>
<script>
  code another function
</script>
<script>
  code
</script>
html...

My tentative conclusion is that there is something seriously wrong with the way the apps script editor handles the <script> tag.  Adding a bunch of unnecessary ones made the error go away when there wasn't one visible in the raw data.  

Since Google recently hit me up with a survey about how to improve the apps script editor, my hopes are up that they are in fact working on it. . They didn't ask much in the quick survey and about all I wrote there was to make the syntax checking  and hint stuff more like brackets and to use a live preview like brackets does.

I don't mind working in an IDE that lives in browser windows.  My first IDE was Borland's Delphi, and I've worked in the Oracle, IBM and Microsoft versions.  Google is a lot less restrictive but  sometimes harder to find out what you need.  The one thing about IDE that make them work best is their central organizing tool; usually  an interactive outline that has links to everything you need.

I do hope that space on the left in the Apps Script editor  is brought up to modern IDE standards.

Just curious:  bunch of these lines are showing up in my console window when I'm loading my webapp into Chrome.  Should I be concerned?  is there something in my code causing this?
 
content-ads.js:1 INS: content-ads.js loaded:  about:blank
content-tss.js:50 TSS: Excluding content tss (trigger: send-message)
content-tss.js:1 TSS: content-tss.js loaded:  https://docs.google.com/_/og/bscframe






Alan Wells

unread,
Nov 14, 2020, 9:40:25 PM11/14/20
to Google Apps Script Community
There is a new Apps Script editor coming.
The current editor sometimes misses errors that the browser doesn't like.
There is an alternative to the Apps Script online code editor.

Are you loading external libraries from a script tag?

Brandon RAGS Smith

unread,
Nov 16, 2020, 2:53:38 PM11/16/20
to Google Apps Script Community
I took a quick look and had to double take since I have done a lot of work in Visual Studio some years ago.  This Visual Studio Code might be just the ticket until the new editor comes out.

I had been loading them and I took them out to eliminate that as a cause.  Reworked design and don't need now.
Reply all
Reply to author
Forward
0 new messages