TOPIC: error: 'too many literals'
error: 'too many literals' 2 Months, 3 Weeks ago
When I run my function 'EnsureDatabase' I get a runtime error: 'too many literals'.

Does this actually mean I have too many literals in a function? I have not counted them but I see no syntax error. It's in a function that creates supporting data, so there are a lot of QueryOutput() calls.

I guess the solution is to break it into many sub-functions?

Re:error: 'too many literals' 2 Months, 3 Weeks ago
There is a limit of 255 literals (e.g. quoted strings) in a function or method. This is because the byte code uses a single byte to reference a literal.

There are usually fairly easy work arounds. One is to put all the data in an object constant. The object constant will only count as one literal no matter how many values are inside it. For example, to output a bunch of records, put a list in an object constant and then loop through it outputting each one.


data = #(
     { ... }
     { ... }
for x in data
     QueryOutput("mytable", x)

If this is in a class you can make the data a member to keep your method short.