Oxygen Basic
Programming => Example Code => Topic started by: Peter on October 15, 2010, 11:32:21 AM
-
Deleted
-
Hi Peter,
The problem seems to be comparing an array variable with another value. There are two workarounds:
A: pass the array value to a simple variable and use that in the comparators.
B: swap the terms so the numeric const is on the left and the array on the right in the comparator expression.
A: elseiF (Key(39)) and ( m1 =177)
B: elseiF (Key(39)) and ( 177=map1(i))
Meanwhile I will find out why this is not working as it should.
Thanks
Charles
PS: I put your code between [ code] .. [ /code] . Hope that is ok.
-
Hi Peter,
Sorry you are having a rough ride with these conditionals.
This problem should be fixed in Alpha016. I found your example returned both conditions true as expected.
I have just posted Alpha017, which I have been using to write GUI/Opengl stuff until a few moments ago.
However I found one further bug in this area which occurs when a conditional is used nested within a case block:
Nested inside a case block this would not work:
iF (map(3) <15) or (map(4) <15) ...
but this will:
iF (map(3) <15) or (map(4) <15)<>0 ...
I don't know whether this applies to your game program?
Charles
-
Yes thank you Peter.
A good practical way to test random number algorithms might be to use them to create textures. The human eye is very sensitive to visual patterns.
I hope to improve the bracket situation soon. I need to adjust precedence rules so that comparators come in between logicals and arithmeticals in priority.
Charles
-
Hi Peter,
I tried your example lines and both ran without crashing.
One possibility is exceeding array boundaries. The default index base in Oxygen is 1. If you normally work from 0 then you can use the directive indexbase 0
I'm working on Alpha018 at the moment Hi Peter,
I tried your example lines and both ran without crashing.
One possibility is exceeding array boundaries. The default index base in Oxygen is 1. If you normally work from 0 then you can use the directive indexbase 0
I'm working on Alpha018 at the moment Hi Peter,
I tried your example lines and both ran without crashing.
One possibility is exceeding array boundaries. The default index base in Oxygen is 1. If you normally work from 0 then you can use the directive indexbase 0
I'm working on Alpha018 at the moment (ready soon!) which has new precedence rules for comparator expressions that don't use brackets. But this should not affect the expressions you use here.
See if this works for you.which has new precedence rules for comparator expressions that don't use brackets. But this should not affect the expressions you use here.
See if this works for you.which has new precedence rules for comparator expressions that don't use brackets. But this should not affect the expressions you use here.
See if this works for you.
dim map2(200),map5(200) as long
dim a,ibx,keyreg as long
function upkey() as sys
return 42
end function
ibx=50
for a=1 to 200
map5(a) = 12
next
'crash ??
if a=0 then
ElseiF ((Map5(iBx)=101) And (Map5(iBx-20)>0)) Or ((Map5(iBx)=86) And (Map5(iBx+20)>0))
else
print "no"
end if
'works !!
if a=0 then
ElseiF (UpKey()) and (Map2(iBx-20) =176) and (KeyReg >0)
else
print "no"
end if
print "ok"
Charles
-
Seems Charles has forgotten to turn off the double buffering before posting his last message or is doing another 36 hour programming marathon. :D
-
Hi Peter,
Clunk!
My eyesight is not particularly good and cannot cope with that format of code - not 300 lines of it anyway.
I will have to write a code layout utility :)
Charles
-
PS: I put your code between [ code] .. [ /code] . Hope that is ok.
@Peter: I second the use of code tags when posting here. You lose your formatting and makes your code difficult to read.
-
Charles,
Don't waste your time on that HORRID code. Peter needs to learn about formatting his code.
Lines like EndIf : EndIf or Next : Next buried in the complex if structure here is ........!!!!!!
James
-
Too late James!
I wrote an Indenting tool to format Peter's code.
There were a number of end if : end if lines which I also straightened out but I think the main problem was the ghostparam() function was placed beyond the main function. So I put in the directive for forward referencing #lookahead.
See if this works Peter
Charles
#basic
#lookahead
dim as sys map2(200),map3(200),map4(200),map5(200),xgos(100),ygos(100),rgos(200)
dim as sys idx,icx,ibx,rasreg
function rand(sys a) as sys
end function
function ghost()
if rasreg >0 then exit function 'you needn't brackets if a single "if" is giving!
for icx =1 to 13
for idx =1 to 18
ibx = icx *20 + idx
if ((map5(ibx)=103) or (map5(ibx)=102)) and ((map5(ibx-20)=84) or (map5(ibx+20)=84))
if map5(ibx-20)=84
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif map5(ibx+20)=84
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
end if
elseif ((map5(ibx)=86) or (map5(ibx)=101)) and ((map5(ibx-1)=84) or (map5(ibx+1)=84))
if map5(ibx-1)=84
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif map5(ibx+1)=84
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
end if
elseif (map5(ibx)=103) and (map5(ibx+1) =84)
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
elseif (map5(ibx)=102) and (map5(ibx-1) =84)
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif (map5(ibx)=101) and (map5(ibx-20) =84)
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif (map5(ibx)=86) and (map5(ibx+20) =84)
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
'---------
elseif ((map5(ibx)=103) and (map5(ibx+1)>0)) or ((map5(ibx)=102) and (map5(ibx-1)>0)) '<--- here
iax = rand(2)
if iax =1
if map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif map5(ibx+20) =0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
elseif (map5(ibx)=103) and (map5(ibx-1)=0)
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif (map5(ibx)=102) and (map5(ibx+1)=0)
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
else
ghostparam(5)
end if
elseif iax =2
if map5(ibx+20) =0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
elseif map5(ibx-20) =0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif (map5(ibx)=103) and (map5(ibx-1)=0)
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif (map5(ibx)=102) and (map5(ibx+1)=0)
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
else
ghostparam(5)
end if
end if
elseif ((map5(ibx)=101) and (map5(ibx-20)>0)) or ((map5(ibx)=86) and (map5(ibx+20)>0)) '<--- here
iax = rand(2)
if iax =1
if map5(ibx-1) =0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif map5(ibx+1) =0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
elseif (map5(ibx)=101) and (map5(ibx+20)=0)
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
elseif (map5(ibx)=86) and (map5(ibx-20)=0)
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
else
ghostparam(5)
end if
elseif iax =2
if map5(ibx+1) =0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
elseif map5(ibx-1) =0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif (map5(ibx)=101) and (map5(ibx+20)=0)
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
elseif (map5(ibx)=86) and (map5(ibx-20)=0)
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
else
ghostparam(5)
end if
end if
'----------
elseif (map5(ibx)=103) and (map3(ibx)=167)
iax = rand(3)
if iax =1
if map5(ibx+1)=0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
elseif map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif map5(ibx+20)=0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
else
ghostparam(5)
end if
elseif iax =2
if map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif map5(ibx+1)=0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
elseif map5(ibx+20)=0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
else
ghostparam(5)
end if
elseif iax =3
if map5(ibx+20)=0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
elseif map5(ibx+1)=0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
elseif map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
else
ghostparam(5)
end if
end if
'-------
elseif (map5(ibx)=102) and (map3(ibx)=167)
iax = rand(3)
if iax =1
if map5(ibx-1)=0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif map5(ibx+20)=0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
else
ghostparam(5)
end if
elseif iax =2
if map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif map5(ibx-1)=0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif map5(ibx+20)=0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
else
ghostparam(5)
end if
elseif iax =3
if map5(ibx+20)=0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
elseif map5(ibx-1)=0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
else
ghostparam(5)
end if
end if
'-------
elseif (map5(ibx)=101) and (map3(ibx)=167)
iax = rand(3)
if iax =1
if map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif map5(ibx-1)=0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif map5(ibx+1)=0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
else
ghostparam(5)
end if
elseif iax =2
if map5(ibx-1)=0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif map5(ibx+1)=0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
else
ghostparam(5)
end if
elseif iax =3
if map5(ibx+1)=0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
elseif map5(ibx-20)=0
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif map5(ibx-1)=0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
else
ghostparam(5)
end if
end if
'-------
elseif (map5(ibx)=86) and (map3(ibx)=167)
iax = rand(3)
if iax =1
if map5(ibx+20)=0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
elseif map5(ibx-1)=0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif map5(ibx+1)=0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
else
ghostparam(5)
end if
elseif iax =2
if map5(ibx-1)=0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif map5(ibx+20)=0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
elseif map5(ibx+1)=0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
else
ghostparam(5)
end if
elseif iax =3
if map5(ibx+1)=0
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
elseif map5(ibx+20)=0
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
elseif map5(ibx-1)=0
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
else
ghostparam(5)
end if
end if
'----------
elseif (map5(ibx)=103) and (map5(ibx+1)=0)
map5(ibx) =0 : map5(ibx+1) =10
ghostparam(1)
elseif (map5(ibx)=102) and (map5(ibx-1)=0)
map5(ibx) =0 : map5(ibx-1) =10
ghostparam(2)
elseif (map5(ibx)=101) and (map5(ibx-20)=0)
map5(ibx) =0 : map5(ibx-20) =10
ghostparam(3)
elseif (map5(ibx)=86) and (map5(ibx+20)=0)
map5(ibx) =0 : map5(ibx+20) =10
ghostparam(4)
end if
next
next
end function
'---------------------------------------------------------------------
function ghostparam(rd as long)
xgos(ibx) = idx *32
ygos(ibx) = icx *32
rgos(ibx) = rd
end function
print "ok"