LB Booster
« "Number Too Big" error »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:08am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: "Number Too Big" error  (Read 716 times)
Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx "Number Too Big" error
« Thread started on: Apr 13th, 2015, 1:45pm »

Very rarely I get this error message flag up from a line that is totally innocuous:

175900 temp1=grid(j1)

grid is simply created by Dim grid(52)
j1 is simply created by the line

175600 j1=int(rnd(1)*weeks)+1

that comes just before.

weeks simply equals 28

I have not got a clue on this one.
« Last Edit: Apr 13th, 2015, 1:46pm by Monkfish » User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: "Number Too Big" error
« Reply #1 on: Apr 13th, 2015, 1:59pm »

It happens so rarely that it is difficult to trap. I know I have the right line because I forced an error on that line by trying to write to array element 100, which is out of bounds. That brought up a different massage but from the same line.

Is there an error log for LBB I could read.

So far it has only come up in the compiled executable version of the program not when I run from the LBB editor. I haven't been able to reproduce the error in debug mode either.

Strangely this step is in my inner loop which has executed hundreds of millions of times without error.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: "Number Too Big" error
« Reply #2 on: Apr 13th, 2015, 3:23pm »

on Apr 13th, 2015, 1:45pm, Monkfish wrote:
Very rarely I get this error message flag up from a line that is totally innocuous:
175900 temp1=grid(j1)

Some questions:

1. Can you confirm you are using LBB v3.00 rather than an earlier version?

2. What is the 175900 here? Is it a line number, a numeric label or what?

3. The 'Number too big' error should say 'at line' something. What line number does it report (I'm guessing it is zero, otherwise you would have said)?

4. When you forced an error by writing to array index 100, what was the exact code you used? I am unclear how you used that to find the line.

5. Are there things happening 'in the background', such as TIMER events, GUI events or CALLBACKs, when the error occurs?

Richard.
User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: "Number Too Big" error
« Reply #3 on: Apr 13th, 2015, 8:11pm »

No, I am using LBB version 2.82

Yes 175600 is the line number. Old habits die hard.

Yes, the error message said at Line 823, which is this particular line number. To check I changed the line to temp1=grid(100), which forced a bad subscript error at line 823. It's the only way I could think of to confirm I had the right line.

I do use the timer instruction in the program, but it should be set to zero while this code is executed. It should be, unless there is something about the timer I don't understand... which is always possible. Here is the timer code:

timer 100, [cont]
[back]
i$=input$(1): if asc(i$)<>13 then goto [back]
timer 0: goto [Enter_Pressed]
[cont]
timer 0: goto [Continue]

It essentially checks the entire keyboard buffer to see if the Return key has been pressed while the program was off doing other stuff (I stripped out the embarrassing line numbers and replaced them with labels instead). As you can see, the code shouldn't be able to escape without disabling the timer.

Thanks Richard smiley
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: "Number Too Big" error
« Reply #4 on: Apr 13th, 2015, 9:32pm »

wait - does LBB has non-blocking INPUT$(1)?
does it documented somewhere?
Code:
timer 100, [back]
[back]
print time$("ms")
scan
i$=input$(1): if asc(i$)<>13 then goto [back]
timer 0
print "Enter pressed"
end
 

*falls off chair*
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: "Number Too Big" error
« Reply #5 on: Apr 13th, 2015, 9:54pm »

on Apr 13th, 2015, 8:11pm, Monkfish wrote:
No, I am using LBB version 2.82

So please upgrade. I can only provide support for v3.00.

Quote:
Yes 175600 is the line number. Old habits die hard.

So are you using GOTOs or GOSUBs to line numbers? Although that works in LBB it's not a feature that is extensively tested because it's rarely used (and it's slow compared with using labels).

Quote:
It's the only way I could think of to confirm I had the right line.

If it said 'at line 823' that's the actual line in your source program where the error happened, so you need only page down and move the cursor (caret) until that number is displayed in the status bar. In v3.00 it's even easier: bring up the Goto Line dialog (e.g. Ctrl+G) and type in 823.

Quote:
Here is the timer code:
Code:
timer 100, [cont]
[back]
i$=input$(1): if asc(i$)<>13 then goto [back]
timer 0: goto [Enter_Pressed] 

It's a bit unusual but I can't see any obvious reason why it wouldn't work.

Edit: Anatoly has rightly identified a potential problem with this code, so it ought to be changed to use INPUT rather than INPUT$(1).

Richard.
« Last Edit: Apr 13th, 2015, 10:49pm by Richard Russell » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: "Number Too Big" error
« Reply #6 on: Apr 13th, 2015, 10:46pm »

on Apr 13th, 2015, 9:32pm, tsh73 wrote:
wait - does LBB has non-blocking INPUT$(1)?

It works the same as the regular INPUT statement: it blocks but internally does a SCAN so can be interrupted by a TIMER or GUI event.

However in the case of INPUT$(1) that feature is really only intended to be used with a SUB handler. Using a label as the TIMER handler is risky because it may cause a jump out of the expression evaluator.

Maybe that is indeed the cause of the OP's problem. As he is trying to detect the Enter key being pressed a regular INPUT should work just as well, and is safer:

Code:
timer 100, [cont]
[back]
input i$
timer 0: goto [Enter_Pressed]
[cont]
timer 0: goto [Continue] 

Richard.
User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: "Number Too Big" error
« Reply #7 on: Apr 14th, 2015, 9:51pm »

Thanks for all your help guys. I am now using V3.00 and have done what you suggested. I haven't seen the error again, so cross fingers smiley

Richard, when you said that line numbers are slower what did you mean exactly? I thought line numbers were viewed by the compiler like labels... just that every line has a label. Will it actually make my program slower?
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: "Number Too Big" error
« Reply #8 on: Apr 14th, 2015, 10:45pm »

on Apr 14th, 2015, 9:51pm, Monkfish wrote:
I thought line numbers were viewed by the compiler like labels... just that every line has a label. Will it actually make my program slower?

It can, yes (in LBB; I can't speak for LB). It all depends on where the line you are jumping to is. If it's near the beginning of the program then using a line number may be no slower than a label (it may even be faster) but the further into the program the destination is, the slower using a line number will become. With a label the location of the destination makes little difference to the speed.

Richard.
User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: "Number Too Big" error
« Reply #9 on: Apr 15th, 2015, 07:58am »

Oh, thanks Richard, I didn't know that. Clearly I need to go to programming Boot Camp! wink
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls