Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / DBC: Debug help - Syntax error & too many immediate strings error

Author
Message
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 26th May 2007 13:02
Hi, I cannot for the life of me work out what is wrong my code (about 2000 lines so too much to post here). The first error I get is this:

Syntax error, unrecognised parameter from this line....
If equip21$(j,2) = "Scanner" then range = range + int(val(equip21$(j,5))*Qty#)

If I remove this line I get the following error message

Compile Error: Too many immediate strings
if i = 1: Load Object "Ships/Eagle.x", ob: Scale ob, 169,169,169:endif

I know that the load object line definitely works in isolation and that the Equip21$(j,5) is numeric but cannot work out what the problem is.

Can anyone help me?

Thanks.
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th May 2007 16:00
You have listed
Quote: " Scale ob,169,169,169"
. This should be Scale object ob,169,169,169.
Also, the variable RANGE is an integer, yet you are using a float (Qty#) in determining it's value. I would make Qty# an integer.

I expect there is at least one more issue, but this is what I see.

LB
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 26th May 2007 16:09
I dont think you need the endif at the end of that line

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th May 2007 16:18
Quote: "Also, the variable RANGE is an integer, yet you are using a float (Qty#) in determining it's value"


That won't cause any compilation errors though. But, Hangar, since you're assigning the calculated value to an integer, there's no need to use int() as DB will auto-cast the float to int.


Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 26th May 2007 16:57
Thanks but no luck with your suggestions. Just wondering if there is some kind of limit as to how many string variables you can have in DBC. I use a lot (mostly arrays) but wonder if this is causing the problem. The reason I say this is because the Equip1-20$ are no problem - only when Equip gets to 21 that the error happens. And the code structure for Equip1-20$ is exactly the same as for Equip$21 as I programmed it in excel and copied and pasted to DB.

Any ideas?
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 27th May 2007 00:28
It seems its the problem is related to "too many immediate strings" - does anyone know what this means??
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th May 2007 03:50
Try changing this:



into



see what happens

TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th May 2007 03:51
Try replacing:



with:



You'll also have to search and replace all the occurences of Qty# with Qty as like LBFN says it should be an integer.

TDK_Man

TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th May 2007 03:54
Zo:

Strictly speaking, 'Ships/Eagle' is part of a URL and should really be 'Ships\Eagle'.

DB accepts either, so it's not that big of a problem!

TDK_Man

SFSW
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 27th May 2007 05:09
There is a string limit in DB. I'm not quite sure what it is exactly, but I've hit it many times (usually when my code for a project reaches about 30,000-50,000 lines). Your only option is to reduce the number of strings you have in your code, that includes anything in quotes, whether object filenames or variables. Here's what I do to keep the string count under control:

- Use an external text file to load any textual content you will have in your project. This also has the benefit of making language translations easier. Then load the text lines into an array (I use rem lines to keep track of what text is assigned to what array slot). I can provide some sample code for this routine, if desired, but it's pretty simple.

- If you load the same object in more than one location in your code, assign that object string to a variable and only use the variable every time you need the object (example: shipobject$="shipobject.x" ).

- Never use double quotes to null a string. If you do this frequently, create a 'nullc$' variable that uses the double quotes, then use the variable every time you need to null a string.

- Keep as much data as possible in external files, avoid assigning anything in quotes to variables that you can use 'read string 1,variable$' for.

Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 27th May 2007 09:19
Thanks all for your help - I suspect I have hit the string limit because I am using a lot of for and next commands to read in arrays. Blast! Oh well at least I now know where the problem lies. Thanks especially to SFSW (is that you vice?) - this has saved me meticulously going through a few thousand lines of code only to discover there is no syntax problem. I will try the reading in of external files to combat the problem.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th May 2007 19:37
Quote: "I will try the reading in of external files to combat the problem."


Unless I've missed the point, that probably won't solve the problem.

If the string limit is being reached, then loading the same amount of data into strings from disk should still result in the same problem.

I've not experienced this myself, so I'm only guessing on this...

TDK_Man

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th May 2007 13:14
Quote: "Unless I've missed the point, that probably won't solve the problem."


Unless I'm mistaken, I read the problem as too many literal strings - anything that appears between quotes within the code. Loading the string directly from a file into the variables/arrays eliminates their quoted presence in the source. At least, that's how I interpret the error message and SFSW's reply.

Enjoy your day.
SFSW
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 28th May 2007 23:37 Edited at: 28th May 2007 23:42
That is correct, you just need to reduce the number of quoted values (anything in quotes). If you put values directly into strings from a text file, then you've eliminated every instance of assigning those values internally with quotes. It isn't a matter of reducing string variables, but instead you need to reduce the number of string values in quotes. Sorry, I probably wasn't clear enough on that.

'For i' loops won't effect how many string slots you use. It is a raw numerical count of how many instances of '""' are in your code. Reduce that total count and you bring down the number of strings in quotes. The more you do this, the more room you leave for using quoted string values later on when you may really need to use them.

Oh, and yes, I'm Vice

Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 29th May 2007 00:36
What?! Why the hell does that happen? That's stupid! Ach well, just gotta live with it.

Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 19th Jun 2007 06:09
Just back from my overseas holiday to the UK (which I used to fix the string problem). I can definitely confirm the problem I was experiencing was due to the number of times that quotes ("") appear in the code. I've redone my variables by reading in from .txt files (which was a real pain in the posterior maximus it must be said) but all is good again. Thanks!
tha_rami
20
Years of Service
User Offline
Joined: 25th Mar 2006
Location: Netherlands
Posted: 20th Jun 2007 03:22
Cool to see ya around here, Vice.

I think SFSW is correct on this one , no actually, I'm certain. I know he ran into the same problem and that that's how he fixed it.

Personally, I started Awakening exactly that way, trying to load variables from external files - just to avoid that problem.

Login to post a reply

Server time is: 2026-07-12 17:59:05
Your offset time is: 2026-07-12 17:59:05