Author Topic: "structureof" command?  (Read 5916 times)

0 Members and 1 Guest are viewing this topic.

Frankolinox

  • Guest
"structureof" command?
« 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

Peter

  • Guest
Re: "structureof" command?
« Reply #1 on: August 17, 2012, 01:14:58 AM »
Hi,

Quote
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
"

Charles Pegge

  • Guest
Re: "structureof" command?
« Reply #2 on: August 17, 2012, 01:44:29 AM »
Hi Frank, you will find it in o2pars.bas and o2keyw.bas . Just search for 'structureof.

Peter

  • Guest
Re: "structureof" command?
« Reply #3 on: August 17, 2012, 03:34:28 AM »
Hi,

Alien description:

Code: [Select]
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

Peter

  • Guest
Re: "structureof" command?
« Reply #4 on: August 17, 2012, 04:06:05 AM »
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

Aurel

  • Guest
Re: "structureof" command?
« Reply #5 on: August 17, 2012, 08:42:08 AM »
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...



efgee

  • Guest
Re: "structureof" command?
« Reply #6 on: August 17, 2012, 08:44:04 AM »
... 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

Charles Pegge

  • Guest
Re: "structureof" command?
« Reply #7 on: August 17, 2012, 10:40:24 AM »

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

Frankolinox

  • Guest
Re: "structureof" command?
« Reply #8 on: August 18, 2012, 12:48:12 AM »
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

Charles Pegge

  • Guest
Re: "structureof" command?
« Reply #9 on: August 18, 2012, 01:23:55 AM »
Hi Frank,

Here is the Attributes function in o2pars.bas (handling structureof)

Code: [Select]

'---------------------------------------------------------
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

Aurel

  • Guest
Re: "structureof" command?
« Reply #10 on: August 18, 2012, 02:01:08 AM »
Charles ...
There is problem in this line with pword()
-unknown function
I have latest oxygen from forum...
what might be that?

Charles Pegge

  • Guest
Re: "structureof" command?
« Reply #11 on: August 18, 2012, 03:58:53 AM »
What is pword?

Peter

  • Guest
Re: "structureof" command?
« Reply #12 on: August 18, 2012, 05:50:03 AM »
Aurel meant this here:

Code: [Select]
w1=pword(s,i) 'resolve

Aurel

  • Guest
Re: "structureof" command?
« Reply #13 on: August 18, 2012, 07:13:25 AM »
Yes i mean that.

Charles Pegge

  • Guest
Re: "structureof" command?
« Reply #14 on: August 18, 2012, 01:04:04 PM »
It can't find your pword definition. Is it out of scope?
« Last Edit: August 18, 2012, 01:28:35 PM by Charles Pegge »