|
Post by rosy on Jan 7, 2021 16:39:08 GMT -6
The startup error sometimes occurs during startup. This happened after adding the KOMPUTER subroutine. Attachments:HOLKA.BAS (4.86 KB)
|
|
|
Post by n00b on Jan 8, 2021 13:28:07 GMT -6
You are causing a memory leak in your code in atleast 1 part of your program. You have dim kolor[7] which will give you an array with 7 values in it, numbered kolor[0] to kolor[6]. But you write to kolor[7] which is trying to write to memory that isn't reserved. That memory could be getting reserved by an event call, the renderer, or literally anything else. You may have other errors like this in your code to but I did not check. It only takes a single byte written to the wrong location to crash your program.
|
|
|
Post by Tomaaz on Jan 8, 2021 13:51:02 GMT -6
Wait a second. Things like that will simply crash the program without a warning or error message? In BASIC???
|
|
|
Post by n00b on Jan 8, 2021 14:11:44 GMT -6
Wait a second. Things like that will simply crash the program without a warning or error message? In BASIC??? RCBasic does not have exceptions for Arrays out of bounds. I wanted code to be able to execute as fast as possible so I avoided adding IF statements for error checks like that in the runtime machine. So basically, if you wouldn't do it in C++ you shouldn't do it in RC either.
|
|
|
Post by Tomaaz on Jan 8, 2021 14:46:32 GMT -6
Well, the problem is that potential RCBasic users don't have to know what you should or shouldn't do in C++. They now what you should or shouldn't do in BASIC and if something like that happens in BASIC, you get an error message. I respect your choice, but, in my opinion, this is not BASIC-like design. Trying to access out of bound array elements is a very common mistake and if it simply crashes the program in an unpredictible way and without any warning then I can't see how RCBasic can be a good option to beginners or even experienced BASIC programmers.
|
|
|
Post by rosy on Jan 8, 2021 14:57:49 GMT -6
And ... I forgot ... How would the code analyzer do before running it would not affect the speed ... In total, it was strange that it crashed at the next DIM command ...
|
|
|
Post by n00b on Jan 9, 2021 12:24:03 GMT -6
Well, the problem is that potential RCBasic users don't have to know what you should or shouldn't do in C++. They now what you should or shouldn't do in BASIC and if something like that happens in BASIC, you get an error message. I respect your choice, but, in my opinion, this is not BASIC-like design. Trying to access out of bound array elements is a very common mistake and if it simply crashes the program in an unpredictible way and without any warning then I can't see how RCBasic can be a good option to beginners or even experienced BASIC programmers. I actually started working on a debugger a while back but I never got that far because I was more interested in porting to other platforms at the time. I might see if I can get the debugger into the next release but even that is not going to be the same as the tracebacks and exception handlers in languages like java and python. And ... I forgot ... How would the code analyzer do before running it would not affect the speed ... In total, it was strange that it crashed at the next DIM command ... The behavior of memory leaks is unpredictable. It actually may not have been the only issue in your code but I fixed that one issue and it ran for me 20 times after that without crashing so I just assumed that fixed it.
|
|
|
Post by aurel on Jan 13, 2021 10:40:32 GMT -6
nOOb hmm.... i don't know why you think that must be checked at runtime . in my micro(A) i made all posible error checking before runtime..and of course i am 100% sure that i made mistake somewhere or forget to check similar things . But because my interpreter is minimal and as such limited i will limit array size ,for start up to 4096 elements. Yes i know it not looks good. On the other side i understand that in C array space must be allocated but because i use o2 he have different way to do that. Well good to know when i decide to add arrays to check it first in step 2-> preprocessor. ps.. .tomaaz will KILL ME because of memory leak
|
|
|
Post by n00b on Jan 14, 2021 3:30:37 GMT -6
nOOb hmm.... i don't know why you think that must be checked at runtime . in my micro(A) i made all posible error checking before runtime..and of course i am 100% sure that i made mistake somewhere or forget to check similar things . But because my interpreter is minimal and as such limited i will limit array size ,for start up to 4096 elements. Yes i know it not looks good. On the other side i understand that in C array space must be allocated but because i use o2 he have different way to do that. Well good to know when i decide to add arrays to check it first in step 2-> preprocessor. ps.. .tomaaz will KILL ME because of memory leak I couldn't do this error check at compile time because the expression in the array index is evaluated at runtime. For example, this code is a memory leak but I could not determine this at compile time because the code is not executed until it is run. Dim x[5] i = Rand(20) x[i^2]=22
|
|