Page 1 of 1

Expression too Complex, Severe Error

Posted: Thu Dec 04, 2008 1:17 am
by abidingjungle
I tried to compile a .bas file into a .exe file, and I got the following error:

=====================================
=====================================
Microsoft (R) QuickBASIC Compiler Version 4.50
(C) Copyright Microsoft Corporation 1982-1988.
All rights reserved.
Simultaneously published in the U.S. and Canada.
0C7F 0146 585 LOCATE 17, 5: PRINT X$
^ Expression too complex
1B9B 01AE 1250 LOCATE 16: PRINT FIRST - 1
^ Expression too complex
1C84 01B6 1275 LOCATE 17: PRINT LAST - 1
^ Expression too complex

42909 Bytes Available
28817 Bytes Free

0 Warning Error(s)
3 Severe Error(s)

Press any key to continue
=====================================
=====================================

I found a microsoft site saying that it is the problem with the qb4.5 compiler. And I should break up the code. Can someone help me to break up the three lines of code with error?

Thanks!

Posted: Thu Dec 04, 2008 1:38 pm
by pebe
Can you show the routine(s) that include those lines of code so we can see the errors in context.

more details

Posted: Thu Dec 04, 2008 10:08 pm
by abidingjungle
thanks for the reply!

The original software was written in 1987.

If the following code is not enough, can you please give me an idea of how much more is needed to get help? e.g. what variables or lines of code that you need.


This is commercial software, so I try to put only what's needed here.
I mainly program in Java, and am new to BASIC.

The errors are at lines 585, 1250, and 1275:


==========================================
DECLARE SUB FIXDIR (X$, Y$, Z$)
...

575 GET #1, REC
580 X$ = X$(1) + " " + X$(2) + " " + X$(3) + " " + X$(4) + " " + X$(5) + " " + X$(6) + " " + X$(7) + " " + X$(8)
585 LOCATE 17, 5: PRINT X$
590 RETURN

...

1235 GET #1, FIRST
1240 X1$ = X$(1) + X$(2) + X$(3) + X$(4) + X$(5) + X$(6) + X$(7) + X$(8) + X$(9) + X$(10)
1245 FX$ = X$(1) + " " + X$(2) + " " + X$(3) + " " + X$(4) + " " + X$(5) + " " + X$(6) + " " + X$(7) + " " + X$(8)
1250 LOCATE 16: PRINT FIRST - 1
1255 LOCATE 16, 8: PRINT FX$
1260 GET #1, LAST
1265 X2$ = X$(1) + X$(2) + X$(3) + X$(4) + X$(5) + X$(6) + X$(7) + X$(8) + X$(9) + X$(10)
1270 LX$ = X$(1) + " " + X$(2) + " " + X$(3) + " " + X$(4) + " " + X$(5) + " " + X$(6) + " " + X$(7) + " " + X$(8)
1275 LOCATE 17: PRINT LAST - 1
1280 LOCATE 17, 8: PRINT LX$

...

==========================================

thank you!

Posted: Fri Dec 05, 2008 11:53 am
by pebe
When compiling QuickBasic programs there are sometimes cases that the compiler does not like. These include some calculations on double precision variables, and long strings. For example, 'FIRST' is not defined so the program will assume it is d.p. variable that takes up 8bytes. If the number is only an integer, it may help if you either define it as INT or call it FIRST%. Then it only takes up 2bytes.

Does the program run OK as an interpreted .BAS file in the QB environment?

If so, are you:
1. Compiling from within the QB environment, or from the DOS prompt?
2. Compiling as a standalone .exe file, or one using Brun?

EDIT:
Just spotted an error in lines 1250 and 1275. The LOCATE statement should have two numbers separated by a comma as in line 1280. These relate to row and line numbers. It runs OK in Basic as written, but may be a problem as an .exe depending on how it is compiled.

Posted: Sat Dec 06, 2008 9:48 am
by Valerie
Here's MS on the Expression too Complex error when using BC.Exe

http://support.microsoft.com/kb/39239

While your code may fall below the magic number 19 it's worth a try.

I understand that the caret (^) indicates that the error is in the line prior to the one referenced so that
1B9B 01AE 1250 LOCATE 16: PRINT FIRST - 1
^ Expression too complex
would indicate an error in line 1245 in your code.

You may also want to compile from the command line, command line options are here:
http://support.microsoft.com/kb/43090

Good luck

V.

Posted: Wed Aug 12, 2009 7:32 am
by BurgerBytes
IF you only use the row in LOCATE, you will LOSE every time!

You can just use the column number without the row if you just want to move the print to the next row:

LOCATE 10, 4: PRINT "Starting row"
LOCATE , 4: PRINT "Next row"

THE LOCATE COLUMN IS REQUIRED except when you want a cursor for INKEY$ or INPUT$!

Why compile something that does not even work in the IDE?