CompileErrors after Restore

Posted on
  • Hello,
    i'm new at using js and the web ide.
    Yesterday, i wrote lot of lines in the web ide and it was running. I can not save files in the ide on disk: the IT rules of my company do not allow js files... :(
    So i had copy it in an editor notepad++ and saved it.

    Now, i want to continue my work. So i had open the file from the web IDE. I get a lot of errors which i don't understand.

    >  Uncaught SyntaxError: Got EOF expected '{' at line 23 col 13
    class Filter
    > Uncaught ReferenceError: "constructor" is not defined as line 26 col 5
    constructor(size)
    

    Whats wrong? How can i fix this?

    Why i can't copy from left hand side of IDE?

    Greetz
    TheAkki


    1 Attachment

  • Can you just load or copy the file into the right hand side and upload from there?

    It seems like you may have hit https://www.espruino.com/Troubleshooting­#i-ve-pasted-code-into-the-left-hand-sid­e-of-the-web-ide-and-it-doesn-t-work

  • I "only" use the tight hand side. It does not work. So i think i'am not affected by the problem with the left hand side problem. Right?

  • Thr 2020.03.26

    'So i think i'am not affected by the problem with the left hand side problem. Right?'

    Not true as, @TheAkki, I agree your code file as is, causes ther error(s) you see.

    I stripped out some detail, and found the solution.

    'i'm new at using js and the web ide'

    As you have indicated new to JS and from your coding style, I believe your background is in C/C++ as I adopted the K&R style back in the 80's, and use many of the conventions, such as same column curly braces shown in your code.

    The WebIDE needs a minor change to that thinking in order to enter a line of code, or delimit a code block.

    See: 'When you hit 'enter' after the first line' just after fifth code snippet there
    https://www.espruino.com/Quick+Start+Cod­e

    See: Heading 'Is there a Coding Style I should use' near page end
    https://www.espruino.com/FAQ


    orig

    class Filter
    {
        constructor(size)
        {
          this.size = size;
          this.elements = [];
        }
    }
    

    fix

    class Filter {
        constructor(size) {
          this.size = size;
          this.elements = [];
        }
    }
    


    Do not follow the suggestion 'The easiest way to fix this is to write code in the K&R style:' that was provided in the post #2 link, as it is clearly an error, and even documented as such, when one follows the embedded link to the wiki destination. Anyone that actually read K&R would immediately recognize that statement error.

    correct at wiki article:
    'When following K&R, each function has its opening brace at the next line on the same indentation level as its header'

    (which the code snippet example does not follow)



    I, self taught 'C' reading the original K&R book back in the late seventies, before the schools even taught here locally, and was introduced to the opening curly brace on the same line Java variant in Steve McConnell (2004) Code Complete, and dismissed it as inconvenient. It wasn't until using the WebIDE forces this convention in order to make the distinction between the end/begin of a function and a code line, that using it became necessary. Still prefer K&R style BTW.


    'So i had copy it in an editor notepad++ and saved it.'

    During the copy-n-paste step into notepad++, there is a setting (which I haven't found yet) that auto completes code blocks, based on style. It appears that a new-line was added before each curly brace, thereby violating the WebIDE requirement in order for Espruino to recognize the difference.

    Simple fix, painful as re-editing it will be.

  • @Robin Thx for the help.
    Yes, i was grow up in development with C++. Actually is my home plc programming. (Nearly zero curly braces) ;)

    So i will avoid to copy it in notepad. ;) I will try if it works.

  • Thr 2020.03.26

    'I will try if it works'

    Try the second snippet from post #4. It does work/compile.

    'So i will avoid to copy it in notepad'

    There is an option within notepad++ just haven't found it yet.

    Ohhhh, @TheAkki no need to avoid notepad++ as I use it as my primary Espruino development. I use it daily and with 1000+ lines of code, such as your code file. Edit the file which will reside in the \Projects folder of the WebIDE save location, using the nice color hilighting, bookmarks and indentation etc. within notepad++. Save the file. Go to the WebIDE and click the lower folder on the middle bar. Select that file and it will appear on the right hand editor side. Click the upload icon.

    While editing on the right side, be careful using the save icon. It is easy to get/lose file edits when using the WebIDE and notepad++ together. Got burned a few times with lost edits and took a bit of patient learning to maintain and get the hang of it.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

CompileErrors after Restore

Posted by Avatar for TheAkki @TheAkki

Actions