View Full Version : maxscript tips/problems
subpixel 11-01-2002, 03:46 AM as a newcomer to maxscript (yet proficient in a variety
of scripting languages) I'd love some tips in debugging
and whatnot.
I keep having one problem in particular, where comments
aren't recognised! I'll have an error on a certain line of code.
I go to comment it out (-- ....), and resave the script, but when
I try to run the script again, the same error pops up, claiming
the same line has an error (with new --'s and everything).
I also get error msgs on lines of code I know are OK,
like lines pasted from blur scripts, or friggin declaring
a simple vanilla variable, or including another .ms file!!
Any tips on figuring out error msgs? Like if it says,
"expected <factor>" whether it means an error involving
a <string>, <number>, or <path_name>?
and what's with "Syntax error: at bad,..." or
".., at to,..."
any and all guru/sage advice is welcome.
|
|
LFShade
11-01-2002, 11:48 PM
I've noticed that the "Expected <factor> ..." error crops up a lot for no apparent reason. It usually jams up at the end of a bracketed chunk of code (a function, an if.. clause, etc.). I've sometimes gotten past it by just deleting the empty space at the end of the line after the closing brace and then hitting enter again to put back the hard return. Of course, this error is also reported if you forget to put in a closing bracket or quote mark somewhere, so I tend to check my bracketing frequently with Ctrl-b while coding.
As far as general debugging, I just put questionable code into try statements and pop up a messagebox on catch() pointing to where my code went wrong. Sometimes I'll create a "pseudo-stack-trace" by dumping variable values to the listener. Both take a little extra time and effort to set up, but it's better than scratching your head and deciphering cryptic MXS error messages all the time.
Here's a question: does anybody else have problems with the MAXScript editor after returning from Visual MAXScript in Max5? Mine stays grayed out, loses its scrollbar, and completely forgets about syntax coloring. Anybody got a way around this? It's annoying:hmm:
googlo
11-02-2002, 03:48 AM
I think there is a program called 'Ultraedit' and it has a 'template' that you can download for it to highlight and work very similar in showing by color coding what is what according to how it would be normally when maxscript editing within Max. I think the template file isn't up to date with max five though with it's definitions.
LFShade
11-02-2002, 03:02 PM
Ultraedit is nice...but then I'd lose the ability to quickly evaluate the script. Tabbing between apps and reopening/evaluating is too much of a distraction for me:)
subpixel
11-04-2002, 02:19 AM
Originally posted by LFShade
I've noticed that the "Expected <factor> ..." error crops up a lot for no apparent reason....
It seems every scripting environment has its own and
abundant quirks that you just have to figure out - part
of the hurdle. Thanks for reconfirming LFShade.
So, using UltraEdit "templates" is how you get
maxscript to color-code keywords?!! I've seen
color-coded examples in the docs & wondered.
Used to use UE to write HTML and ASP.
I'll try that out.
LFShade
11-04-2002, 06:41 AM
Script editors automatically color your code in Max5. The syntax coloring is there in R4, too, it just doesn't happen dynamically. You have to force it with a keyboard shortcut (I think it was Ctrl-D) whenever you want the coloring to be updated.
subpixel
11-04-2002, 09:18 AM
Ah, Ctrl-D! That'll def do for now. Using 4.2
Here's some things I've learned:
1) You need a space after "-- ", or the comment chokes.
Isn't this way with some other langs.
2) I like to use a scrap_script file to test stuff out on.
I can better learn the grammatical quirks of each element
of maxscript (manipulating strings, arrays & objects; rendering from cameras to named files; grabbing objects and materials).
Then copy over a few lines of code to my main script.
I suppose I could use the Listener for this, but I like
to keep that clean so I can see errors, traces, and feedback.
3) A library of Blur scripts as excellent reference examples! :thumbsup:
4) when the code gets blurry, it's time for bed.
LFShade
11-05-2002, 06:32 AM
Now you're talkin'! I slap together test functions in a throwaway editor window as well, but I use listener to test them. You can enter code into the upper (pink) part of the listener and watch for output and tracebacks in the lower (white) half. This works well for me, especially since I very rarely turn on the macro recorder (which clutters up the upper listener like crazy!). I use Edit->Clear all on the lower listener whenever its contents get unmanageable.
By the way, if you happen to be into working with external editors, there's a way to get a sort of on-the-spot evaluation like you can do with the MAXScript editor. Tie a quickie macroScript to a keystroke or button, that calls FileIn() on your working script [and perhaps calls one or more functions for output testing]. Then you can edit and save in your external editor, tab to Max, and hit your macro shortcut to evaluate the updated script. It's a few extra steps, but when you have an editor you're very fond of it at least eases the pain of developing MAXScript with it.
CGTalk Moderation
01-13-2006, 08:01 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.