Author |
Topic: Wut da heck? :-/ (Read 1502 times) |
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: Wut da heck? :-/
« Reply #8 on: May 2nd, 2015, 6:56pm » |
|
Richard, somehow code from reply #5 crashes LBB with Internal error 26 (after Message box telling "Internal error 26" it just closes. I tried run, debug and even create EXE - same error). Any ideas?
Currently I'm on Win XP home SP3 with 4Gb ram. EDIT LBB 3.00
Daniel, no offence, but line "I originally use functions, but they weren't working properly so I changed to subs" really tells you are not know what are you doing. That's actually OK - and normal learning process - if you are realising this.
I could recommend you 2 things. 1) Teddy bear programming. Google around  It was conveyed to me in this form: "Put a teddy bear on your desk. Then stuck, try to explain your programming problem to a bear. Then it starts arguing, go for a walk". (well, talking to actual living person looks less awkward) 2) Then you have obscure error, try to run your program through Liberty BASIC. Who knows, it might complain differently - and it could help you.
|
| « Last Edit: May 2nd, 2015, 7:17pm by tsh73 » |
Logged
|
|
|
|
datwill
Guest
|
 |
Re: Wut da heck? :-/
« Reply #9 on: May 2nd, 2015, 8:18pm » |
|
Well, I called and defined the function correctly as far as I was aware. Is it true that you cannot call a function by simply typing: functionName() assuming that this function was already defined? I tried to (the one I was using required an argument), but it didn't work, and when I *nearly * switched to subs it worked. Idk whether I did something wrong or you can't call a function by itself ...
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Wut da heck? :-/
« Reply #10 on: May 2nd, 2015, 8:43pm » |
|
on May 2nd, 2015, 6:56pm, tsh73 wrote:| somehow code from reply #5 crashes LBB with Internal error 26 |
|
That's what Daniel was asking about (Error 26 = 'No such variable'). I explained the cause in my reply to him: trying to end a SUB with END FUNCTION, which confuses LBB:
Code:sub applyIcon windowHandle
.........
end function Or have I misunderstood your question?
Richard.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: Wut da heck? :-/
« Reply #11 on: May 2nd, 2015, 8:49pm » |
|
Richard, it never said to me "No such variable" It just shows messagebox with title "Error" and text "Internal error 26" and quits. I just don't like then program quits - how I'll debug it?
Yes I understand sub/function issue. Question is, does LBB supposed to quit in this case?
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Wut da heck? :-/
« Reply #12 on: May 2nd, 2015, 8:50pm » |
|
on May 2nd, 2015, 8:18pm, Daniel Atwill wrote:| Is it true that you cannot call a function by simply typing: functionName() |
|
A function returns a value. If you don't want the returned value, then (for example) assign it to a dummy variable:
Code: But if you are throwing away the returned value, why are you using a function?
Richard.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: Wut da heck? :-/
« Reply #13 on: May 2nd, 2015, 8:52pm » |
|
Daniel, Quote:Well, I called and defined the function correctly as far as I was aware. Is it true that you cannot call a function by simply typing: functionName() assuming that this function was already defined? I tried to (the one I was using required an argument), but it didn't work, and when I *nearly * switched to subs it worked. Idk whether I did something wrong or you can't call a function by itself |
|
Yes you can't call function by itself. But again, "function" supposed to return a value. If you need a value, you will never call it by itself - you either store return value or use it (in expression etc) If you need piece of code that *doesn't* have return value, then you naturally use sub.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Wut da heck? :-/
« Reply #14 on: May 2nd, 2015, 9:22pm » |
|
on May 2nd, 2015, 8:49pm, tsh73 wrote:| Question is, does LBB supposed to quit in this case? |
|
What do you mean by "supposed to"?
If you mean "was it a deliberate design decision to quit?" then obviously not. LBB should never report an 'Internal error'; it means something has gone wrong internally and, if it quits unexpectedly, unsaved changes to the program may be lost.
But if you mean "is that what you would expect to happen?" then yes it is. The code of LBB is written in such a way that an END FUNCTION without a FUNCTION will fail with an 'Internal error 26'. There is nothing mysterious about it.
When writing LBB I concentrated on making an error-free BASIC program compile to an error-free executable, as I hope you would expect. Checking that the compiler behaves in a 'helpful' way when there is an error in the BASIC program is much more difficult!
A valid BASIC program is defined by the Syntax and Semantics of the language, and therefore in principle it is possible to test that every aspect of the compiler works correctly (not that I am claiming LBB does). However there is no 'specification' of an invalid BASIC program: the number of possible errors is close to infinite so it is not practical to test what happens in every case.
I have a large suite of test programs which I use to validate each release of LBB. But I don't have a suite of broken programs to test how LBB behaves with them!
Richard.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Wut da heck? :-/
« Reply #15 on: May 3rd, 2015, 09:54am » |
|
on May 2nd, 2015, 8:49pm, tsh73 wrote:| Richard, it never said to me "No such variable" |
|
Although knowing what the 'Internal error' codes mean is helpful to me, in general it won't be useful to the LBB user (knowing that the error was 'No such variable' didn't help Daniel locate the bug in his program, in fact it led him astray). It's a bit like LB's error log, which is helpful to Carl but incomprehensible to most users!
However, for those who like to be inquisitive, the LBB error codes are documented and that's presumably how Daniel knew what 'Internal error 26' actually means:
http://www.bbcbasic.co.uk/bbcwin/manual/bbcwinc.html#trapprog
Richard.
|
|
Logged
|
|
|
|
datwill
Guest
|
 |
Re: Wut da heck? :-/
« Reply #16 on: May 3rd, 2015, 3:29pm » |
|
Thank you about the function thing (of course it's meant to return a value - silly me), and yes I should've used a sub and I have.
Oh yeah, you know about the public offer of anyone willing to become an administrator (I can' remember where I've read that - i think it was in the thread on being banned from the LBCF)? Am I aloud to be one ? If I can, thanks a lot!
|
| « Last Edit: May 3rd, 2015, 3:37pm by datwill » |
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: Wut da heck? :-/
« Reply #17 on: May 5th, 2015, 07:13am » |
|
Quote:| However, for those who like to be inquisitive, the LBB error codes are documented and that's presumably how Daniel knew what 'Internal error 26' actually means: |
|
Thank you, Richard.
|
|
Logged
|
|
|
|
datwill
Guest
|
 |
Re: Wut da heck? :-/
« Reply #18 on: May 5th, 2015, 10:47am » |
|
I didn't it literally told me "no such variable"
|
|
Logged
|
|
|
|
|