I’ve been rewriting a database, converting a lot of the code into custom classes. It was all going well, but I’ve hit a weird roadblock today.
I basically have three custom classes - ‘timesheet’, which inherits from ‘employee’, which in turn inherits from ‘timeclock’. I was adding some code today when I got a “token is too long” message. I figured my code (in the declarations section) was too long, so I split the library into three, one for each class.
The token too long message disappeared, and everything compiled, but when I ran the code I got a “type mismatch on external name: EMPLOYEE” error. I spent hours trying to fix my new code, assuming it was a problem there, but through a process of elimination (and commenting out of code) I eventually came to the conclusion that the code was fine, and the problem might relate to the token is too long error.
The issue wasn’t my new code, it was in the adding of a new property to store the result of my new code. If I add even one new property to any of my three classes, I get the type mismatch error for 'EMPLOYEE". Remove it, and the code runs fine. The property can be anything, like ‘dim test as string’.
For example, this would work:
class test
dim prop1 as string
dim prop2 as string
public sub new
end sub
end class
but this wouldn’t:
class test
dim prop1 as string
dim prop2 as string
dim prop3 as string
public sub new
end sub
end class
Obviously my code is way more complex, but I wanted to give an example.
Anyway, it’s almost as if I have reached some sort of limit in Notes for the amount of properties an object can have. To make matters more confusing, I can happily add code outside of the properties (ie in the various subs and functions inside the class) - it’s literally just that one area the causes the problem, and I will compile fine.
Any ideas?
Thanks,
Karl
Subject: Couple of things worth trying
Hi Karl,
I’ve never seen that error before but I have seen problems when a script text contains one or more “bad” characters (or bytes) which aren’t always visible through designer.
It might be worth copying and pasting your code into a text editor such as “notepad++” and switch on the option “view/show all characters”. You’ll then need to scan the text for unexpected control chars which could be causing your code to be interpretted incorrectly when compiling.
With regard to the type mismatch on external name that’s usually fixable by running the “compile all lotusscript” action within Designer. Although if this error has now gone away this may be a mute point.
Recompiling the whole lot may be worthwhile, however, just to see if the “token is too long” error goes away.
Out of interest, how many properties, in total, do your classes have? I’m sure you’d have to use a very large number of them to hit a limit (if, indeed, there is a limit).
Cheers,
Phil
Subject: Solved, I think, but it seems to be a bug
Hi Phil,
Thanks for your suggestions - I had tried the ‘recompile all’ option earlier (without anything being revealed).
The classes are used by a form that opens by default when the database is opened. It looks like any time I make a change to a property in my script library, I have to go into that form, make a change, and save the form. I’ve been going in, commenting a line out, saving, and then un-commenting the line and saving again.
It seems to work, although it’s irritating. I’m wondering whether there is something wrong with the form, although it compiles fine.
very strange.
Karl
Subject: OO in LS is more than a little arcane…
-
I’ve been doing it for years; it’s mainly building that’s the issue, once it’s built it works quite well, which is why I keep doing it. (grin)
-
Anyway, the only size limit I’ve seen is in the actual editor itself. Before I started using OO in LS I had a Script Library that was over 6000 lines long. One day the editor simply decided to truncate the code, and ever after it would no longer save. I was freaking out until I tried a TS Analyze on it, and that tool had the entire library. I copy and pasted it into two smaller libraries, then started learning OO on LS.
-
I have a OO system that’s been deployed for two years that’s comprised of nearly forty LS classes with inheritance five levels deep. One of the classes in the hierarchy is 1256 lines, so I’m nothing thinking you’re hitting any size limit, you’re hitting the “flakey build” limit.
-
What I have to do to get this system to build is this:
-
Make changes and try them. If they work without error then stop here. Go buy a lottery ticket!
-
If I get any errors like Use or Token or something that makes no sense, I close all Notes and Designer windows.
-
Delete cache.ndk from the client data directory. It seems Designer caches stuff here as well because this is the real magic to making it function.
-
Reload all Notes & Designer windows.
-
Rebuild all LotusScript.
-
Greater than nineteen times out of twenty this will fix it. That other 1 in 20 it’s a PEBKAC error that I missed. (wink)