|
Post by bluatigro on Apr 22, 2018 2:30:54 GMT -5
the folowing don't works Always :
end function f( a , b ) on error goto [ferror]
f = some calculation
exit function print "error in f f = 0 end function
i want this fixed in LB% or earilyer
see geneteic programming post why i need this
|
|
|
Post by Stefan Pendl on Apr 22, 2018 2:35:45 GMT -5
Shouldn't this look more like the following?
end function f( a , b ) on error goto [ferror]
f = a * b ' some calculation exit function
[ferror] print "error in f" f = 0 end function
|
|
|
Post by bluatigro on Apr 22, 2018 3:05:07 GMT -5
LB does not report the funtion where the error hapens
so i don't know what code thows a exception
|
|
|
Post by Alyce Watson on Apr 22, 2018 3:51:53 GMT -5
You've posted a small snippet of code that cannot be run, but it appears you are defining an error trapping label inside a function, but the actual label exists outside the function. They are not in the same "scope". See this article, and section: Scope in Functions
You posted another bit of code yesterday that began with : '' bluatigro 22 apr 2018
'' genetic programming in just basic
'' proof of concept
This is not a Just BASIC forum. Post code intended for Just BASIC on the dedicated forum. The languages are similar, but not identical. It can also be confusing if a conversation is carried on over two or more forums. I do not participate in the JB forum, so I have not been following any discussions of your code at that location. Just BASIC Forum
|
|
|
Post by tsh73 on Apr 22, 2018 6:17:10 GMT -5
It looks like
does not caught with OnError: This works
on error goto [xxx] x=1/0 'Error caught print "Ok"
[xxx] print "Err" print err, Err
But this one erros
on error goto [xxx] x=val(1e310) 'Error does not caught print "Ok"
[xxx] print "Err" print err, Err
EDIT I was wrong
|
|
|
Post by bluatigro on Apr 22, 2018 6:55:45 GMT -5
i tryed to find the bug :
on error goto [error] ''print sqr( -1 ) ''print log( -1 ) ''print exp( 1000.1 ) ''print exp( -1000 ) ''print asn( 2 ) ''print acs( 2 ) ''print 10 mod 0 ''print -2 ^ .5 ''print 1 / 0 print "[ end error test ]" end [error] print "error" end
in all these it works giving the question : why does genetic programming sometime crash ?
i think i did not test al posible error's can anyone think of more error's ? add them and test them please
|
|
|
Post by bluatigro on Apr 22, 2018 7:28:34 GMT -5
update : hunting a bug 2
whit more error's + report what they do
global pi pi = atn( 1 ) * 4 on error goto [error] ''print sqr( -1 ) ''print log( -1 ) ''print exp( 1000.1 ) ''print exp( -1000 ) ''print asn( 2 ) ''print acs( 2 ) ''print tan( rad( 90 ) ) ''wil print something ''print tan( pi / 2 ) ''wil print something ''print 10 mod 0 ''print -2 ^ .5 ''print 10.1 ^ 400 ''print 10.1 ^ -400 ''print 1 / 0 ''print 12.1 and 10.1 ''wil print something ''print 12.5 or .25 ''wil print something ''print 12.1 xor 10.1 ''wil print something ''print not( 20.5 ) ''wil print something ''the remaining error's are al catched print "[ end error test ]" end [error] print "error" end function rad( deg ) rad = deg * pi / 180 end function
please help whit testing on error goto whit more posible error's
|
|
|
Post by tsh73 on Apr 22, 2018 7:53:48 GMT -5
You really should pinpoint error first. Run it in debug or light debug mode - program usually stops on offending line. Read my reply to your Genetic programming thread - error I found was too big a string fed into VAL() function, outside of ON ERROR protected block.
|
|
|
Post by bluatigro on Apr 22, 2018 8:00:15 GMT -5
i humbely apolegase : there was no 'bug'
i forget to check the outut of gprun$()
@alice : i did not jet join the JB forum
|
|
|
Post by Alyce Watson on Apr 22, 2018 10:50:56 GMT -5
Glad you found your error.
|
|