PDA

View Full Version : scripts prevented from exposing code


DannyBoy3
12-16-2011, 04:26 AM
I'm wanting to stop an encrypted script from throwing an error and interrupting the thread thus exposing the script for inspection. It seems that no matter how many 'try (catch)' clauses I put in, eventually I am able to 'break' the script. Is there a general catch all to prevent a script 'breaking'?

Moosley
12-16-2011, 10:02 AM
Have you considered using the assert systems?

DannyBoy3
12-16-2011, 10:41 AM
tell me more

Gravey
12-16-2011, 12:10 PM
if you are having to use try/catch everywhere then you probably aren't doing enough error checking and/or your code is poorly written. You should also debug your code unencrypted so that you can see which line(s) fail and make corrections accordingly.

ideally, post the code you are having problems with for others to see and help you debug.

Moosley
12-16-2011, 12:45 PM
tell me more

Full Documentation of the assert functions are here: Assert Functions (http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-821E791F-6D80-48C7-8A65-65BE73C551C-2145.htm)

Hope that helps :)

PEN
12-16-2011, 01:27 PM
Is any one here using the assert function as I have not really tried to add it to my work flow.

Klunk
12-16-2011, 01:34 PM
i imagine it's designed to mirror the c\c++ function/macro and if so it's really a debug only, obviously we don't have a specific "debug" compile option as with c\c++, which would automatically turn it off for the release build, but i still think it's supposed to be used in the same way, finding bugs and errors in the development stage and not for handling unforseen errors in a finished script.

Moosley
12-16-2011, 02:20 PM
Yes, that's pretty much what I use them for... the new AssertReporter stuff in 2012 is also pretty useful. Much nicer than lot's of print statements everywhere!

If you're lazy you can also use the result of the assert function in an if statement to catch otherwise invalid parameters and what not and print a custom error message at the same time...

Pjanssen
12-16-2011, 05:08 PM
Is any one here using the assert function as I have not really tried to add it to my work flow.
It's very useful for testing. See this (sort of) unit test I wrote to (regression-)test a struct:
https://github.com/Pjanssen/Outliner/blob/develop/tests/nestedlayers_test.ms
It is of course no replacement for try/catch, it's a different thing altogether. In fact, it will only throw more exceptions if something is wrong. I suppose you could use it to throw specific exceptions a bit more easily in 'production code' though, instead of using if x then throw m.

CGTalk Moderation
12-16-2011, 05:08 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.