I haven't used quick basic before today, so I might be asking a very silly question here!
I wrote this code which is running fine in the QB 4.5 IDE and is doing what it is supposed to do.
When I tried to create the exe file it threw this error "expression too complex" in the line:
IF line1checksum% < 16 THEN line1checksum$ = "0" + line2checksum$
what is wrong?
Please help me!
"expression too complex" while creating exe - plea
Hello Nixon,
My code is pasted below. It is probably the most ugly qbasic code you have seen
All I am trying to do is to find check sum of two lines of data in the file 'data.hex' and add it to the end of the lines.
What you said is right, I tried commenting out the line which gave me the error and the same error started appearing at the function definition line!
Help anybody?!
My code is pasted below. It is probably the most ugly qbasic code you have seen
All I am trying to do is to find check sum of two lines of data in the file 'data.hex' and add it to the end of the lines.
What you said is right, I tried commenting out the line which gave me the error and the same error started appearing at the function definition line!
Help anybody?!
Code: Select all
DECLARE FUNCTION DecimalValue% (param%)
COMMON SHARED param%, dig1%, dig2%
'$INCLUDE: 'DECL.BAS'
OPEN "C:\data.hex" FOR BINARY AS #1
GET #1, 1702, line1val1%
GET #1, 1704, line1val2%
GET #1, 1706, line1val3%
GET #1, 1708, line1val4%
GET #1, 1710, line1val5%
GET #1, 1712, line1val6%
GET #1, 1714, line1val7%
GET #1, 1716, line1val8%
GET #1, 1718, line1val9%
GET #1, 1720, line1val10%
GET #1, 1722, line1val11%
GET #1, 1724, line1val12%
GET #1, 1726, line1val13%
GET #1, 1728, line1val14%
GET #1, 1730, line1val15%
GET #1, 1732, line1val16%
GET #1, 1734, line1val17%
GET #1, 1736, line1val18%
GET #1, 1738, line1val19%
GET #1, 1740, line1val20%
GET #1, 1747, line2val1%
GET #1, 1749, line2val2%
GET #1, 1751, line2val3%
GET #1, 1753, line2val4%
GET #1, 1755, line2val5%
GET #1, 1757, line2val6%
GET #1, 1759, line2val7%
GET #1, 1761, line2val8%
CLOSE #1
line1val1% = DecimalValue%(line1val1%)
line1val2% = DecimalValue%(line1val2%)
line1val3% = DecimalValue%(line1val3%)
line1val4% = DecimalValue%(line1val4%)
line1val5% = DecimalValue%(line1val5%)
line1val6% = DecimalValue%(line1val6%)
line1val7% = DecimalValue%(line1val7%)
line1val8% = DecimalValue%(line1val8%)
line1val9% = DecimalValue%(line1val9%)
line1val10% = DecimalValue%(line1val10%)
line1val11% = DecimalValue%(line1val11%)
line1val12% = DecimalValue%(line1val12%)
line1val13% = DecimalValue%(line1val13%)
line1val14% = DecimalValue%(line1val14%)
line1val15% = DecimalValue%(line1val15%)
line1val16% = DecimalValue%(line1val16%)
line1val17% = DecimalValue%(line1val17%)
line1val18% = DecimalValue%(line1val18%)
line1val19% = DecimalValue%(line1val19%)
line1val20% = DecimalValue%(line1val20%)
line1checksum% = line1val1% + line1val2% + line1val3% + line1val4% + line1val5% + line1val6% + line1val7% + line1val8% + line1val9% + line1val10% + line1val11% + line1val12% + line1val13% + line1val14% + line1val15% + line1val16% + line1val17% + _
line1val18% + line1val19% + line1val20%
line1checksum% = ((line1checksum% / 256) - INT(line1checksum% / 256)) * 256
line1checksum% = 255 - line1checksum% + 1
line1checksum$ = HEX$(line1checksum%)
IF line1checksum% < 16 THEN line1checksum$ = "0" + line2checksum$
line2val1% = DecimalValue%(line2val1%)
line2val2% = DecimalValue%(line2val2%)
line2val3% = DecimalValue%(line2val3%)
line2val4% = DecimalValue%(line2val4%)
line2val5% = DecimalValue%(line2val5%)
line2val6% = DecimalValue%(line2val6%)
line2val7% = DecimalValue%(line2val7%)
line2val8% = DecimalValue%(line2val8%)
line2checksum% = line2val1% + line2val2% + line2val3% + line2val4% + line2val5% + line2val6% + line2val7% + line2val8%
line2checksum% = ((line2checksum% / 256) - INT(line2checksum% / 256)) * 256
line2checksum% = 255 - line2checksum% + 1
line2checksum$ = HEX$(line2checksum%)
IF line2checksum% <16> 40 THEN
dig1 = dig1 - 31
ELSE dig1 = dig1 - 30
END IF
IF dig2 > 40 THEN
dig2 = dig2 - 31
ELSE dig2 = dig2 - 30
END IF
DecimalValue = dig1 * 16 + dig2
END FUNCTION
The problem is this line. I would suggest re-writing your code using arrays rather than having line1val1%, line1val2% and so on.
Code: Select all
line1checksum% = line1val1% + line1val2% + line1val3% + line1val4% + line1val5% + line1val6% + line1val7% + line1val8% + line1val9% + line1val10% + line1val11% + line1val12% + line1val13% + line1val14% + line1val15% + line1val16% + line1val17% + _
line1val18% + line1val19% + line1val20%