locked
The question of "LDCall.Compile(path)" RRS feed

  • Question

  • (translated by Google translator)

    Hello.

    Tell me, please, what is the result if I compile the code, which has a syntax error by using the function "LDCall.Compile(path)" ?

    I'm afraid to check it out myself. I'm afraid to damage anything on my computer.

    Thank you.

    Sunday, January 29, 2017 3:03 PM

Answers

  • Hi,

    LDCall.Compile just uses the Small Basic compiler to compile an sb file (*.sb) to an exe.  This is identical to running the sb file in the SB environment.  So you cannot do any additional harm with this command.

    Of course if you then run the exe it could be damaging, just like any other sb program, for example it could delete files so you should never run any compiled sb code that you are not sure of of the source code.

    The use for LDCall.Compile is to interactively compile an sb file from another, usually to then run this compiled code in some way, either getting a subroutine from it using LDCall.Include and LDCall.CallInclude or running directly with LDProcess.Start.

    You could actually write (save to a file), compile and run an SB file from within another which could create some interesting effects.

    Sunday, January 29, 2017 3:15 PM
  • LDCall.Compile(path) internally uses a call of 'SmallBasicCompiler.exe' (hidden in the background) to compile an SB source file.

    Just like executing the command

    [SB-InstallPath\]SmallBasicCompiler.exe" [C:\Path\Projects\]CompDemo.sb

    from the command line.

    If you run eg.

    "C:\Program Files (x86)\Microsoft\Small Basic\SmallBasicCompiler.exe" "C:\myPath\etc.\CompDemo.sb"

    against a file CompDemo.sb,  then there are 2 possible outputs from 'SmallBasicCompiler.exe':

    1.) CompDemo.sb: 0 errors.   (if successfull, -> LDCall.Compile would return "C:\myPath\etc.\CompDemo.exe")

    2.) CompDemo.sb: 3 errors.   (if failed with eg. 3 errors -> LDCall.Compile would return "".)

    LDCall.Compile(path)  cannot report more than it can read from the 'SmallBasicCompiler.exe' output, and that's just this single line: 'SBFile.sb: X errors.'

    Detailed error messages are only available in the SB IDE.


    • Edited by Pappa LapubEditor Saturday, February 4, 2017 7:04 PM
    • Proposed as answer by jricestkEditor Tuesday, February 14, 2017 8:07 PM
    • Marked as answer by litdev Tuesday, February 14, 2017 8:41 PM
    Saturday, February 4, 2017 6:59 PM
    Answerer

All replies

  • Hi,

    LDCall.Compile just uses the Small Basic compiler to compile an sb file (*.sb) to an exe.  This is identical to running the sb file in the SB environment.  So you cannot do any additional harm with this command.

    Of course if you then run the exe it could be damaging, just like any other sb program, for example it could delete files so you should never run any compiled sb code that you are not sure of of the source code.

    The use for LDCall.Compile is to interactively compile an sb file from another, usually to then run this compiled code in some way, either getting a subroutine from it using LDCall.Include and LDCall.CallInclude or running directly with LDProcess.Start.

    You could actually write (save to a file), compile and run an SB file from within another which could create some interesting effects.

    Sunday, January 29, 2017 3:15 PM
  • (translated by Google translator)

    Will the in this case, any console window with a message about a compilation error?


    Sunday, January 29, 2017 3:27 PM
  • (translated by Google translator)

    I tried to compile code that contains a syntax error.

    Small Basic Editor showed an error message, but usage the function "LDCall.Compile(path)" did not show any message.

    Thanks for the help.

    Sunday, January 29, 2017 4:03 PM
  • Are you asking why "LDCall.Compile(path)" didn't show an error message?

    Thanks!


    Ed Price, Azure Development Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Thursday, February 2, 2017 3:47 PM
  • (translated by Google translator)

    То Ed Price

    Yes. I'm asking why "LDCall.Compile(path)" didn't show an error message.

    Thursday, February 2, 2017 6:01 PM
  • LDCall.Compile(path) internally uses a call of 'SmallBasicCompiler.exe' (hidden in the background) to compile an SB source file.

    Just like executing the command

    [SB-InstallPath\]SmallBasicCompiler.exe" [C:\Path\Projects\]CompDemo.sb

    from the command line.

    If you run eg.

    "C:\Program Files (x86)\Microsoft\Small Basic\SmallBasicCompiler.exe" "C:\myPath\etc.\CompDemo.sb"

    against a file CompDemo.sb,  then there are 2 possible outputs from 'SmallBasicCompiler.exe':

    1.) CompDemo.sb: 0 errors.   (if successfull, -> LDCall.Compile would return "C:\myPath\etc.\CompDemo.exe")

    2.) CompDemo.sb: 3 errors.   (if failed with eg. 3 errors -> LDCall.Compile would return "".)

    LDCall.Compile(path)  cannot report more than it can read from the 'SmallBasicCompiler.exe' output, and that's just this single line: 'SBFile.sb: X errors.'

    Detailed error messages are only available in the SB IDE.


    • Edited by Pappa LapubEditor Saturday, February 4, 2017 7:04 PM
    • Proposed as answer by jricestkEditor Tuesday, February 14, 2017 8:07 PM
    • Marked as answer by litdev Tuesday, February 14, 2017 8:41 PM
    Saturday, February 4, 2017 6:59 PM
    Answerer
  • (translated by Google translator)

    I am very grateful to you.

    I was afraid to run the compiled file which contains a syntax error. Now I feel calm.

    Thank you.

    Saturday, February 4, 2017 7:19 PM
  • OK.

    I was afraid to run the compiled file which contains a syntax error.

    I guess, with 'compiled file' you mean an older compiled Exe file. Because: If you get a syntax error when compiling (F5), then your source code wont compile and run with that error. If there's an Exe though, its probably an Exe from a previous successfull execution (then look at its modification date/time). So if you've created an exe, it cannot have a syntax error (else it would not exist) and you can run it.

    • Proposed as answer by jricestkEditor Tuesday, February 14, 2017 8:07 PM
    Saturday, February 4, 2017 8:52 PM
    Answerer