Oxygen Basic
Programming => Problems & Solutions => Topic started by: Frankolinox on August 17, 2012, 12:40:03 AM
-
hello charles, do you know where I can find the command "structureof" in source code folder? I noticed that in a "udt type" example (type2) in "basics" folder. best regards, frank
-
Hi,
where I can find the command "structureof"
Return data structure of compund (UDT) or variabe
USE: obtain data for diagnostics or reflective programming
EXAMPLE: type vt long v,double d
dim as vt v : r=recordof v
RESULT: r="
v 0 4 1 A0 , long
d 4 4 1 A0 , double
"
-
Hi Frank, you will find it in o2pars.bas and o2keyw.bas . Just search for 'structureof.
-
Hi,
Alien description:
type ABC
sys p1
single s1
byte b1
string v1
end type
ABC pa
pa = {256,0.125,255,"HELLO"}
print structureof(pa)
'long name p1: ? 019A: type = sys
'long name s1: ? 419A: type = single
'long name b1: ? 819A: type = byte
'long name v1: ? 129A: type = string
print pa.v1 + " Number " + pa.b1
-
Hi,
We need a tutorial about OxygenBasic for easy understanding about this stuff, what
Charles under pressure and drugs has developed.
I think Aurel is the right man for this matter.
He has always time, is in thousand foren and has AurelBasic developed.
First, I thought JRS could it do,but I have my doubts, he knows only ScriptBasic and handies and his holy Linux.
About me, I am sorry, my English too bad for this job. people would laugh about me.
What do you think?
:D :D :D
-
Like David Lynch say:
“Through the darkness of future past, the magician longs to see, one chance out between two worlds, fire walk with me!”
Hi Peter ...you always cheer me up... ;)
Yes you right, Oxygen really need some sort of tutorial or user guide or help
to to present the language in the easiest way.
I think that Kent do something about that but where he stops,i don't know.
My english is not good,bucause i am to lazy to learn gramatic rules. >:(
I don't know many things about oxygen to... ::)
And there is no better person here than Charles...
-------------------------
About content:
General about... syntax rules ...etc
Variable ...types...how to use ...pointers...etc
structure or types or UDT....type/end ...uninon/end....etc
macros...
OOP way...etc...
-
... I am sorry, my English too bad for this job. people would laugh about me.
What do you think?
:D :D :D
Close your eyes and imagine:
Millions of people (programmers and non programmers alike) read the O2-Tutorials...
...not because O2 is such a great language...
...but because they all want to read the hilarious funny tutorials...
...written by you!
Tempting?
;D
-
Oxygen is not quite complete yet and takes a wider range of syntax than other Basics. But I hope we will eventually be able to distil some useful documentation from the substantial collection of examples that we have so far.
Charles
-
thank you charles, peter, aurel and efgee for your feedback. my search engine on my notebook strikes sometimes, it's bad I am thinking. I've searched for "structureof" with "no match found" :)
the more I see the genius structure of oxygenbasic the more I am astonished what's possible with very few code lines. I like oxygen very mucho although there's a lot of things I must go to another planet (for example: jupiter) to understand their language and behaviour (like "avatar" movie) :-) thanks charles! best regards, frank
-
Hi Frank,
Here is the Attributes function in o2pars.bas (handling structureof)
'---------------------------------------------------------
function attributes(s as string, byref i as sys) as string
'=========================================================
'
dim as sys kn,a,c,k,m,wa,ty
dim as string wr,w1
'
kn=maco(mp,5)
'
if ascn=lbr then c=1 : i+=1 'SKIP LEFT BRACKET
'
nmac=1
w1=pword(s,i) 'resolve
nmac=0
ty=typ
'if ascn=91 then fixsqbr(s,i)
'if ascn=lbr then wpfx+=arrayres(s,i,ty,w1)
typ=ty
'
if c then
if ascn=rbr then
i+=1 : skiplspace(s,i) 'BLANK RIGHT BRACKET
end if
end if
'
'
'
wr="0" : k=mp : m=k
'
'VARIABLE OR STRUCTURE ?
'
if mc>=0 then
m=mc
end if
'
'
'
select case kn 'SIZEOF
case 1
if mc=0 then
if isq(ascw) then
wa=cpuw
goto attrin
end if
end if
if mc>=0 then
wa=lent
elseif instrword(" string wstring bstring bstring2 ",w1) then
wa=cpuw
elseif instrword(" char zstring asciiz ",w1) then
wa=1
elseif instrword(" wchar zstring2 ",w1) then
wa=2
elseif mc<0 then
a=identype(w1) : if a then wa=lent
end if
goto attrin
case 2
if mc>=0 then
wa=maco(mp,2)+woff
end if
goto attrin 'OFFSETOF
case 3
if mc>=0 then
wa=wval(macso(mp,2)) 'SPANOF: NUMBER OF ELEMENTS OF MAIN ARRAY
if wa=0 then wa=1
end if
goto attrin
case 4 'TYPEOF:
if mc>=0 then
if len(sog) then
wr=sog
else
wr=identypes(typ)
end if
elseif mc<0 then
wr="metatype "+str(mc)+" "+_
dicsn(metatypes,mc) 'TYPEOF TYPE
end if
case 5
wr=macso(m,1) 'STRUCTUREOF ENCODINGOF
case 6
wr=macso(k,3) 'PROTOTYPEOF
case 7
wa=typ
goto attrin 'TYPECODEOF
case 8
wr=writestates(k,k) 'RECORDOF
case 9
if isstr(typ)=0 then
ert=109 : ers="Not a string"
else
makestrptr(w1)
function=w1 'STRPTR
end if
exit function
end select
'
'
'-----
attris:
'-----
'
if nl then
typ=0 'raw code
else
wr=iq+wr+iq 'quoted string literal
typ=&hc1
end if
'
goto attrix
'
'-----
attrin:
'-----
'
wr=str(wa) : typ=cpuw
'
'-----
attrix:
'-----
'
mc=0 : mp=0 : varf=0
function=wr
'
end function
Charles
-
Charles ...
There is problem in this line with pword()
-unknown function
I have latest oxygen from forum...
what might be that?
-
What is pword?
-
Aurel meant this here:
w1=pword(s,i) 'resolve
-
Yes i mean that.
-
It can't find your pword definition. Is it out of scope?
-
As i say i recive error about unknown function - pword
and before that with maco function...
what are those functions ???
here:
function attributes(s as string, byref i as sys) as string
'=========================================================
'
dim as sys kn,a,c,k,m,wa,ty
dim as string wr,w1
'
kn=maco(mp,5) ' <---- error
'
if ascn=lbr then c=1 : i+=1 'SKIP LEFT BRACKET
'
nmac=1
w1=pword(s,i) 'resolve ' <----error
X
-
Oh I see! you are referring to the source code. You have to compile the whole thing.
fbc -dll Oxygen.bas
I'm using FB version 0.21
pword is part of the parsing suite - it resolves macros, pointers and a few other items.
You will find it further down in o2pars.bas. These functions are often used recursively.
Charles
-
Uops ...i don't know that this is conected with FB source of oxygen.
Charles ...belive me i have never tried to compile oxygen with FB.
I have version v0.20b.
By the way i study examples by Dean Hodgson about how he create multiple windows.
You probably see this example on FB forum.
-
thanks you all :) my example with udt types "structure of" are working well!
nice week-end, here in my home town there's a big celebretion day for summer days and farmers :-) today at sunday there were 38 celsius degree!!!
best regards, frank (and I can repeat it every day thanks for your great oxygen basic works) !