Oxygen Basic
Programming => Bugs & Feature Requests => Topic started by: Peter on December 01, 2012, 06:55:33 AM
-
Deleted
-
Ugh! I am a hostage to fortune
Is this better Peter?
X
-
Ugh! I am a hostage to fortune
@Charles - Remember O2 is open source. Rephrased: I am a hostage to perfection
-
Weeds in my garden:
(http://www.bbc.co.uk/gardening/images/gardening_with_children/300x193_weeds.jpg)
-
Weeds in my garden
The people of Washington State just legalized pot. (use and sale) Puts a whole new spin on weeds in the garden. :o
-
That is an amazing turnaround! Until recently, You might have expected 10 years of incarceration for such an evil crime!
-
Colorado has also legalized pot in the last elections. So far the federal government (still a crime) hasn't made any moves to override the states authority. Interesting times.
more ... (http://seattletimes.com/html/localnews/2019812886_apuslegalizingmarijuanahowithappened.html)
-
A few things that appear to me like bugs:
this prints zero:
function myf() int
return 1
end function
print myf()
and this prints no function result:
function myf() int
return 1
end function
print myf() "zzz..."
this crashes:
function myf() int
int i
return 1
end function
print myf() "zzz..."
and some more:
these two fragments to my limited understanding should do exactly the same, but they do not (not always). #1 OB, and #2 FreeBasic, with FB doing correct. [sorry for the formatting - the board destroys the original formatting..]
#case sensitive
#indexbase 0
type Node
int nextnode[25]
int id
end type
string keys[2] <= {"", "CONTINUE", "FOR"}
Node tree[999]
sub Populate
int c, i, node, nodes = 1
byte* p
for c = 1 to 2
@p = strptr keys[c]
node = 0
while p != 0
i = p - 65
if tree[node].nextnode[i] == 0 then
tree[node].nextnode[i] = nodes
nodes++
end if
node = tree[node].nextnode[i]
@p++
wend
tree[node].id = c
next
end sub
function Scan(string s) as int
int i, node = 0
byte* p
@p = strptr s
while p != 0
i = p - 65
if tree[node].nextnode[i] == 0 then exit while
node = tree[node].nextnode[i]
@p++
wend
if tree[node].id != 0 and p == 0 then return tree[node].id
return 0
end function
'''main'''
Populate
print Scan("FR")
type TNode
as integer nextnode(25)
as integer id
end type
static shared as zstring * 12 keys(2) => {"", "CONTINUE", "FOR"}
dim shared as TNode tree(999)
sub Populate
dim as integer c, i, node, nodes = 1
dim as zstring ptr p
for c = 1 to 2
p = @keys(c)
node = 0
while *p <> 0
i = *p - 65
if tree(node).nextnode(i) = 0 then
tree(node).nextnode(i) = nodes
nodes += 1
end if
node = tree(node).nextnode(i)
p += 1
wend
tree(node).id = c
next
end sub
function Scan(s as zstring ptr) as integer
dim as integer i, node = 0
dim as zstring ptr p
p = s
while *p <> 0
i = *p - 65
if tree(node).nextnode(i) = 0 then exit while
node = tree(node).nextnode(i)
p += 1
wend
if tree(node).id <> 0 and *p = 0 then return tree(node).id
return 0
end function
'''main'''
Populate
print Scan("FR")
sleep
-
Hi Jumpandrun,
function myf() as int
function myf() as int
return 1
end function
print myf()
-
ok, but OB does not complain about the missing "as"..
and what is the difference in the two codes OB/FB?
-
Yes, it should be possible to make the return typer as optional without disrupting other keys. I will investigate.
PS:
string keys[2]={"CONTINUE", "FOR"}
-
string keys[2]={"CONTINUE", "FOR"}
unfortunately does not change the outcome..
so, is there no automatic counting of elements by the compiler?
-
I've checked prototype parsing and we definitely need the as key to avoid other syntax conflicts.
Array elements are not automatically counted at present.
But the same syntax can be used to fill elements of compound types and arrays of compound types. Unlike C, multiassignments can be done any time and from any offset.
example:
type location string name, single x,y,z
location loclist[8]
loclist[2]<=
"A", 1,1,1,
"B", 1,1,2,
"C", 2,1,3,
"D", 2,1,4
print loclist[3].name + loclist[3].z ' B2
-
Charles ...
I download latest oxygen.dll and replace with old wihich i currently use
BUT now compiler complain that there is error:
cc = Tally(temp$,",")
he say that error is with comma inside quote ???
Is this bug ?
/ So i must use again old oxygen.dll (409kB) - which work with oxyMapy / >:(
-
Should be okay, Aurel. Can it locate Tally?
I checked a version of tally with #lookahead
#lookahead
string temp$=" ,,, , , , ,"
cc = Tally(temp$,",")
print cc '7
end
function tally(string s,k) as sys
sys a,c
a=1
do
a=instr a,s,k
if a
c++
a+=len k
else
exit do
end if
end do
return c
end function
-
Aha...Ok Charles ;)
I will check this now ...
-
Charles...
latest oxygen dll not work properly .
look i have this in include file:
'MsgBox--------------------------------
Function MsgBox (lpText AS STRING,lpCaption AS STRING) as INT
RETURN MessageBox 0,lpText,lpCaption,0
End Function
It is simple MsgBox function, i also have try with byref and with byval
and not work ...
i have receive strange error that wndproc not found ???
It is strange that work inside subroutine in program ???
prog:
'test
include "awinh.inc"
MsgBox "Message...","Title"
And more strange thing sometimes not compile then gxo2 just stay hangin in memory :o
what kind of errors is all about ???
and also again Tally( temp, delim) not work...
This time i dont have any lookahead in awinh.inc
I really don't know what to do.. :-\
with every new oxygen.dll more and more problems , so i again must use older dll (409kB).
Charles please,do you can concentrate on bug fixed release ...then adding new asm or what ever else
function ,so please make bug fixed version that most of us can use our older programs with few
modifications..etc and not with constant errors,crushes...etc..
thanks ..Aurel ;)
-
Hi Aurel, I test new DLLs on your projectsB/Scintilla/AsciEdit, among many other progs, but yes this is very odd. If you add any statement after masbox, like a=4, then it works fine
My test code:
'u=loadlibrary "user32.dll"
'bind u
'{
' MessageBox MessageBoxA
'}
Library "user32.dll"
! MessageBox alias "MessageBoxA"
Library ""
Function MsgBox (lpText AS STRING,lpCaption AS STRING) as INT
If lpCaption = "" then lpCaption="<MsgBox>"
Return MessageBox 0,lpText,lpCaption,0
End Function
MsgBox "hello","title"
a=4
'print "ok"
'MessageBox 0,"AA","BB",0
PS: it appears to be caused by the last param on the last line of a prog being a quoted string. If you add enclosing brackets or use a variable, its okay. This looks an old bug and you discovered the evil combination. So Thank you for exposing it :)
-
Thanks Charles.. ;)
Maybe sometimes my posting here looks like trolling or something like that.
But i am very impressed with your work... :)
I always watch very close what was heapend in any of my program.
Of course anyone can make mistake or miss something.
keep up and i hope that all things will work properly... ;)
-
Library is a directive rather than a control block. Personally, I prefer extern .. end extern.
extern may include lib, calling-convention, export and/or virtual
extern lib "kernel32.dll" stdcall
!..
end extern
extern stdcall export
myfun(...)
...
end function
end extern
-
I agree with Peter that Declare Function or !
! MessageBoxA Lib "user32.dll" (sys hwnd, string lpText, lpCaption, sys wType) As Long
is far easier and better .
Charles when we can espect bug fixing with this weird string litteral problem?
-
Charles
I don't know why again Tally(temp,",") is not work.
so i try :
Tally(temp,chr(44))
and agin not work ,how is this posible ,is this some really weird bug or something starange that
compiler can see chr()... ???
-
I dont have an original but here is a byte-based tally. It skips quoted words, but is also able to count individual quote marks.
function tally(string s,k) as sys
'
if s="" or k="" then exit function
byte sb at (strptr s)
byte kb at (strptr k)
sys lk=len k
sys ls=len(s)-lk+1
sys i=1
sys j
indexbase 1
'
do
if sb=34 or sb=39 or sb=96 ' " `
if sb<>kb
byte cq=sb
do 'SKIP QUOTE
@sb++
i++
if i>ls
jmp fwd done 'LIMIT
elseif sb=cq
exit do
end if
end do
end if
end if
if sb=kb
j=2
do
if j>lk
exit do
end if
if sb(j)<>kb(j)
j=0 : exit do 'NO MATCH
end if
j++
end do
if j>lk
function++ 'TALLY
i+=lk
@sb+=lk
continue do
end if
elseif i>ls
exit do 'LIMIT
end if
@sb++
i++ 'NEXT BYTE
end do
done:
end function
print tally("one,two,three,,`,q,`","`") '2
print tally("one,two,three,,`,q,`","`,q,`") '1
print tally("one,two,three,one,`,q,`","one") '2
print tally("one,two,three,one,`,q,`",chr(44)) '4
-
Hi Charles..
here is Tally which i use because i need to store commas positions in array:
FUNCTION Tally(STRING Main$,STRING Match$) As INT
'print "TALLY:" + main$
DIM i,j,q,mlen,matchlen As INT
DIM t$ As STRING
mlen = LEN(Main$)
matchlen = LEN(Match$)
i = 1
j = 0
q = 0
IF (mlen = 0) OR (matchlen = 0)
RETURN j
END IF
do
t$ = MID(Main$,i,matchlen)
IF t$ = Chr(34) THEN q = q + 1
IF q=2 THEN q = 0
IF t$ = Match$ AND q=0
j++
'mem del$ position
dpos[j]=i
'j = j + 1
END IF
i++
IF i > mlen then
exit do
END IF
end do
'tbreak:
RETURN j
END FUNCTION
So o2 complain like this:
That strings inside not defined... ???
-
here is shot of this wird error ,o2 see function with main as string even is not defined in tally function ???
X
-
We seem to have acquired sensitivity to "$" suffixes attached to parameter names, when using C style prototypes. If you remove the '$' from both parameter names, it should work. I only support it as a legacy, but this should be quite easy to fix.
-
So Charles
i must remove from every string name $ ...this is really weird.
I don't see that any other compiler complain about using $ or any other character on the end of varible
name...
So do i must remove all $ from string variable names or not ???
-
Aha ...
I forget to look into Oxygen update topic... ::)
Thanks Charles finally work OK ,like in old oxygen version ;)
just one small point maybe someone else find this unusual...
when we have:
FUNCTION Tally(byval Main$ as string,byval Match$ as string) As int
this cose error in reading function BUT
when we use this:
FUNCTION Tally(Main$ as string,Match$ as string) As int
then work fine...
;)