[JW Lua] Finale crash when argument is nil
Jari Williamsson
jari.williamsson at mailbox.swipnet.se
Tue Sep 22 12:55:21 CEST 2015
Charles/Thomas,
During test phases of coding, this code might help:
http://www.lua.org/extras/5.2/strict.lua
The code is linked from the following page, and here are also more
approaches to detect undefined variables:
http://lua-users.org/wiki/DetectingUndefinedVariables
I have just made some brief tests with it, but I just wanted you to know
that there might be approaches available to detect spelling errors in
variables in Lua.
Best regards,
Jari Williamsson
On 2015-09-08 20:03, Charles O. Lawrence wrote:
> Thomas,
> It would seem to me that since you are calling your own user-written
> function, you can pass it any argument you want. How is JW Lua it to know
> if the argument is unknown (misspelled)? It would have no way to know you
> really wanted to call the function with the iteration variable as the
> argument, just because the function call is within the for...do loop. I
> think a run-time error is all that can be expected. JW Lua should perhaps
> be able to catch the error and terminate the script gracefully as opposed to
> crashing Finale.
>
> BTW: With the argument spelled correctly, it runs but does nothing that I
> can see.
>
> Charles
>
> -----Original Message-----
> From: JWLua [mailto:jwlua-bounces at jwmusic.nu] On Behalf Of Thomas Weber
> Sent: Tuesday, September 8, 2015 12:26 AM
> To: JW Lua Mailing List <jwlua at jwmusic.nu>
> Subject: [JW Lua] Finale crash when argument is nil
>
> I found Finale is simply crashing with this script:
>
>
> local function getStaffSpec(noteEntry)
> local staffSpec = finale.FCCurrentStaffSpec()
> staffSpec:LoadForEntry(noteEntry)
> return staffSpec
> end
>
> for entry in eachentry(finenv.Region()) do
> getStaffSpec(enty) -- misspelled
> end
>
>
> One can of course add a check in the script to make it fail gracefully, but
> I think ideally, such a check should be built into JW Lua itself.
>
> Have a great day!
> Thomas
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
>
More information about the JWLua
mailing list