Xcode Line Limit? Help!

Does Xcode have a line limit? My script for the applicaqtion I’m working on is 4063 lines long, and whenever I save the script it doesn’t syntax it with the colors and different typefaces. However, the changes that I make do take effect in the application after it is built, even though the script is not saving properly. There are no build errors what so ever. Can anyone tell me what is going on, I’m exasperated!

Hmm, that’s interesting. Before OS X, the old TextEdit style record format had a limit of something like, um, 8000 or so “runs” of styles. This generally wasn’t a problem, as TextEdit was limited to handling only about 32k of text anyway, (about 32k div about 8k means every sequence of about four characters could have their own style).

You could perhaps break your longish script up into 2 or more scripts, although Xcode does then make it difficult for those scripts to “talk” to one another… if they need to do so.

Jonn8 mentioned in another thread that the best approch is to have a master “interface” script that contains all of the event handlers, and to then use “load script” to bring other scripts into the master script that have handlers for doing much of the work.

I don’t think multiple scripts are really possible. I have aroung 50 global variables, and probably even more secondary variables, so I really can’t see a way for them to talk to each other. Anyone have any more insights?

50 global variables… is alot. :wink: Even if you really need that many, it isn’t a great hardship to pass them off to handlers in other scripts from time to time:


global gWhatever

...

set scriptLibrary to load script "whatever"

...

-- pass it in, get it back:
--
set gWhatever to DoIt( gWhatever ) of scriptLibrary

It’s likely that you need some optimization of your code. Do you have lots of sections where you are doing almost the exact same thing, with just slight changes? It’s best to incorporate these into handlers.

If it is really just the loss of syntax coloring that bothers you, you might consider simplifying the styles you have set. For instance, I use the same style for both my variables and for operators, such that:
x + y
uses only a single style run rather than three.

I’ve recently run into this problem again and it is a pain. It forced me to be very creative with my code and I came up with lot of optimizations such as:

Aside from eliminating a lot of extraneous code this way, if you are making an app for Mac OS X 10.3+ only, look into Cocoa Bindings for your prefs:

http://developer.apple.com/cocoa/cocoabindings.html

it will save tons of code. If you’re very adventurous, you could move bug chinks of code to Obj-C for huge speed gains and cool bragging rights. Barring that, Arthur is right (reiterating what I allegedly wrote), try to split your code into several scripts.

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]