Oxygen Basic
Programming => Problems & Solutions => Topic started by: Aurel on October 20, 2013, 12:20:23 PM
-
Charles
This thing look very weird to me ,
Why variable id is not set by p in this simple function ???
Infact is it set but it looks that is not visible to outside print statment ??
string vList[65535]
int rList[65535]
int id
function Lookup(string k) as int
=====================================
int p,v,i
i = 65534
vList[i]="target"
rList[i] = 4
string s
DO
s=vList[p]
If s = k
v = rList[p]
id = p
'print str(id) 7/ here is id 65534
exit do
End If
p=p+1
if p=65535 then exit do
END DO
Return v
end function
'but here is id set to null ??
print "Pos<ID>: " + str(id) +" " + Lookup("target")
-
This had me puzzled for a while :)
In the print expression: id is evaluated before Lookup is executed, (to alter the value of id)
The prog also needs indexbase 0
-
Hmm..
this way work...
but i suspect that something is wrong ,because other ways not work at all.. ???
'$ filename "lookup.exe"
'include "rtl32.inc"
'include "awinh.inc"
#lookahead
string vList[65535]
int rList[65535]
int id,res
'indexbase 1
res=LookUp("target")
string rs
rs=str(res)
'MsgBox(res,"ok")
print res + " " + str(id)
function Lookup(string k) as int
=====================================
int p,v
i = 65534
vList[i]="target"
rList[i] = 4
string s
DO
s=vList[p]
If s = k
v = rList[p]
id = p
'print str(id)
exit do
End If
p=p+1
if p=65535 then exit do
END DO
Return v
end function
-
How about this one:
indexbase 0
#lookahead
'STORAGE
========
string vList[65535]
int rList[65535]
'TEST DATA
==========
int i = 65534
vList[i]="target"
rList[i] = 4
'TEST LOOKUP
============
int res,id
res=LookUp("target",id)
print "res: " res " id: " id
function Lookup(string k,int*p) as int
======================================
p=0
do
if k=vList[p]
return rList[p]
end If
p=p+1
if p=65535 then exit do
end do
end function
Simplified further:
function Lookup(string k,int*p) as int
======================================
for p=0 to 65535
if k=vList[p]
return rList[p]
end if
next
end function
-
Now work ,even without indexbase 0...
hmmm
but when i try with include file then not work
because i use MsgBox() functiom from awinh.inc...
well sometimes i am completely confused where to look...
ok.. ;)
-
Subtle but important correction to the right macro:
macro right(s,i)
mid(s,-(i))
end macro
-
thanks Charles
i know for that and i fix this...
I will compare my few programs with latest oxygen and with older release
just to see why some things not work as espected....
because something is not as it has to be .
-
so i try with older oxygen.dll and yes ...
with this older version all my programs work without problems
so i will use this older version and wait for new release.
:)
-
Hi Aurel, if you post your latest, I will try it with the Oxygen I am working on.
-
Ok Charles
I will send you code there is no problem about that.
But just one thing...
error is the same as in some old versions of oxygen which point into
simple Tally function and is about comma inside Tally(src,",")
so here is well know tally...
FUNCTION Tally (string Main$,string Match$) As INT
'print "TALLY:" + main$
INT n
For n=1 TO 20:dPos[n]=0:Next n
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
Compiler complain about this comma sign ,why?
then complain about MsgBox() function to...
'MsgBox--------------------------------
Function MsgBox (lpText AS STRING,lpCaption AS STRING) as INT
If lpCaption = "" then lpCaption="<MsgBox>"
Return MessageBox 0,lpText,lpCaption,0
End Function
-
then complain about MsgBox() function to...
Function MsgBox (sys hwnd, string lpText, lpCaption, sys flags) as INT
If lpCaption = "" then lpCaption="<MsgBox>"
Return MessageBox 0,lpText,lpCaption,0
End Function