Oxygen Basic
Programming => Problems & Solutions => Topic started by: Peter on July 21, 2011, 12:57:32 PM
-
Hi Charles,
what means this accurately:
eighteen excess brackets?
[attachment deleted by admin]
-
That a lot!
It is often a symptom of Unclosed conditions or procedures.
Charles
-
Hi Charles,
After two days searching I got the following result:
'OxyGenBasic version o36 Forbidden secrets', must go to hell. >:(
There are two hazardous Bugs. I have got eighteen 'Exit Sub' and got eighteen 'excess left brackets in source ((..)'
'Exit Function' is also a handy cap!
Your explanation for that? I need quickly a better version.
[attachment deleted by admin]
[attachment deleted by admin]
-
Hi Peter,
I have not seen any problems with these symptoms for a very long time. If you can show me your code I should be able to trace the bug and find a better way to trap it in future releases.
Charles
-
Hi Charles,
is not executable here!
Sub MainMenu()
While EscKey() =0
glClearColor 0.0, 0.0, 0.0, 0.0
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
DrawTexture Bild,0,0,800,600
DrawText Font,"MINI BOULDER",208,16,32,32
DrawText Font, a,64,32,12,8
DrawText Font,"LEVELS " + zLev,336,224,16,16
DrawText Font,"PLAYER " + xName,336,240,16,16
DrawText Font,"HSCORE ",336,256,16,16
DrawText Font,"GOHOME ",336,272,16,16
DrawText Font,"SECRET ",336,288,16,16
DrawText Font,"OXYGENBASIC GAME",272,528,16,64
DrawTexture Quad,xCur,yCur,96,16
iF Key(vk_down) <0 and yCur <288 and CurD=0
yCur +=16: CurD=1
PlaySound s30
ElseiF Key(vk_up) <0 and yCur >224 and CurU=0
yCur -=16: CurU=1
PlaySound s30
ElseiF Key(vk_right) <0 and zlev <50 and yCur=224 and CurR=0
zlev +=1: CurR=1
PlaySound s30
ElseiF Key(vk_left) <0 and zlev > 1 and yCur=224 and CurL=0
zlev -=1: CurL=1
PlaySound s30
ElseiF Key(vk_space) <0 And yCur =224 and iRet=0
iRet=1
'DataInit()
'Times = xTime(zLev)
'Gems = xGems(zLev)
LoadFile "Maps\Map" + zLev + ".bin",cMap
'FindDigger()
'MainGame()
'ElseiF yCur =240
'PlayerInput()
ElseiF Key(vk_space) <0 And yCur =256 and iRet=0
iRet=1
'ShowHighScore()
ElseiF Key(vk_space) <0 And yCur =288
DrawTexture Peti,430,300,128,128
ElseiF Key(vk_space) <0 And yCur =272
'SavePlayer()
Exit Sub '< 1 excess left brackets in source ((..)
End iF
DoEvents
SwapBuffers hDC
WaitFrames 25
iF Key(vk_right) =0 Then CurR=0
iF Key(vk_left) =0 Then CurL=0
iF Key(vk_Up) =0 Then CurU=0
iF Key(vk_Down) =0 Then CurD=0
iF Key(vk_space =0 Then iRet=0
Wend
End Sub
yCur=224: xCur=336
MainMenu
I also noticed that 'ElseiF Key(vk_return) <0' has no effect! Key is = GetAsyncKeyState() : vk_return = 0x0D
The other 17 'excess left brackets in source ((..)' are similar built.
I have got 4574 lines right now. If I leave aside 'Exit Sub' then is anything Okay!
-
Peter,
I noticed there is a missing right bracket towards the end:
iF Key(vk_space =0 Then iRet=0
Charles
-
Yes, but it gave no error. It is a case for the administrator.
I stuck in a trap. >:(
Better error handling would be good. ;D
-
'ElseiF Key(vk_return) <0' has no effect!
GetAsyncKeyState returns a short integer. If you use low level binding then this fact will not be known to the compiler and it will assume a sys value (long) is the return type, resulting in a negative value being seen as a positive value.
http://msdn.microsoft.com/en-us/library/ms646293(v=vs.85).aspx
Charles
-
I knows it! That is no problem here.
modifications:
Every 'Exit Sub' is now Return 0. That goes! No error message here!
-
With subs you can use simple return
I don't know why you are getting errors with exit sub though.
Charles
-
Hi Charles,
I translate each of the 500 routines in a single manner.
(SUB EXIT) stays problematic.
This will become the first GL-GAME, and I am quite new therewith.
But I will try it likewise.
I hope that I will find some bugs for you.
-
Peter,
I was able to simulate the problem you were having with exit sub and excess left brackets:
suppose the word "exit" got redefined by accident..
%exit 1
sub f1(sys a)
print "ok"
exit sub
end sub
sub f2(sys a)
print "ok"
exit sub
end sub
f1 1
Charles
-
Hi Charles,
Our last hope, new Installation of OxygenBasic v o36 macabre version.
[attachment deleted by admin]
-
More stuff. :D
[attachment deleted by admin]
-
Peter,
Yes that is what happens.
There is a directive that will prevent things being defined more than once:
#unique on
this is generally the default behaviour in Basic but not in Oxygen.
It may help to have this active at least for debugging.
Charles
-
Hi Charles
Okay, (#unique on) must be standard at all!
Exit is that evil word, because Exit Sub is not a whole word like EXITSUB
before the compiler compiles, all spaces must be deleted. This is done by the parser. In German = Syntaxanalysierer.
Do you have no Parser?
Well, I found this word (EXIT) in the gl library, hidden under many other words.
#unique gave me the tip.
-
If you want to tighten up further, Peter:
#autodim off
This ensures that all variables are defined either using a dim statement or in the C style.
Oxygen has lexing, parsing, expression analysis, semantics and several other distinct processes. I endeavour to create a strong modular architecture.
There are many exits and many ends!
You can use 'endif' instead of 'end if' if you prefer. Also enddo and endwhile and endsel, but I have not done this for 'exit' yet.
Charles
-
Peter,
I added this information (and more...) to the wiki 14 days ago:
http://www.oxygenbasic.org/wiki/index.php/FAQ
8)
-
Thanks for all your Wiki notes Frank. Much appreciated.
Charles