Oxygen Basic
Programming => Problems & Solutions => Topic started by: Aurel on February 14, 2015, 03:43:38 PM
-
Hi Charles
Do you know that number of ElseIf statments are limited to 25 ?
I just discoverd this when i try to add new command in my interpreter parser and
my new elseif is 26 ???
If ...
elseif...
elseif..
end if
block
so if number of elseif is more than 24 then program not work :o
of course i can replace them with ordinary if/end if but i really dont know that else if have limitation
-
There are no limitations on elseifs in Oxygen. It is just a repeating pattern:
if not(new condition) then goto next else
...
goto next endif:
else:
if not(new condition) then goto next else
...
goto next endif:
else:
if not(new condition) then goto next else
...
else:
...
endif:
There is, however, a limit on nesting depth for blocks: I have set it to 100, which I hope is high enough, never to be exceeded.
-
There is, however, a limit on nesting depth for blocks: I have set it to 100, which I hope is high enough, never to be exceeded.
Can these parameters/limits be O2 system variable? In SB the basic.conf files hold the overrides for limits and defaults.
-
Hi John,
There are quite a large number of fixed size buffers/arrays, hard coded at compile time. They have rarely needed to be adjusted during the course of Oxygen's evolution. Flexibility comes at a price :)
Most of them can be found in src/o2glob.bas
-
Charles you get me wrong
i was talk about this :
(this code is part of parser with if/elseif /end if.
'check command :::
If c$="DEFN"
parse_DEFINT()
ElseIf c$="IF"
parse_IF()
ElseIf c$="ENDIF"
parse_ENDIF()
ElseIf c$="SET"
parse_SET()
ElseIf c$="NARRAY"
parse_ARRAYN()
ElseIf c$="WFORM"
parse_WINDOW()
ElseIf c$="FOR"
parse_FOR()
ElseIf c$="NEXT"
parse_NEXT()
ElseIf c$ = "TXCOLOR"
parse_TxColor()
ElseIf c$="WTEXT"
parse_wtext()
ElseIf c$="LINE"
parse_LineXY()
ElseIf c$="CIRCLE"
parse_Circle()
ElseIf c$="RECT"
parse_Rect()
ElseIf c$="PIX"
parse_PsetXY()
ElseIf c$="JUMP"
parse_JUMP()
ElseIf c$="LABEL"
parse_LABEL()
'####################
ElseIf c$="MBOXGTW"
parse_MBoxGetWord()
'......................
'ElseIf c$="CALL"
'parse_CALL()
'ElseIf c$="FUNC"
' parse_FUNC()
'ElseIf c$="ENDFUNC"
' parse_ENDFUNC()
'......................
ElseIf c$="WCOLOR"
parse_WINCOLOR()
ElseIf c$="WCON"
parse_WINCONTROL()
ElseIf c$="WAIT"
parse_WAIT()
ElseIf c$="@OFF"
parse_OFF()
ElseIf c$="@ONCLICK"
parse_OnClick()
ElseIf c$="@MOUSEMOVE"
parse_MouseMove()
ElseIf c$="@MOUSEX"
parse_MouseX()
ElseIf c$="@MOUSEY"
parse_MouseY()
End If
well if i add one more elseif condition then program refuse to work or start
so it is clear if is more than 25 elseif then program not work .
-
Not true, Aurel
int a=10,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z=1
if a=1 then
print a
elseif b=1 then
print a
elseif b=1 then
print a
elseif c=1 then
print a
elseif d=1 then
print a
elseif f=1 then
print a
elseif g=1 then
print a
elseif h=1 then
print a
elseif i=1 then
print a
elseif j=1 then
print a
elseif k=1 then
print a
elseif l=1 then
print a
elseif m=1 then
print a
elseif n=1 then
print a
elseif o=1 then
print a
elseif p=1 then
print a
elseif q=1 then
print a
elseif r=1 then
print a
elseif s=1 then
print a
elseif t=1 then
print a
elseif u=1 then
print a
elseif v=1 then
print a
elseif w=1 then
print a
elseif x=1 then
print a
elseif y=1 then
print a
elseif z=1 then
print a
endif
print "okay"
-
Yes it is because i have strings NOT integers
-
peter try this one ...so must be printed last string which is OK
but is not printed OK then 26
string a="26",b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x="OK",y,z="26"
if a=z
print a
elseif b=z
print a
elseif b=z
print a
elseif c=z
print a
elseif d=z
print a
elseif f=z
print a
elseif g=z
print a
elseif h=z
print a
elseif i=z
print a
elseif j=z
print a
elseif k=z
print a
elseif l=z
print a
elseif m=z
print a
elseif n=z
print a
elseif o=z
print a
elseif p=z
print a
elseif q=z
print a
elseif r=z
print a
elseif s=z
print a
elseif t=z
print a
elseif u=z
print a
elseif v=z
print a
elseif w=z
print a
elseif x=z
print a
elseif y=z
print a
elseif z=a
print x
endif
print "okay"
-
Hi Aurel,
your example works as expected. If you delete the first 'if a=z' then you will reach the final 'if a=z' and produce x 'OK'
-
Aurel;
.
-
sorry charles but i don't post without reason
i have tested my original if/elseif and not work as it should be ...
for example what result you get with this program...
i get 2 ::)
string a="2",b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,zz=""
if a=z '1
print "1"
elseif b=z '2
print a
elseif c=z '3
print a
elseif d=z '4
print a
elseif e=z '5
print a
elseif f=z '6
print a
elseif g=z '7
print a
elseif h=z '8
print a
elseif i=z '9
print a
elseif j=z '10
print a
elseif k=z '11
print a
elseif l=z '12
print a
elseif m=z '13
print a
elseif n=z '14
print a
elseif o=z '15
print a
elseif p=z '16
print a
elseif q=z '17
print a
elseif r=z '18
print a
elseif s=z '19
print a
elseif t=z '20
print a
elseif u=z '21
print a
elseif v=z '22
print a
elseif w=z '23
print a
elseif a=zz '24
print "24"
'elseif y="" '25 'y=""
' print "OK" 'print "OK"
'elseif zz=a '26 comment this part and change in 25 item a to "" empty
' print "OK"
end if
-
2 is the correct answer :)
-
2 is the correct answer! ;D
-
I really don't know what is wrong with version of o2 dll which i use
and it looks that i must avoid all SELECT /END SELECT things
and use IF / END IF
Also i need to modify all event messages....c***
::)
-
Poor Aurel, there is a new dll in space. :D
-
Hi Peter...
unfortunately last dll from Arnold post not work properly or worst
it just crush program when WM_COMMAND event is called .
I relly cannot understand WHY any new bug fixed version have some strange
conflict with windows api :(
i will try use dll from last oxygen release to see...
-
this old dll work for me 479kB
.
-
Hi Aurel,
The last dll works well, tried it with my asm library, there were not problems!
Dll date: 11.02.2015
-
Peter i can agree right now that last dll work with your programs but not
with mine.
I suspect on Bind ()
which seems that makes whole bunch of problems in oxygen
And i use a lot of strings in my programs so this is completely differnt stuff than you use ..
-
Hi Aurel,
AsciEdit2 and WebBrowserATL still work, so Bind in awinh.inc is okay.
-
sorry Charles
i really don't know what to say...
in attachment is miniRub with two example which work when ruben2 interpreter is compiled
with old dll...
but when i compile with latest dll then interpreter crush or not respond
.
-
Hi Aurel,
I am able to compile and run ruben2 (clickdraw.rub), using drag and drop onto the exe file.
I supplied awinh.inc from the projectsB/Scintilla folder, and RTL32 from /inc.
Is your RTL32.inc up to date?
-
Hi Aurel,
why do you use such an outdated SciLexer.dll?
I do my projects outside of OxygenBasic and use e.g. Include "$\inc\rtl32.inc", so my OxygenBasic stays untouched. Before I unzip a new OxygenBasic download, I rename the old o2h folder adding a date, so I can compare with previous versions.
I renamed your rubens2.exe and copied the files which Charles indicated. I can confirm that after compiling your rubens2.o2bas and then drag and drop ClickDraw.rub or MouseMove.rub to the exe file will crash the rubens2.exe. This will also happen if I use a previous build (A40 "06:30 30/01/2015") The size of your exe file is ca 100 kb, the size of my file ca 99 kb.
I have an older build of last year ("20:21 01/07/2014"). Here compiling to an exe and running it works (with the latest rtl32.inc file). The size of the exe is about the same as yours but not exactly.
I do not know if the result differs when using 32bit or 64bit. And I do not know why I get a different result as Charles. But I think you should at least use a more up to date SciLexer.dll?
Roland
-
Hi Aurel,
I am able to compile and run ruben2 (clickdraw.rub), using drag and drop onto the exe file.
I supplied awinh.inc from the projectsB/Scintilla folder, and RTL32 from /inc.
Is your RTL32.inc up to date?
Hi Charles
If i understand properly you are able to compile ruben2 using latest dll + latest RTL32
so if that is true then problem is in my old RTL32.inc
Ok Charles i ill try this .... ;)
-
Hi Aurel,
why do you use such an outdated SciLexer.dll?
I do my projects outside of OxygenBasic and use e.g. Include "$\inc\rtl32.inc", so my OxygenBasic stays untouched. Before I unzip a new OxygenBasic download, I rename the old o2h folder adding a date, so I can compare with previous versions.
I renamed your rubens2.exe and copied the files which Charles indicated. I can confirm that after compiling your rubens2.o2bas and then drag and drop ClickDraw.rub or MouseMove.rub to the exe file will crash the rubens2.exe. This will also happen if I use a previous build (A40 "06:30 30/01/2015") The size of your exe file is ca 100 kb, the size of my file ca 99 kb.
I have an older build of last year ("20:21 01/07/2014"). Here compiling to an exe and running it works (with the latest rtl32.inc file). The size of the exe is about the same as yours but not exactly.
I do not know if the result differs when using 32bit or 64bit. And I do not know why I get a different result as Charles. But I think you should at least use a more up to date SciLexer.dll?
Hi Arnold
I use old 1.6.8.0 version of scintilla because works fine for me and is small .
Yes Arnold i also get crushed ruben2 if i use latest dll BUT as Charles might be problem in older
RTL32.inc...so i will see
But if you whish to build on my way u must use old dLL ( i really don't know when is released ??)
and then will work on your computer to.
-
Some RUB programs I can get working, some not. It looks like an overflow corruption problem somewhere.
-
I must correct myself. I did not notice the very last build.
Charles: if I see below the magician the time: February 16.2015 7:13, is this time shown with all browsers in the world?
When I run the compiled code, mousemov.rub works, ClickDraw.rub gives a GPF. For me this is an indication, that something is not ok with the code. (Some of my projects do not work ok neither, but I will correct them).
When I looked into the code of ruben2.o2bas, I got a big surprise. There is so much well structured code in the demos of Oxygen and the contributions, but this code is very hard to read. The first thing I did was to format it with indenter.o2bas. I had to check with my text-diff tool of PsPad, because there seems to be some whitespace in Rubens2.o2bas which confuses indenter.o2bas. Anyway my_Rubens2.o2bas is the same line by line code, but indented.The next thing I will do is to comment out #lookahead to arrange a bottom up reconstruction.
Charles: Reading the OxygenBasic help is my assuption correct?
(one line instruction)
if a>b then a print a (no more statements)
if a>b then print a else print b (if using : then this is no one liner?)
multi line instruction)
'MULTI-LINE FORMAT
if a>b then
s=`A>B`
elseif a=b then
s=`A=B`
else
s=`A<B`
end if
Is 'then' mandatory with this construct? I use it intuitively, because it looks much clearer to me.
I also found gosub in the code. What is the best way to use gosub? There are some demos supplied with OxygenBasic and Oxygen seams to be very tolerant.
Roland
.
-
Hi Roland,
Yes, if .. then .. else .. can be used as a single liner
But I agree that the multi-line format is clearer and more useful for all but the simplest of statements.
I am also looking closely at Aurel's code. As you can see it is a combination of many different coding styles. There is a particular problem with Tally. I found that any attempt to alter it renders the exe file unusable.
I think it would benefit from a full rewrite - that would bring the source code down from 77k to about 30k, and eliminate most of the string variables.
Gosub is intended for labelled suboutines located within an individual procedure, able to operate within the same scope. But it can be used to call another procedure which has no arguments, and does not need to share its internal variables.
-
but this code is very hard to read *** is combination of many coding styles
ahh sorry guys blame on me ... ;D
In fact ruben2 is not to complex at all ..most of things are very transparent.
I have discovered one maybe crucial problem in ruben2
inside SUB RunCode i use PeekMessage api function to prevent blocking of message
interception and it looks that this small routine create conflict with new window
which must be able to operate with events (message processing)...
strange thing is that is not in conflict by WM_COMMAND but is with WM_MOUSEMOVE...
I must fix that...
About GOSUB i think that if you use GOSUB subName you don't need to use
parenth like you can without gosub like
MySubProgram()
-
Hi Aurel,
I give up with trying to get Ruben2.o2bas structured bottom up. First there was a loop: Expression, Term. Factor, Expression. Now I find the flow: Getvar calls GerFunc which calls EvalLine which calls Expression which calls Term which calls Factor Which calls Getvar ... This is not worth the trouble any more- At least this is too difficult for me.
If your code works with an older version of Oxygen you are lucky. As I am only a hobby programmer I only will do some small projects. I admire the people who can solve difficult problems in an elegant recursive manner, but I never saw that they used mutual function calls in this extensive manner.
Roland
-
but I never saw that they used mutual function calls in this extensive manner
hi Arnold
this is not something ultra special but i created in little bit crazy way...i am not original
author of this expression evaluator than one guy from PureBasic forum called tronD.
I use this evaluator when i search for evaluator who not produce memory leaks with string
operation and this one work very well and fast.
I don't think that evaluator is a problem that ruben2 not work under latest dll but
something else..but what it is not easy to say because compiler not report any error.
This time can be error in more than one things and is not easy to say where...
however it work :)