It seems that the fonction dim work only the first time in a sub-routine:
A exemple:
object myform as form
Height=100
Width=100
object click as button
onclick=cluk
end object
end object
myform.ShowModal
sub cluk()
dim i as double
showmessage "i= "+str$(i)
if i< 1 then dim a as double
showmessage "a= "+str$(a)
i=1
end sub
If I click the first time I obtain:i=0 and a=0
the second time I expect i=0 but I obtain 1 and with the variable a I expect a bug because it`s not declared but I obtain a=0
I think that dim is ignored the second time.
declaration of variable ignored in a sub-routine
declaration of variable ignored in a sub-routine
Hi,
Not "dim is ignored the second time", but the variables in the subroutines (and functions) keeps the own values on all further callings, I wish so.
PaPi
Not "dim is ignored the second time", but the variables in the subroutines (and functions) keeps the own values on all further callings, I wish so.
PaPi
declaration of variable ignored in a sub-routine
See also the example in ProjectsExamplessort.bas, it has this comment:
``fnx basic does not keeps a stack for local varibles
``these are global for recursive calls
``fnx basic does not keeps a stack for local varibles
``these are global for recursive calls
declaration of variable ignored in a sub-routine
In my opinion your code wokr freely! You can make the little modification:
.
.
.
if i< 1 then
dim a as double
showmessage "i=0 ??? " + "i= "+str$(i)
end if
.
.
.
and you can see.
PaPi
.
.
.
if i< 1 then
dim a as double
showmessage "i=0 ??? " + "i= "+str$(i)
end if
.
.
.
and you can see.
PaPi